Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_Describable.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_Describable.hpp"
12 
13 
14 namespace Teuchos {
15 
16 
18 
19 
20 std::string Describable::description () const
21 {
22  const std::string objectLabel = this->getObjectLabel ();
23  std::ostringstream oss;
24  if (objectLabel.length ()) {
25  oss << "\"" << objectLabel << "\": ";
26  }
27  oss << typeName (*this);
28  return oss.str ();
29 }
30 
31 void
33  const EVerbosityLevel /* verbLevel */) const
34 {
35  RCP<FancyOStream> out = rcpFromRef (out_arg);
36  OSTab tab (out);
37  *out << this->description () << std::endl;
38 }
39 
40 void
41 Describable::describe (std::ostream& out,
42  const EVerbosityLevel verbLevel) const
43 {
44  RCP<FancyOStream> fancyOut = getFancyOStream (rcpFromRef (out));
45  this->describe (*fancyOut, verbLevel);
46 }
47 
49 
50 } // namespace Teuchos
virtual ~Describable()
Destructor (marked virtual for memory safety of derived classes).
virtual std::string getObjectLabel() const
Get the object label (see LabeledObject).
Generate output as defined by the object.
EVerbosityLevel
Verbosity level.
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object...
std::ostream subclass that performs the magic of indenting data sent to an std::ostream object among ...
virtual std::string description() const
Return a simple one-line description of this object.
static const EVerbosityLevel verbLevel_default
Default value for the verbLevel argument of describe().
Smart reference counting pointer class for automatic garbage collection.
Defines basic traits returning the name of a type in a portable and readable way. ...
virtual void describe(FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
Print the object with some verbosity level to a FancyOStream.
std::string typeName(const T &t)
Template function for returning the concrete type name of a passed-in object.