Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Public Member Functions | Static Public Attributes | List of all members
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. More...
 
int operator() (const JUPI_t &upi)
 Get module identifier. More...
 
JUPI_t operator() (const int id)
 Get UPI. More...
 

Static Public Attributes

static JCLBIDHelper helper
 Helper object. More...
 

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:234
Template definition for getting table specific selector.

◆ 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.
Definition: JException.hh:712
Database exception.
Definition: JException.hh:684
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
void initialise()
Initialise.
Definition: JDBToolkit.hh:184
JUPI_t CLBUPI
Definition: JCLBID.hh:24

◆ 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: