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 CkpvExtern(infostream, iout_obj);
00018 
00019 infostream& infostream::access_iout_obj() {
00020   return CkpvAccess(iout_obj);
00021 }
00022 
00023 infostream::infostream() {}
00024 
00025 infostream::~infostream() {;}
00026 
00027 /* output using CkPrintf() (end by inform) */
00028 void infostream::endi() {
00029   *this << std::ends;
00030   std::string infostr = str();
00031   CkPrintf("%s",infostr.c_str());
00032 #ifndef NAMD_NO_STDOUT_FLUSH
00033   fflush(stdout);  // since CkPrintf doesn't always flush
00034 #endif
00035   str("");
00036 }
00037 
00038 infostream& endi(infostream& s)  { s.endi(); return s; }
00039 
00040 std::ostream& iPE(std::ostream& s) {
00041   return s << "Pe(" << CkMyPe() << ')';
00042 }
00043 
00044 std::ostream& operator<<(std::ostream& strm, const Vector &v1) {
00045        strm << v1.x << " " << v1.y << " " << v1.z;
00046        return strm;
00047 }
00048 
00049 infostream& operator<<(infostream& strm, const Vector &v1) {
00050        strm << v1.x << " " << v1.y << " " << v1.z;
00051        return strm;
00052 }
00053 
00054 
00055 std::ostream& operator<<(std::ostream& strm, const Tensor &t1) {
00056        strm << t1.xx << " " << t1.xy << " " << t1.xz << " "
00057             << t1.yx << " " << t1.yy << " " << t1.yz << " "
00058             << t1.zx << " " << t1.zy << " " << t1.zz;
00059        return strm;
00060 }
00061 
00062 infostream& operator<<(infostream& strm, const Tensor &t1) {
00063        strm << t1.xx << " " << t1.xy << " " << t1.xz << " "
00064             << t1.yx << " " << t1.yy << " " << t1.yz << " "
00065             << t1.zx << " " << t1.zy << " " << t1.zz;
00066        return strm;
00067 }
00068 
00069 /* define how to use the remaining << args */
00071 infostream& infostream::operator<<(std::ostream& (*f)(std::ostream&)) { f(*this); return(*this); }
00073 infostream& infostream::operator<<(infostream& (*f)(infostream&)) { return f(*this); }
00074 
00075 #define LOCALMOD(type) infostream& infostream::operator<<(type x) \
00076                 { (std::ostream&)(*this) << x; return(*this); }
00077 
00078 LOCALMOD(char)
00079 LOCALMOD(unsigned char)
00080 LOCALMOD(const char *)
00082 LOCALMOD(int)
00083 LOCALMOD(long)
00084 LOCALMOD(short)
00085 LOCALMOD(unsigned int)
00086 LOCALMOD(unsigned long)
00087 LOCALMOD(unsigned short)
00088 #ifdef _MSC_VER
00089 LOCALMOD(__int64)
00090 LOCALMOD(unsigned __int64)
00091 #else
00092 LOCALMOD(long long);
00093 LOCALMOD(unsigned long long);
00094 #endif
00095 
00096 LOCALMOD(float)
00097 LOCALMOD(double)
00099 LOCALMOD(void *)
00100 LOCALMOD(std::streambuf *)
00101 #undef LOCALMOD
00102 
00107 std::ostream& iINFO (std::ostream& s)  { return s << "Info: "; }
00108 std::ostream& iWARN (std::ostream& s)  { return s << "Warning: "; }
00109 std::ostream& iERROR(std::ostream& s)  { return s << "ERROR: "; }
00110 std::ostream& iDEBUG(std::ostream& s)  { return s << "DEBUG: "; }
00111 
00112 

Generated on Sat Nov 18 01:17:14 2017 for NAMD by  doxygen 1.4.7