Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Teuchos_VerboseObject.cpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Teuchos: Common Tools Package
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
44
45
46namespace Teuchos {
47
48
49// Private static data members
50
51
53{
54 static RCP<FancyOStream> defaultOStream;
55 if (defaultOStream.get()==NULL) {
56 defaultOStream = fancyOStream(rcpFromRef(std::cout));
57 defaultOStream->setOutputToRootOnly(0);
58// if(GlobalMPISession::getNProc()>1)
59// defaultOStream->setShowProcRank(true);
60 }
61 return defaultOStream;
62}
63
64
65// Public static member functions
66
67
69 const RCP<FancyOStream> &defaultOStream
70 )
71{
72 privateDefaultOStream() = defaultOStream;
73}
74
75
78{
79 return privateDefaultOStream();
80}
81
82// Destructor
83
85{
86}
87
88// Constructors/Initializers
89
90
92 const RCP<FancyOStream> &oStream
93 )
94 : thisOverridingOStream_(null)
95{
96 this->initializeVerboseObjectBase(oStream);
97}
98
99
101 const RCP<FancyOStream> &oStream
102 )
103{
104 thisOStream_ = oStream;
105}
106
107
110{
111 thisOStream_ = oStream;
113 return *this;
114}
115
116
119 const RCP<FancyOStream> &oStream
120 ) const
121{
122 thisOverridingOStream_ = oStream;
124 return *this;
125}
126
127
129VerboseObjectBase::setLinePrefix(const std::string &linePrefix)
130{
131 thisLinePrefix_ = linePrefix;
133 return *this;
134}
135
136
137// Query functions
138
139
142{
146 return getDefaultOStream();
147 return thisOStream_;
148}
149
150
153{
155}
156
157
159{
160 return thisLinePrefix_;
161}
162
163
164// Utility functions
165
166
168 const int tabs,const std::string &linePrefix
169 ) const
170{
171 return OSTab(
172 this->getOStream(), tabs, linePrefix.length()
173 ? linePrefix : this->getLinePrefix()
174 );
175}
176
177
178// protected
179
180
182{}
183
184
185} // 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.
T * get() const
Get the raw C++ pointer to the underlying object.
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.
RCP< FancyOStream > thisOverridingOStream_
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.
static RCP< FancyOStream > & privateDefaultOStream()
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