DOLFIN
DOLFIN C++ interface
LogStream.h
1 // Copyright (C) 2003-2009 Anders Logg
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // Modified by Garth N. Wells 2005.
19 
20 #ifndef __LOG_STREAM_H
21 #define __LOG_STREAM_H
22 
23 #include <complex>
24 #include <string>
25 #include <sstream>
26 
27 namespace dolfin
28 {
29 
30  class Variable;
31  class MeshEntity;
32  class MeshEntityIterator;
33  class Point;
34 
38 
39  class LogStream
40  {
41  public:
42 
44  enum class Type {COUT, ENDL};
45 
47  LogStream(Type type);
48 
50  ~LogStream();
51 
53  LogStream& operator<< (const LogStream& stream);
54 
56  LogStream& operator<< (const std::string& s);
57 
59  LogStream& operator<< (int a);
60 
62  LogStream& operator<< (unsigned int a);
63 
65  LogStream& operator<< (long int a);
66 
68  LogStream& operator<< (long unsigned int a);
69 
71  LogStream& operator<< (double a);
72 
74  LogStream& operator<< (std::complex<double> z);
75 
77  LogStream& operator<< (const Variable& variable);
78 
81  LogStream& operator<< (const MeshEntity& entity);
82 
84  LogStream& operator<< (const Point& point);
85 
87  void setprecision(std::streamsize n);
88 
89  private:
90 
91  // Type of stream
92  Type _type;
93 
94  // Buffer
95  std::stringstream buffer;
96 
97  };
98 
100  extern LogStream cout;
101 
103  extern LogStream endl;
104 
105 }
106 
107 #endif
Common base class for DOLFIN variables.
Definition: Variable.h:35
Definition: adapt.h:29
Definition: Point.h:40
LogStream endl
dolfin::endl;
void setprecision(std::streamsize n)
Set precision.
Definition: LogStream.cpp:122
LogStream & operator<<(const LogStream &stream)
Output for log stream.
Definition: LogStream.cpp:46
LogStream(Type type)
Create log stream of given type.
Definition: LogStream.cpp:36
~LogStream()
Destructor.
Definition: LogStream.cpp:41
Definition: LogStream.h:39
Definition: MeshEntity.h:42
LogStream cout
dolfin::cout
Type
Stream types.
Definition: LogStream.h:44