Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDATABASE::JCLBIDHelper Struct Reference

Auxiliary class for mapping UPI of central-logic board to module identifier. More...

#include <JDBToolkit.hh>

Inheritance diagram for JDATABASE::JCLBIDHelper:
std::vector< JCLBID >

Public Member Functions

void initialise ()
 Initialise.
 
int operator() (const JUPI_t &upi)
 Get module identifier.
 
JUPI_t operator() (const int id)
 Get UPI.
 

Static Public Attributes

static JCLBIDHelper helper
 Helper object.
 

Detailed Description

Auxiliary class for mapping UPI of central-logic board to module identifier.

Definition at line 178 of file JDBToolkit.hh.

Member Function Documentation

◆ initialise()

void JDATABASE::JCLBIDHelper::initialise ( )
inline

Initialise.

Definition at line 184 of file JDBToolkit.hh.

185 {
186 ResultSet& rs = JDB::get()->StreamDS(getTable<JCLBID>(), getSelector<JCLBID>());
187
188 for (JCLBID parameters; rs >> parameters; ) {
189 this->push_back(parameters);
190 }
191
192 rs.Close();
193 }
static JDB & get()
Get connection to database.
Definition JDB.hh:235
const char * getTable()
Get table name.
Definition JDB.hh:373

◆ operator()() [1/2]

int JDATABASE::JCLBIDHelper::operator() ( const JUPI_t & upi)
inline

Get module identifier.

Parameters
upiUPI
Returns
module identifier

Definition at line 202 of file JDBToolkit.hh.

203 {
204 using namespace std;
205 using namespace JPP;
206
207 if (this->empty()) {
208 this->initialise();
209 }
210
211 const_iterator p = find_if(this->begin(), this->end(), make_predicate(&JCLBID::CLBUPI, upi));
212
213 if (p != this->end())
214 return p->CLBID;
215 else
216 THROW(JDatabaseException, "Invalid UPI " << upi);
217 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Database exception.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void initialise()
Initialise.

◆ operator()() [2/2]

JUPI_t JDATABASE::JCLBIDHelper::operator() ( const int id)
inline

Get UPI.

Parameters
idmodule identifier
Returns
UPI

Definition at line 226 of file JDBToolkit.hh.

227 {
228 using namespace std;
229 using namespace JPP;
230
231 if (this->empty()) {
232 this->initialise();
233 }
234
235 const_iterator p = find_if(this->begin(), this->end(), make_predicate(&JCLBID::CLBID, id));
236
237 if (p != this->end())
238 return p->CLBUPI;
239 else
240 THROW(JDatabaseException, "Invalid module identifier " << id);
241 }

Member Data Documentation

◆ helper

JCLBIDHelper JDATABASE::JCLBIDHelper::helper
static

Helper object.

Definition at line 247 of file JDBToolkit.hh.


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