BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
ExampleIssue.cxx
Go to the documentation of this file.
1/*
2 * ExampleIssue.cxx
3 * Test
4 *
5 * Created by Matthias Wiesmann on 24.01.05.
6 * Copyright 2005 CERN. All rights reserved.
7 *
8 */
9
10#include "ExampleIssue.h"
11#include <iostream>
12#include <sstream>
13
14namespace {
15 /// This block of code is only needed if issues of this type will need to be deserialised
16 /// outside of the process where it is first created. For instance if the Issue is created in
17 /// one process, streamed to a file and read again from this file. If the following function
18 /// is not defined and registered, when an Issue is deserialised, it will have a special
19 /// type, \c DefaultIssue all the information inside the issue will be intact, but custom
20 /// method will not be available.
21 /// \return
22
23 ers::Issue* create_example_issue() {
24 ers::Issue* i = new ExampleIssue();
25 return i;
26 } // create_issue
27
28 /// We register the factory function with the IssueFactory singleton, this should only be
29 /// done if a create_issue function is defined for the Issue.
30
32 create_example_issue );
33} // anonymous namespace
34
35const char* const ExampleIssue::CLASS_NAME = "ExampleIssue";
36const char* const ExampleIssue::PROCRASTINATION_LEVEL_KEY = "PROCRASTINATION_LEVEL";
37
39
42
43/** User constructor, this constructor should be used by the user.
44 * The prototype includes the two mandatory parameters, context and severity
45 * plus whatever custome construction parameters are needed.
46 * \param context object representing the code-context where the issue originated, normally,
47 * this is the macro ERS_HERE \param severity the severity of the issue \param
48 * procrastination_level this is a custom parameter needed by this example issue
49 */
50
53 : ers::Issue( context, severity ) {
55 std::ostringstream msg_str;
56 msg_str << "Procrastinating at level " << procrastination_level;
57 finish_setup( msg_str.str() );
58} // ExampleIssue
59
60/** This method is an example of an accessor for a custom property in the issue
61 * It basically searches the value table for the right property and returns it.
62 * \return the value of the procrastination property
63 */
64
67} // procrastination_level
68
69/// This function returns the name of the Issue, this name should be the same as
70/// the unmangled class name. Here we given back the string defined in ExampleIssue::CLASS_NAME
71/// \note If this function is not defined, the implementation
72/// the Issue root object tries to build a meaningfull name out of RTTI information,
73/// but depending on the compiler this is unreliable.
74/// \return name of the class
75
76const char* ExampleIssue::get_class_name() const throw() {
78} // get_class_name
Example issue.
virtual const char * get_class_name() const
static const char *const CLASS_NAME
static const char *const PROCRASTINATION_LEVEL_KEY
int procrastination_level() const
Source context for Issue.
bool register_issue(const std::string &name, CreateIssueCallback creator)
register an issue factory
static IssueFactory * instance()
method to access singleton
Root Issue class.
void set_value(const std::string &key, uint8_t value)
Sets a value 8 bit unsigned.
severity_t severity() const
severity_t of the issue
int get_int_value(const std::string &key, int def=0) const
Get a value of the table as an integer.
void finish_setup(const std::string &message)
Finishes the setup of the Issue.
Issue(const Context &context, severity_t s)
Constructor for subclasses.
enum ers::_severity_t severity_t