NAMD
DataStream.h
Go to the documentation of this file.
1 
7 /*
8  Defines a new stream: dout, for data logging.
9 */
10 
11 #ifndef DATASTREAM_H
12 #define DATASTREAM_H
13 
14 #include "InfoStream.h"
15 
16 class datastream : public std::ostringstream
17 {
18  public:
21 
22  void endd();
23 
24  /* define how to use the remaining << args */
26  datastream& operator<<(std::ostream& (*f)(std::ostream&)) { f(*this); return(*this); }
28  datastream& operator<<(datastream& (*f)(datastream&)) { return f(*this); }
29 
30  #define LOCALMOD(type) datastream& operator<<(type x) \
31  { (std::ostream&)(*this) << x; return(*this); }
32 
33  LOCALMOD(char);
34  LOCALMOD(unsigned char);
35  LOCALMOD(const char *);
37  LOCALMOD(int);
38  LOCALMOD(long);
39  LOCALMOD(short);
40  LOCALMOD(unsigned int);
41  LOCALMOD(unsigned long);
42  LOCALMOD(unsigned short);
44  LOCALMOD(float);
45  LOCALMOD(double);
47  LOCALMOD(void *);
48  LOCALMOD(std::streambuf *);
49  #undef LOCALMOD
50 };
51 
52 datastream& operator<<(datastream& strm, const Vector &v1);
53 
54 datastream& operator<<(datastream& strm, const Tensor &t1);
55 
57 inline datastream& endd(datastream& s) { s.endd(); return s; }
58 
59 #define iFILE __FILE__<<'('<<__LINE__<<"): "
60 #define iINFOF iINFO << iFILE
61 #define iWARNF iWARN << iFILE
62 #define iERRORF iERROR << iFILE
63 #define iDEBUGF iDEBUG << iFILE
64 
65 
66 extern datastream dout;
67 
68 #endif /* DATASTREAM_H */
69 
void endd()
Definition: DataStream.C:18
datastream & endd(datastream &s)
Definition: DataStream.h:57
datastream dout
Definition: DataStream.C:37
Definition: Vector.h:64
datastream & operator<<(datastream &strm, const Vector &v1)
Definition: DataStream.C:25
LOCALMOD(char)
datastream & operator<<(datastream &(*f)(datastream &))
Definition: DataStream.h:28
Definition: Tensor.h:15
datastream & operator<<(std::ostream &(*f)(std::ostream &))
Definition: DataStream.h:26