Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

InfoStream.C

Go to the documentation of this file.
00001 
00007 /*
00008    Defines a new stream: iout, for "i"nforming consoles.
00009 */
00010 
00011 #include "InfoStream.h"
00012 #include "charm++.h"
00013 #include "Vector.h"
00014 #include "Tensor.h"
00015 #include <stdio.h>
00016 
00017 infostream::infostream() {}
00018 
00019 infostream::~infostream() {;}
00020 
00021 /* output using CkPrintf() (end by inform) */
00022 void infostream::endi() {
00023   *this << std::ends;
00024   std::string infostr = str();
00025   CkPrintf("%s",infostr.c_str());
00026 #ifndef NAMD_NO_STDOUT_FLUSH
00027   fflush(stdout);  // since CkPrintf doesn't always flush
00028 #endif
00029   str("");
00030 }
00031 
00032 infostream& endi(infostream& s)  { s.endi(); return s; }
00033 
00034 std::ostream& iPE(std::ostream& s) {
00035   return s << "Pe(" << CkMyPe() << ')';
00036 }
00037 
00038 std::ostream& operator<<(std::ostream& strm, const Vector &v1) {
00039        strm << v1.x << " " << v1.y << " " << v1.z;
00040        return strm;
00041 }
00042 
00043 infostream& operator<<(infostream& strm, const Vector &v1) {
00044        strm << v1.x << " " << v1.y << " " << v1.z;
00045        return strm;
00046 }
00047 
00048 
00049 std::ostream& operator<<(std::ostream& strm, const Tensor &t1) {
00050        strm << t1.xx << " " << t1.xy << " " << t1.xz << " "
00051             << t1.yx << " " << t1.yy << " " << t1.yz << " "
00052             << t1.zx << " " << t1.zy << " " << t1.zz;
00053        return strm;
00054 }
00055 
00056 infostream& operator<<(infostream& strm, const Tensor &t1) {
00057        strm << t1.xx << " " << t1.xy << " " << t1.xz << " "
00058             << t1.yx << " " << t1.yy << " " << t1.yz << " "
00059             << t1.zx << " " << t1.zy << " " << t1.zz;
00060        return strm;
00061 }
00062 
00063 /* define how to use the remaining << args */
00065 infostream& infostream::operator<<(std::ostream& (*f)(std::ostream&)) { f(*this); return(*this); }
00067 infostream& infostream::operator<<(infostream& (*f)(infostream&)) { return f(*this); }
00068 
00069 #define LOCALMOD(type) infostream& infostream::operator<<(type x) \
00070                 { (std::ostream&)(*this) << x; return(*this); }
00071 
00072 LOCALMOD(char)
00073 LOCALMOD(unsigned char)
00074 LOCALMOD(const char *)
00076 LOCALMOD(int)
00077 LOCALMOD(long)
00078 LOCALMOD(short)
00079 LOCALMOD(unsigned int)
00080 LOCALMOD(unsigned long)
00081 LOCALMOD(unsigned short)
00083 LOCALMOD(float)
00084 LOCALMOD(double)
00086 LOCALMOD(void *)
00087 LOCALMOD(std::streambuf *)
00088 #undef LOCALMOD
00089 
00094 std::ostream& iINFO (std::ostream& s)  { return s << "Info: "; }
00095 std::ostream& iWARN (std::ostream& s)  { return s << "Warning: "; }
00096 std::ostream& iERROR(std::ostream& s)  { return s << "ERROR: "; }
00097 std::ostream& iDEBUG(std::ostream& s)  { return s << "DEBUG: "; }
00098 
00099 infostream iout;
00100 

Generated on Fri Sep 5 04:07:14 2008 for NAMD by  doxygen 1.3.9.1