BOSS 7.0.5
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 <iostream>
11#include <sstream>
12#include "ExampleIssue.h"
13
14namespace {
15 /// This block of code is only needed if issues of this type will need to be deserialised outside
16 /// of the process where it is first created. For instance if the Issue is created in one process,
17 /// streamed to a file and read again from this file.
18 /// If the following function is not defined and registered, when an Issue is deserialised, it will
19 /// have a special 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 done if
29 /// a create_issue function is defined for the Issue.
30
31 bool registered = ers::IssueFactory::instance()->register_issue(ExampleIssue::CLASS_NAME,create_example_issue) ;
32} // anonymous namespace
33
34
35const char * const ExampleIssue::CLASS_NAME = "ExampleIssue" ;
36const char * const ExampleIssue::PROCRASTINATION_LEVEL_KEY = "PROCRASTINATION_LEVEL" ;
37
39
40ExampleIssue::ExampleIssue(const ers::Context& context, ers::severity_t severity) : ers::Issue(context,severity) {}
41
42/** User constructor, this constructor should be used by the user.
43 * The prototype includes the two mandatory parameters, context and severity
44 * plus whatever custome construction parameters are needed.
45 * \param context object representing the code-context where the issue originated, normally, this is the macro ERS_HERE
46 * \param severity the severity of the issue
47 * \param procrastination_level this is a custom parameter needed by this example issue
48 */
49
50ExampleIssue::ExampleIssue(const ers::Context& context, ers::severity_t severity, int procrastination_level) : ers::Issue(context,severity) {
52 std::ostringstream msg_str ;
53 msg_str << "Procrastinating at level " << procrastination_level ;
54 finish_setup(msg_str.str());
55} // ExampleIssue
56
57/** This method is an example of an accessor for a custom property in the issue
58 * It basically searches the value table for the right property and returns it.
59 * \return the value of the procrastination property
60 */
61
64} // procrastination_level
65
66/// This function returns the name of the Issue, this name should be the same as
67/// the unmangled class name. Here we given back the string defined in ExampleIssue::CLASS_NAME
68/// \note If this function is not defined, the implementation
69/// the Issue root object tries to build a meaningfull name out of RTTI information,
70/// but depending on the compiler this is unreliable.
71/// \return name of the class
72
73const char *ExampleIssue::get_class_name() const throw() {
75} // get_class_name
76
Example issue.
Definition: ExampleIssue.h:20
virtual const char * get_class_name() const
static const char *const CLASS_NAME
Definition: ExampleIssue.h:25
static const char *const PROCRASTINATION_LEVEL_KEY
Definition: ExampleIssue.h:26
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
void set_value(const std::string &key, uint8_t value)
Sets a value 8 bit unsigned.
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.
enum ers::_severity_t severity_t