00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "Teuchos_VerboseObject.hpp"
00030 #include "Teuchos_GlobalMPISession.hpp"
00031
00032 namespace Teuchos {
00033
00034
00035
00036 RefCountPtr<FancyOStream>& VerboseObjectBase::privateDefaultOStream()
00037 {
00038 static RefCountPtr<FancyOStream> defaultOStream;
00039 if(defaultOStream.get()==NULL) {
00040 defaultOStream = rcp(new FancyOStream(rcp(&std::cout,false)));
00041 defaultOStream->setOutputToRootOnly(0);
00042
00043
00044 }
00045 return defaultOStream;
00046 }
00047
00048
00049
00050 void VerboseObjectBase::setDefaultOStream( const RefCountPtr<FancyOStream> &defaultOStream )
00051 {
00052 privateDefaultOStream() = defaultOStream;
00053 }
00054
00055 RefCountPtr<FancyOStream>
00056 VerboseObjectBase::getDefaultOStream()
00057 {
00058 return privateDefaultOStream();
00059 }
00060
00061
00062
00063 VerboseObjectBase::VerboseObjectBase(
00064 const RefCountPtr<FancyOStream> &oStream
00065 )
00066 {
00067 this->initializeVerboseObjectBase(oStream);
00068 }
00069
00070 void VerboseObjectBase::initializeVerboseObjectBase(
00071 const RefCountPtr<FancyOStream> &oStream
00072 )
00073 {
00074 thisOStream_ = oStream;
00075 }
00076
00077 const VerboseObjectBase& VerboseObjectBase::setOStream(const RefCountPtr<FancyOStream> &oStream) const
00078 {
00079 thisOStream_ = oStream;
00080 return *this;
00081 }
00082
00083 VerboseObjectBase& VerboseObjectBase::setLinePrefix(const std::string &linePrefix)
00084 {
00085 thisLinePrefix_ = linePrefix;
00086 return *this;
00087 }
00088
00089
00090
00091 RefCountPtr<FancyOStream>
00092 VerboseObjectBase::getOStream() const
00093 {
00094 if(!thisOStream_.get())
00095 return getDefaultOStream();
00096 return thisOStream_;
00097 }
00098
00099 std::string VerboseObjectBase::getLinePrefix() const
00100 {
00101 return thisLinePrefix_;
00102 }
00103
00104
00105
00106 OSTab VerboseObjectBase::getOSTab(const int tabs,const std::string &linePrefix) const
00107 {
00108 return OSTab( this->getOStream(), tabs, linePrefix.length() ? linePrefix : this->getLinePrefix() );
00109 }
00110
00111 }