Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_VerboseObject.cpp
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
10#include "Teuchos_VerboseObject.hpp"
12
13
14namespace Teuchos {
15
16
17// Private static data members
18
19
20RCP<FancyOStream>& VerboseObjectBase::privateDefaultOStream()
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
38 )
39{
40 privateDefaultOStream() = defaultOStream;
41}
42
43
46{
47 return privateDefaultOStream();
48}
49
50// Destructor
51
55
56// Constructors/Initializers
57
58
61 )
62 : thisOverridingOStream_(null)
63{
64 this->initializeVerboseObjectBase(oStream);
65}
66
67
74
75
78{
79 thisOStream_ = oStream;
81 return *this;
82}
83
84
88 ) const
89{
90 thisOverridingOStream_ = oStream;
92 return *this;
93}
94
95
98{
99 thisLinePrefix_ = linePrefix;
101 return *this;
102}
103
104
105// Query functions
106
107
110{
111 if(!is_null(thisOverridingOStream_))
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
151
152
153} // namespace Teuchos
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Smart reference counting pointer class for automatic garbage collection.
Non-templated base class for objects that can print their activities to a stream.
virtual RCP< FancyOStream > getOStream() const
Return the output stream to be used for out for *this object.
void initializeVerboseObjectBase(const RCP< FancyOStream > &oStream=Teuchos::null)
Calls initializeVerboseObject().
VerboseObjectBase(const RCP< FancyOStream > &oStream=Teuchos::null)
Calls initializeVerboseObject().
virtual std::string getLinePrefix() const
Get the line prefix for this object.
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.
virtual void informUpdatedVerbosityState() const
Function that is called whenever the verbosity state is updated.
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.
static void setDefaultOStream(const RCP< FancyOStream > &defaultOStream)
Set the default output stream object.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
virtual RCP< FancyOStream > getOverridingOStream() const
Return the the overriding output stream if set.
virtual const VerboseObjectBase & setOverridingOStream(const RCP< FancyOStream > &oStream) const
Set the overriding the output stream for *this object.
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
basic_OSTab< char > OSTab
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...