Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
Teuchos_Describable.hpp
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
#ifndef TEUCHOS_DESCRIBABLE_HPP
11
#define TEUCHOS_DESCRIBABLE_HPP
12
13
#include "
Teuchos_VerbosityLevel.hpp
"
14
#include "Teuchos_FancyOStream.hpp"
15
#include "Teuchos_LabeledObject.hpp"
16
17
18
namespace
Teuchos
{
19
20
44
class
TEUCHOSCORE_LIB_DLL_EXPORT
Describable
:
virtual
public
LabeledObject
{
45
public
:
47
static
const
EVerbosityLevel
verbLevel_default
;
48
50
51
63
virtual
std::string
description
()
const
;
64
116
virtual
void
117
describe
(
FancyOStream
&out,
118
const
EVerbosityLevel
verbLevel =
verbLevel_default
)
const
;
119
130
void
131
describe
(std::ostream &out,
132
const
EVerbosityLevel
verbLevel =
verbLevel_default
)
const
;
133
135
virtual
~Describable
();
136
};
137
138
139
// Describable stream manipulator state class
140
//
141
// This is not a class that a user needs to see and that is why it is not
142
// being given doxygen documentation!
143
struct
DescribableStreamManipulatorState {
144
const
Describable
&describable;
145
const
EVerbosityLevel
verbLevel;
146
DescribableStreamManipulatorState(
147
const
Describable
&_describable,
148
const
EVerbosityLevel
_verbLevel =
VERB_MEDIUM
149
)
150
:describable(_describable)
151
,verbLevel(_verbLevel)
152
{}
153
};
154
155
177
inline
DescribableStreamManipulatorState
describe
(
178
const
Describable
&describable,
179
const
EVerbosityLevel
verbLevel =
Describable::verbLevel_default
180
)
181
{
182
return
DescribableStreamManipulatorState(describable,verbLevel);
183
}
184
185
212
inline
213
std::ostream&
operator<<
(
214
std::ostream& os,
const
DescribableStreamManipulatorState& d
215
)
216
{
217
d.describable.
describe
(*
getFancyOStream
(
Teuchos::rcp
(&os,
false
)),d.verbLevel);
218
return
os;
219
}
220
221
//
222
// RAB: Note: The above function works with an std::ostream object even
223
// through Describable::describe(...) requires a FancyOStream object. We must
224
// write the stream manipulator in terms of std::ostream, or compound output
225
// statements like:
226
//
227
// void foo( FancyOStream &out, Describable &d, EVerbLevel verbLevel )
228
// {
229
// out << "\nThis is the describable object d:" << describe(d,verbLevel);
230
// }
231
//
232
// will not work correctly. The problem is that the first output
233
//
234
// out << "\nThis is the describable object d:"
235
//
236
// must return a reference to an std::ostream object. This should mean that
237
// the next statement, which is basically:
238
//
239
// static_cast<std::ostream&>(out) << DescribableStreamManipulatorState
240
//
241
// should not even compile. However, under gcc 3.4.3, the code did compile
242
// but did not call the above function. Instead, it set up some type of
243
// infinite recursion that resulted in a segfault due to the presence of the
244
// Teuchos::any class!
245
//
246
247
248
}
// namespace Teuchos
249
250
#endif
// TEUCHOS_DESCRIBABLE_HPP
Teuchos_VerbosityLevel.hpp
Teuchos::Describable
Base class for all objects that can describe themselves.
Definition
Teuchos_Describable.hpp:44
Teuchos::Describable::verbLevel_default
static const EVerbosityLevel verbLevel_default
Default value for the verbLevel argument of describe().
Definition
Teuchos_Describable.hpp:47
Teuchos::Describable::operator<<
std::ostream & operator<<(std::ostream &os, const DescribableStreamManipulatorState &d)
Output stream operator for Describable manipulator.
Definition
Teuchos_Describable.hpp:213
Teuchos::Describable::describe
DescribableStreamManipulatorState describe(const Describable &describable, const EVerbosityLevel verbLevel=Describable::verbLevel_default)
Describable output stream manipulator.
Definition
Teuchos_Describable.hpp:177
Teuchos::Describable::describe
virtual void describe(FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
Print the object with some verbosity level to a FancyOStream.
Definition
Teuchos_Describable.cpp:32
Teuchos::Describable::description
virtual std::string description() const
Return a simple one-line description of this object.
Definition
Teuchos_Describable.cpp:20
Teuchos::LabeledObject::LabeledObject
LabeledObject()
Construct with an empty label.
Definition
Teuchos_LabeledObject.cpp:16
Teuchos::basic_FancyOStream::getFancyOStream
RCP< basic_FancyOStream< char > > getFancyOStream(const RCP< std::basic_ostream< char > > &out)
Get a FancyOStream from an std::ostream object.
Definition
Teuchos_FancyOStream.hpp:597
Teuchos::FancyOStream
basic_FancyOStream< char > FancyOStream
Definition
Teuchos_FancyOStream.hpp:813
Teuchos::EVerbosityLevel
EVerbosityLevel
Verbosity level.
Definition
Teuchos_VerbosityLevel.hpp:31
Teuchos::VERB_MEDIUM
@ VERB_MEDIUM
Generate more output.
Definition
Teuchos_VerbosityLevel.hpp:35
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Definition
Teuchos_RCPDecl.hpp:1234
Generated by
1.17.0