BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
HumanStream.cxx
Go to the documentation of this file.
1/*
2 * HumanStream.cxx
3 * ers
4 *
5 * Created by Matthias Wiesmann on 01.12.04.
6 * Copyright 2004 CERN. All rights reserved.
7 *
8 */
9
10#include "ers/HumanStream.h"
11#include "ers/ers.h"
12#include <assert.h>
13
14const char* const ers::HumanStream::KEY = "human";
15
16namespace {
17 ers::Stream* create_stream( const std::string& protocol, const std::string& uri ) {
18 (void)uri;
19 if ( protocol == ers::HumanStream::KEY ) { return new ers::HumanStream(); }
20 return 0;
21 } //
22 bool registered =
24} // anonymous namespace
25
26/** Dumps the content of an issue into a string
27 * This class is used internally by the Issue class to produce then description field.
28 * \param issue_ptr the Issue to serialise
29 * \return string description
30 */
31
32std::string ers::HumanStream::to_string( const Issue* issue_ptr ) throw() {
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
45
49
50/** \return the content of the stream as a string
51 */
52
53std::string ers::HumanStream::to_string() { return m_out_stream.str(); } // to_string
54
55/** Clears the content of the stream
56 */
57
58void ers::HumanStream::clear() { m_out_stream.str( "" ); } // clear
59
60void ers::HumanStream::print_to( std::ostream& stream ) const {
61 stream << ers::HumanStream::KEY << ':';
62} // print_to
63
64void ers::HumanStream::send( const Issue* issue_ptr ) {
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
Single line, human readable format stream.
virtual void send(const Issue *ptr)
Sends an issue into the stream.
std::string to_string()
virtual void print_to(std::ostream &stream) const
static std::string to_string(const Issue *issue)
Root Issue class.
const std::string & get_value(const std::string &key, const std::string &def) const
Reads the property list.
static const char *const SEVERITY_KEY
key for the severity_t of the issue
const string_map_type * get_value_table() const
extract value table
static const char *const MESSAGE_KEY
key for human readable
bool register_factory(const std::string &name, create_stream_callback callback)
register a factory method
static StreamFactory * instance()
return the singleton
Root/Null issue stream.
std::map< std::string, std::string > string_map_type