ARTS  1.0.222
messages.h
Go to the documentation of this file.
1 /* Copyright (C) 2000, 2001 Stefan Buehler <sbuehler@uni-bremen.de>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
39 #ifndef messages_h
40 #define messages_h
41 
42 #include <iostream>
43 #include <fstream>
44 #include "arts.h"
45 
63 class Messages {
64 public:
67  Messages() : screen(-1), file(-1) { /* nothing to do here */ }
72 };
73 
74 
84 template<class T>
85 void MessagePrint(ostream& os, Index priority, const T& t)
86 {
87  extern Messages messages;
88  extern ofstream report_file;
89 
90  // cout << "Printing object of type: " << typeid(t).name() << endl;
91 
92  if (messages.screen >= priority)
93  os << t;
94 
95  if (messages.file >= priority)
96  // if (report_file) // Check if report file is good
97  {
98  report_file << t;
99  report_file.flush ();
100  }
101 }
102 
103 /* Parent class for all output streams. These control the level of detail
104  for your output. There are four output streams altogether, out0 to
105  out3. Out0 means highest priority, out3 lowest. Out0 and out1
106  should not be used within methods, only by the ARTS engine.
107 
108  Nothing is done in this class, it just servers to group the four
109  output stream classes together.
110 
111  \see Messages */
112 //class OutStream {
113 //};
114 
115 
120 class Out0 {
121 };
122 
126 class Out1 {
127 };
128 
132 class Out2 {
133 };
134 
138 class Out3 {
139 };
140 
141 //--------------------< Output Operators >--------------------
142 
144 template<class T>
145 Out0& operator<<(Out0& os, const T& t)
146 {
147  MessagePrint(cerr,0,t);
148  return os;
149 }
150 
152 template<class T>
153 Out1& operator<<(Out1& os, const T& t)
154 {
155  // cout << "Outing Object Of Type: " << Typeid(T).Name() << Endl;
156  MessagePrint(cout,1,t);
157  return os;
158 }
159 
161 template<class T>
162 Out2& operator<<(Out2& os, const T& t)
163 {
164  MessagePrint(cout,2,t);
165  return os;
166 }
167 
169 template<class T>
170 Out3& operator<<(Out3& os, const T& t)
171 {
172  MessagePrint(cout,3,t);
173  return os;
174 }
175 
176 //----------< Make output streams globally visible >----------
177 
178 extern Out0 out0;
179 extern Out1 out1;
180 extern Out2 out2;
181 extern Out3 out3;
182 
183 
184 
185 #endif // messages_h
Messages::Messages
Messages()
Default constructor.
Definition: messages.h:67
Out2
Medium priority output stream.
Definition: messages.h:132
out1
Out1 out1
Level 1 output stream.
Definition: messages.cc:52
Messages
The verbosity level for screen and file output.
Definition: messages.h:63
messages
Messages messages
Verbosity levels.
Definition: messages.cc:45
out3
Out3 out3
Level 3 output stream.
Definition: messages.cc:56
Out1
Engine output stream.
Definition: messages.h:126
Out3
Lowest priority output stream.
Definition: messages.h:138
Messages::screen
Index screen
Verbosity of screen output.
Definition: messages.h:69
report_file
ofstream report_file
The report file.
Definition: messages.cc:41
Out0
Highest priority output stream.
Definition: messages.h:120
out2
Out2 out2
Level 2 output stream.
Definition: messages.cc:54
out0
Out0 out0
Level 0 output stream.
Definition: messages.cc:50
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: arts.h:153
MessagePrint
void MessagePrint(ostream &os, Index priority, const T &t)
Print a message to stream and report file.
Definition: messages.h:85
Messages::file
Index file
Verbosity of file output.
Definition: messages.h:71
operator<<
Out0 & operator<<(Out0 &os, const T &t)
Output operator for Out0.
Definition: messages.h:145
arts.h
The global header file for ARTS.