CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
RangeIssue.cxx
Go to the documentation of this file.
1/*
2 * RangeIssue.cxx
3 * ers
4 *
5 * Created by Matthias Wiesmann on 15.02.05.
6 * Copyright 2005 CERN. All rights reserved.
7 *
8 */
9
10#include "ers/RangeIssue.h"
11#include <sstream>
12
13
14const char * const ers::RangeIssue::CLASS_NAME = "ers::RangeIssue" ;
15const char * const ers::RangeIssue::INDEX_REFERENCE_TYPE = "scalar" ;
16const char * const ers::RangeIssue::RANGE_MIN_KEY = "REFERENCE_RANGE_MIN" ;
17const char * const ers::RangeIssue::RANGE_MAX_KEY = "REFERENCE_RANGE_MAX" ;
18
19
20namespace {
21 ers::Issue *create_issue() { return new ers::RangeIssue(); }
23} // anonymous context
24
25void ers::RangeIssue::check_range(const ers::Context &c, int64_t min, int64_t value, int64_t max, const char* entity_name) {
26 if ((value>max) || (value<min)) throw RangeIssue(c,ers::error,min,value,max,entity_name);
27} // check_range
28
29
30void ers::RangeIssue::set_range(ers::Issue &issue, int64_t index, int64_t min_index, int64_t max_index, const char* entity_name) {
31 issue.set_value(REFERENCE_VALUE_KEY,index) ;
32 issue.set_value(RANGE_MIN_KEY,min_index);
33 issue.set_value(RANGE_MAX_KEY,max_index);
34 std::ostringstream reference_stream ;
35 reference_stream << INDEX_REFERENCE_TYPE ;
36 if (entity_name) {
37 reference_stream << "(name=" << entity_name << ')' ;
38 }
39 issue.set_value(REFERENCE_TYPE_KEY,reference_stream.str()) ;
40} // set_range
41
43
47
48ers::RangeIssue::RangeIssue(const ers::Context &c, ers::severity_t s, int64_t min_index, int64_t index, int64_t max_index, const char* entity_name) : ers::InvalidReferenceIssue(c,s) {
49 set_range(*this,index,min_index,max_index,entity_name) ;
50 std::ostringstream message_stream ;
51 message_stream << "invalid index: " ;
52 if (entity_name) {
53 message_stream << entity_name << '=';
54 } // entity
55 message_stream << index << " is not in range " << min_index << '-' << max_index ;
56 finish_setup(message_stream.str());
57} // RangeIssue
58
59const char*ers::RangeIssue::get_class_name() const throw() { return CLASS_NAME ; }
60
XmlRpcServer s
Source context for Issue.
Definition Context.h:42
static const char *const REFERENCE_TYPE_KEY
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.
void finish_setup(const std::string &message)
Finishes the setup of the Issue.
static const char *const INDEX_REFERENCE_TYPE
Definition RangeIssue.h:22
static const char *const RANGE_MIN_KEY
Definition RangeIssue.h:23
static void set_range(ers::Issue &issue, int64_t index, int64_t min_index, int64_t max_index, const char *entity_name=0)
static const char *const CLASS_NAME
Definition RangeIssue.h:21
static const char *const RANGE_MAX_KEY
Definition RangeIssue.h:24
virtual const char * get_class_name() const
Get key for class (used for serialisation)
static void check_range(const ers::Context &c, int64_t min, int64_t value, int64_t max, const char *entity_name=0)
@ error
Definition Core.h:24
enum ers::_severity_t severity_t