BOSS
7.0.9
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
14
namespace
{
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
35
const
char
*
const
ExampleIssue::CLASS_NAME
=
"ExampleIssue"
;
36
const
char
*
const
ExampleIssue::PROCRASTINATION_LEVEL_KEY
=
"PROCRASTINATION_LEVEL"
;
37
38
ExampleIssue::ExampleIssue
() :
ers
::Issue() {}
39
40
ExampleIssue::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
50
ExampleIssue::ExampleIssue
(
const
ers::Context
& context,
ers::severity_t
severity,
int
procrastination_level) :
ers
::Issue(context,severity) {
51
set_value
(
PROCRASTINATION_LEVEL_KEY
,
procrastination_level
) ;
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
62
int
ExampleIssue::procrastination_level
()
const
{
63
return
get_int_value
(
PROCRASTINATION_LEVEL_KEY
);
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
73
const
char
*
ExampleIssue::get_class_name
()
const
throw() {
74
return
ExampleIssue::CLASS_NAME
;
75
}
// get_class_name
76
ExampleIssue.h
ExampleIssue
Example issue.
Definition:
ExampleIssue.h:20
ExampleIssue::get_class_name
virtual const char * get_class_name() const
Definition:
ExampleIssue.cxx:73
ExampleIssue::CLASS_NAME
static const char *const CLASS_NAME
Definition:
ExampleIssue.h:25
ExampleIssue::PROCRASTINATION_LEVEL_KEY
static const char *const PROCRASTINATION_LEVEL_KEY
Definition:
ExampleIssue.h:26
ExampleIssue::procrastination_level
int procrastination_level() const
Definition:
ExampleIssue.cxx:62
ExampleIssue::ExampleIssue
ExampleIssue()
Definition:
ExampleIssue.cxx:38
ers::Context
Source context for Issue.
Definition:
Context.h:42
ers::IssueFactory::register_issue
bool register_issue(const std::string &name, CreateIssueCallback creator)
register an issue factory
Definition:
IssueFactory.cxx:47
ers::IssueFactory::instance
static IssueFactory * instance()
method to access singleton
Definition:
IssueFactory.cxx:28
ers::Issue
Root Issue class.
Definition:
ers/ers-00-00-03/ers/Issue.h:40
ers::Issue::set_value
void set_value(const std::string &key, uint8_t value)
Sets a value 8 bit unsigned.
Definition:
ers/ers-00-00-03/src/Issue.cxx:371
ers::Issue::get_int_value
int get_int_value(const std::string &key, int def=0) const
Get a value of the table as an integer.
Definition:
ers/ers-00-00-03/src/Issue.cxx:305
ers::Issue::finish_setup
void finish_setup(const std::string &message)
Finishes the setup of the Issue.
Definition:
ers/ers-00-00-03/src/Issue.cxx:568
ers
Definition:
Event/ers/ers-00-00-03/ers/Assertion.h:20
ers::severity_t
enum ers::_severity_t severity_t
source
Event
ers
ers-00-00-03
test
ExampleIssue.cxx
Generated by
1.9.6