Chombo + EB
3.2
src
BaseTools
Printable.H
Go to the documentation of this file.
1
#ifdef CH_LANG_CC
2
/*
3
* _______ __
4
* / ___/ / ___ __ _ / / ___
5
* / /__/ _ \/ _ \/ V \/ _ \/ _ \
6
* \___/_//_/\___/_/_/_/_.__/\___/
7
* Please refer to Copyright.txt, in Chombo's root directory.
8
*/
9
#endif
10
11
#ifndef _PRINTABLE_H_
12
#define _PRINTABLE_H_
13
14
#include <ostream>
15
#include "
BaseNamespaceHeader.H
"
16
17
/**
18
* This class encapsulates the concept of `printability',
19
* it automatically associates the output operator
20
* to a derived class via a virtual method
21
* to get around the problem of polymorphic operator being illegal in C++.
22
*
23
* Typical usage:
24
* (1) inherit from Printable
25
* Class A : Class Printable
26
* (2) define the method print() in A
27
* (3) use '<<' operator for objects of class A
28
*
29
* Variants of print can be added for different flavors.
30
*/
31
class
Printable
32
{
33
public
:
34
virtual
~Printable
()
35
{
36
}
37
38
virtual
void
print
(std::ostream& )
const
= 0;
39
};
40
41
inline
std::ostream&
operator<<
(std::ostream& os,
const
Printable
& p)
42
{
43
p.
print
(os);
44
return
os;
45
}
46
47
#include "
BaseNamespaceFooter.H
"
48
#endif
Printable::~Printable
virtual ~Printable()
Definition:
Printable.H:34
operator<<
std::ostream & operator<<(std::ostream &os, const Printable &p)
Definition:
Printable.H:41
BaseNamespaceHeader.H
Printable::print
virtual void print(std::ostream &) const =0
Printable
Definition:
Printable.H:31
BaseNamespaceFooter.H
Generated by
1.8.13