Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
JDATABASE::JDetectorsHelper Struct Reference

Auxiliary class for mapping serial number and object identifier of detectors. More...

#include <JDBToolkit.hh>

Inheritance diagram for JDATABASE::JDetectorsHelper:
JLANG::JSingleton< T >

Public Types

typedef T data_type
 

Public Member Functions

int operator() (const std::string &detid) const
 Get detector serial number. More...
 
std::string operator() (const int id) const
 Get detector identifier. More...
 

Static Public Member Functions

static void initialise ()
 Initialise. More...
 
static data_typegetInstance ()
 Get unique instance of template class. More...
 

Protected Attributes

std::map< int, std::string > id2det
 
std::map< std::string, int > det2id
 

Detailed Description

Auxiliary class for mapping serial number and object identifier of detectors.

Definition at line 34 of file JDBToolkit.hh.

Member Typedef Documentation

template<class T>
typedef T JLANG::JSingleton< T >::data_type
inherited

Definition at line 20 of file JSingleton.hh.

Member Function Documentation

static void JDATABASE::JDetectorsHelper::initialise ( )
inlinestatic

Initialise.

Definition at line 40 of file JDBToolkit.hh.

41  {
42  ResultSet& rs = JDB::get()->StreamDS(getTable<JDetectors>(), JSelector());
43 
44  for (JDetectors parameters; rs >> parameters; ) {
45  getInstance().det2id[parameters.OID] = parameters.SERIALNUMBER;
46  getInstance().id2det[parameters.SERIALNUMBER] = parameters.OID;
47  }
48 
49  rs.Close();
50  }
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Auxiliary class for specifying selection of database data.
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27
static JDB & get()
Get connection to database.
Definition: JDB.hh:81
int JDATABASE::JDetectorsHelper::operator() ( const std::string &  detid) const
inline

Get detector serial number.

Parameters
detidobject identifier
Returns
serial number

Definition at line 59 of file JDBToolkit.hh.

60  {
62 
63  if (p == det2id.end()) {
64 
65  ResultSet& rs = JDB::get()->StreamDS(getTable<JDetectors>(), getSelector<JDetectors>(detid));
66 
68 
69  if (rs >> parameters) {
70 
71  rs.Close();
72 
73  det2id[parameters.OID] = parameters.SERIALNUMBER;
74  id2det[parameters.SERIALNUMBER] = parameters.OID;
75 
76  return parameters.SERIALNUMBER;
77  }
78 
79  } else {
80 
81  return p->second;
82  }
83 
84  THROW(JDatabaseException, "Invalid detector identifier " << detid);
85  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
std::map< std::string, int > det2id
Definition: JDBToolkit.hh:124
std::map< int, std::string > id2det
Definition: JDBToolkit.hh:123
Template definition for getting table specific selector.
static JDB & get()
Get connection to database.
Definition: JDB.hh:81
std::string JDATABASE::JDetectorsHelper::operator() ( const int  id) const
inline

Get detector identifier.

Parameters
idserial number
Returns
object identifier

Definition at line 94 of file JDBToolkit.hh.

95  {
97 
98  if (p == id2det.end()) {
99 
100  ResultSet& rs = JDB::get()->StreamDS(getTable<JDetectors>(), getSelector<JDetectors>(id));
101 
103 
104  if (rs >> parameters) {
105 
106  rs.Close();
107 
108  id2det[parameters.SERIALNUMBER] = parameters.OID;
109  det2id[parameters.OID] = parameters.SERIALNUMBER;
110 
111  return parameters.OID;
112  }
113 
114  } else {
115 
116  return p->second;
117  }
118 
119  THROW(JDatabaseException, "Invalid detector identifier " << id);
120  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
std::map< std::string, int > det2id
Definition: JDBToolkit.hh:124
std::map< int, std::string > id2det
Definition: JDBToolkit.hh:123
Template definition for getting table specific selector.
static JDB & get()
Get connection to database.
Definition: JDB.hh:81
template<class T>
static data_type& JLANG::JSingleton< T >::getInstance ( )
inlinestaticinherited

Get unique instance of template class.

Returns
object

Definition at line 27 of file JSingleton.hh.

28  {
29  static data_type value;
30 
31  return value;
32  }

Member Data Documentation

std::map<int, std::string> JDATABASE::JDetectorsHelper::id2det
mutableprotected

Definition at line 123 of file JDBToolkit.hh.

std::map<std::string, int> JDATABASE::JDetectorsHelper::det2id
mutableprotected

Definition at line 124 of file JDBToolkit.hh.


The documentation for this struct was generated from the following file: