BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
ers::HumanStream Class Reference

Single line, human readable format stream. More...

#include <HumanStream.h>

Inheritance diagram for ers::HumanStream:

Public Member Functions

 HumanStream ()
 HumanStream (const HumanStream &other)
 ~HumanStream ()
std::string to_string ()
void clear ()
virtual void send (const Issue *ptr)
 Sends an issue into the stream.
virtual void print_to (std::ostream &stream) const
 HumanStream ()
 HumanStream (const HumanStream &other)
 ~HumanStream ()
std::string to_string ()
void clear ()
virtual void send (const Issue *ptr)
 Sends an issue into the stream.
virtual void print_to (std::ostream &stream) const
 HumanStream ()
 HumanStream (const HumanStream &other)
 ~HumanStream ()
std::string to_string ()
void clear ()
virtual void send (const Issue *ptr)
 Sends an issue into the stream.
virtual void print_to (std::ostream &stream) const
Public Member Functions inherited from ers::Stream
 Stream ()
 Stream (const Stream &other)
 operator std::string () const
virtual ~Stream ()
virtual Issuereceive ()
 Receives an issue from the stream.
 Stream ()
 Stream (const Stream &other)
 operator std::string () const
virtual ~Stream ()
virtual Issuereceive ()
 Receives an issue from the stream.
 Stream ()
 Stream (const Stream &other)
 operator std::string () const
virtual ~Stream ()
virtual Issuereceive ()
 Receives an issue from the stream.

Static Public Member Functions

static std::string to_string (const Issue *issue) throw ()
static std::string to_string (const Issue *issue) throw ()
static std::string to_string (const Issue *issue) throw ()

Static Public Attributes

static const char *const KEY = "human"
Static Public Attributes inherited from ers::Stream
static const char *const NULL_STREAM_KEY = "null"

Protected Attributes

std::ostringstream m_out_stream

Detailed Description

Single line, human readable format stream.

This class streams an issue into an human readable string. It is uses by the issue class to display itself. This stream can be specified for other uses, but the user is then responsible for reading data from the stream and clearing it.

Author
Matthias Wiesmann
Version
1.0

Definition at line 26 of file Event/ers/include/ers/HumanStream.h.

Constructor & Destructor Documentation

◆ HumanStream() [1/6]

ers::HumanStream::HumanStream ( )

Definition at line 46 of file HumanStream.cxx.

46: ers::Stream() {} // HumanStream

Referenced by HumanStream(), and to_string().

◆ HumanStream() [2/6]

ers::HumanStream::HumanStream ( const HumanStream & other)

Definition at line 47 of file HumanStream.cxx.

47: ers::Stream( other ) {}

◆ ~HumanStream() [1/3]

ers::HumanStream::~HumanStream ( )

Definition at line 48 of file HumanStream.cxx.

48{}

◆ HumanStream() [3/6]

ers::HumanStream::HumanStream ( )

◆ HumanStream() [4/6]

ers::HumanStream::HumanStream ( const HumanStream & other)

◆ ~HumanStream() [2/3]

ers::HumanStream::~HumanStream ( )

◆ HumanStream() [5/6]

ers::HumanStream::HumanStream ( )

◆ HumanStream() [6/6]

ers::HumanStream::HumanStream ( const HumanStream & other)

◆ ~HumanStream() [3/3]

ers::HumanStream::~HumanStream ( )

Member Function Documentation

◆ clear() [1/3]

void ers::HumanStream::clear ( )

Clears the content of the stream

Definition at line 58 of file HumanStream.cxx.

58{ m_out_stream.str( "" ); } // clear

◆ clear() [2/3]

void ers::HumanStream::clear ( )

◆ clear() [3/3]

void ers::HumanStream::clear ( )

◆ print_to() [1/3]

void ers::HumanStream::print_to ( std::ostream & stream) const
virtual

Reimplemented from ers::Stream.

Definition at line 60 of file HumanStream.cxx.

60 {
61 stream << ers::HumanStream::KEY << ':';
62} // print_to

◆ print_to() [2/3]

virtual void ers::HumanStream::print_to ( std::ostream & stream) const
virtual

Reimplemented from ers::Stream.

◆ print_to() [3/3]

virtual void ers::HumanStream::print_to ( std::ostream & stream) const
virtual

Reimplemented from ers::Stream.

◆ send() [1/3]

void ers::HumanStream::send ( const Issue * i)
virtual

Sends an issue into the stream.

Sends the issue to the stream.

Parameters
ithe issue to send
Note
This implementation silently discards the Issue

Reimplemented from ers::Stream.

Definition at line 64 of file HumanStream.cxx.

64 {
65 ERS_PRE_CHECK_PTR( issue_ptr );
66 if ( m_out_stream )
67 {
68 try
69 {
70 const string_map_type* table = issue_ptr->get_value_table();
71 const std::string message_str = issue_ptr->get_value( Issue::MESSAGE_KEY );
72 const std::string severity_str = issue_ptr->get_value( Issue::SEVERITY_KEY );
73 m_out_stream << "issue: " << message_str << "(" << severity_str << ")[";
74 bool first = true;
75 for ( string_map_type::const_iterator pos = table->begin(); pos != table->end(); ++pos )
76 {
77 const std::string& key = pos->first;
78 const std::string& value = pos->second;
79 if ( first ) { first = false; }
80 else { m_out_stream << ", "; } // first or not
81 m_out_stream << key << "=\"" << value << '\"';
82 } // for
83 m_out_stream << "]";
84 } catch ( std::ios_base::failure& ex )
85 { throw ers::Issue( ERS_HERE, ers::error, &ex ); } // catch generic I/O errors
86 } // if m_out_stream
87} // send
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition Taupair.h:42
static const char *const SEVERITY_KEY
key for the severity_t of the issue
static const char *const MESSAGE_KEY
key for human readable
Index first(Pair i)
std::map< std::string, std::string > string_map_type

Referenced by to_string().

◆ send() [2/3]

virtual void ers::HumanStream::send ( const Issue * i)
virtual

Sends an issue into the stream.

Sends the issue to the stream.

Parameters
ithe issue to send
Note
This implementation silently discards the Issue

Reimplemented from ers::Stream.

◆ send() [3/3]

virtual void ers::HumanStream::send ( const Issue * i)
virtual

Sends an issue into the stream.

Sends the issue to the stream.

Parameters
ithe issue to send
Note
This implementation silently discards the Issue

Reimplemented from ers::Stream.

◆ to_string() [1/6]

std::string ers::HumanStream::to_string ( )
Returns
the content of the stream as a string

Definition at line 53 of file HumanStream.cxx.

53{ return m_out_stream.str(); } // to_string

◆ to_string() [2/6]

std::string ers::HumanStream::to_string ( )

◆ to_string() [3/6]

std::string ers::HumanStream::to_string ( )

◆ to_string() [4/6]

std::string ers::HumanStream::to_string ( const Issue * issue_ptr)
throw ( )
static

Dumps the content of an issue into a string This class is used internally by the Issue class to produce then description field.

Parameters
issue_ptrthe Issue to serialise
Returns
string description

Definition at line 32 of file HumanStream.cxx.

32 {
33 try
34 {
35 HumanStream ers_stream;
36 ers_stream.send( issue_ptr );
37 std::string str = ers_stream.to_string();
38 return str;
39 } catch ( std::exception& ex )
40 {
41 std::string msg = "error while building message " + std::string( ex.what() );
42 return msg;
43 } //
44} // to_string

Referenced by to_string().

◆ to_string() [5/6]

std::string ers::HumanStream::to_string ( const Issue * issue)
throw ( )
static

◆ to_string() [6/6]

std::string ers::HumanStream::to_string ( const Issue * issue)
throw ( )
static

Member Data Documentation

◆ KEY

const char *const ers::HumanStream::KEY = "human"
static

Definition at line 32 of file Event/ers/include/ers/HumanStream.h.

Referenced by print_to(), and to_string().

◆ m_out_stream

std::ostringstream ers::HumanStream::m_out_stream
protected

Definition at line 28 of file Event/ers/include/ers/HumanStream.h.

Referenced by clear(), send(), and to_string().


The documentation for this class was generated from the following files: