Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_VerboseObject.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
12 
13 
14 namespace Teuchos {
15 
16 
17 // Private static data members
18 
19 
21 {
22  static RCP<FancyOStream> defaultOStream;
23  if (defaultOStream.get()==NULL) {
24  defaultOStream = fancyOStream(rcpFromRef(std::cout));
25  defaultOStream->setOutputToRootOnly(0);
26 // if(GlobalMPISession::getNProc()>1)
27 // defaultOStream->setShowProcRank(true);
28  }
29  return defaultOStream;
30 }
31 
32 
33 // Public static member functions
34 
35 
37  const RCP<FancyOStream> &defaultOStream
38  )
39 {
40  privateDefaultOStream() = defaultOStream;
41 }
42 
43 
46 {
47  return privateDefaultOStream();
48 }
49 
50 // Destructor
51 
53 {
54 }
55 
56 // Constructors/Initializers
57 
58 
60  const RCP<FancyOStream> &oStream
61  )
62  : thisOverridingOStream_(null)
63 {
64  this->initializeVerboseObjectBase(oStream);
65 }
66 
67 
69  const RCP<FancyOStream> &oStream
70  )
71 {
72  thisOStream_ = oStream;
73 }
74 
75 
76 const VerboseObjectBase&
78 {
79  thisOStream_ = oStream;
81  return *this;
82 }
83 
84 
85 const VerboseObjectBase&
87  const RCP<FancyOStream> &oStream
88  ) const
89 {
90  thisOverridingOStream_ = oStream;
92  return *this;
93 }
94 
95 
97 VerboseObjectBase::setLinePrefix(const std::string &linePrefix)
98 {
99  thisLinePrefix_ = linePrefix;
101  return *this;
102 }
103 
104 
105 // Query functions
106 
107 
110 {
112  return thisOverridingOStream_;
113  if(is_null(thisOStream_))
114  return getDefaultOStream();
115  return thisOStream_;
116 }
117 
118 
121 {
122  return thisOverridingOStream_;
123 }
124 
125 
127 {
128  return thisLinePrefix_;
129 }
130 
131 
132 // Utility functions
133 
134 
136  const int tabs,const std::string &linePrefix
137  ) const
138 {
139  return OSTab(
140  this->getOStream(), tabs, linePrefix.length()
141  ? linePrefix : this->getLinePrefix()
142  );
143 }
144 
145 
146 // protected
147 
148 
150 {}
151 
152 
153 } // namespace Teuchos
virtual std::string getLinePrefix() const
Get the line prefix for this object.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
static void setDefaultOStream(const RCP< FancyOStream > &defaultOStream)
Set the default output stream object.
T * get() const
Get the raw C++ pointer to the underlying object.
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object...
basic_OSTab< char > OSTab
virtual VerboseObjectBase & setLinePrefix(const std::string &linePrefix)
Set line prefix name for this object.
virtual const VerboseObjectBase & setOStream(const RCP< FancyOStream > &oStream) const
The output stream for *this object.
VerboseObjectBase(const RCP< FancyOStream > &oStream=Teuchos::null)
Calls initializeVerboseObject().
virtual OSTab getOSTab(const int tabs=1, const std::string &linePrefix="") const
Create a tab object which sets the number of tabs and optionally the line prefix. ...
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
Non-templated base class for objects that can print their activities to a stream. ...
RCP< FancyOStream > thisOverridingOStream_
virtual const VerboseObjectBase & setOverridingOStream(const RCP< FancyOStream > &oStream) const
Set the overriding the output stream for *this object.
static RCP< FancyOStream > & privateDefaultOStream()
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
void initializeVerboseObjectBase(const RCP< FancyOStream > &oStream=Teuchos::null)
Calls initializeVerboseObject().
Smart reference counting pointer class for automatic garbage collection.
virtual RCP< FancyOStream > getOverridingOStream() const
Return the the overriding output stream if set.
virtual RCP< FancyOStream > getOStream() const
Return the output stream to be used for out for *this object.
virtual void informUpdatedVerbosityState() const
Function that is called whenever the verbosity state is updated.