Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
Public Member Functions | Static Public Attributes | List of all members
JDATABASE::JUPIHelper Struct Reference

Auxiliary class for mapping PBS and serial number of product to UPI. More...

#include <JDBToolkit.hh>

Inheritance diagram for JDATABASE::JUPIHelper:
std::map< JPBS_t, std::map< int, JUPI_t > >

Public Member Functions

void initialise (const JPBS_t &pbs)
 Initialise. More...
 
JUPI_t operator() (const JPBS_t &pbs, const int number)
 Get UPI. More...
 

Static Public Attributes

static JUPIHelper helper
 Helper object. More...
 

Detailed Description

Auxiliary class for mapping PBS and serial number of product to UPI.

Definition at line 254 of file JDBToolkit.hh.

Member Function Documentation

◆ initialise()

void JDATABASE::JUPIHelper::initialise ( const JPBS_t pbs)
inline

Initialise.

Parameters
pbsPBS

Definition at line 262 of file JDBToolkit.hh.

263  {
264  ResultSet& rs = JDB::get()->StreamDS(getTable<JUPI>(), getSelector<JUPI>(pbs));
265 
266  for (JUPI parameters; rs >> parameters; ) {
267 
268  const JUPI_t upi(parameters.PBS,
269  parameters.VARIANT,
270  parameters.VERSION,
271  parameters.SERIALNUMBER);
272 
273  (*this)[pbs][parameters.SERIALNUMBER] = upi;
274  }
275 
276  rs.Close();
277  }
static JDB & get()
Get connection to database.
Definition: JDB.hh:234
Universal product identifier (UPI).
Definition: JUPI_t.hh:32
Template definition for getting table specific selector.

◆ operator()()

JUPI_t JDATABASE::JUPIHelper::operator() ( const JPBS_t pbs,
const int  number 
)
inline

Get UPI.

Parameters
pbsPBS
numberserial number
Returns
UPI

Definition at line 287 of file JDBToolkit.hh.

288  {
289  const_iterator p = this->find(pbs);
290 
291  if (p == this->end()) {
292 
293  initialise(pbs);
294 
295  p = this->find(pbs);
296  }
297 
298  if (p != this->end()) {
299 
300  typename mapped_type::const_iterator q = p->second.find(number);
301 
302  if (q != p->second.end()) {
303 
304  return q->second;
305 
306  } else {
307 
308  THROW(JValueOutOfRange, "Invalid serial number " << number);
309  }
310 
311  } else {
312 
313  THROW(JDatabaseException, "Invalid PBS " << pbs);
314  }
315  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Database exception.
Definition: JException.hh:684
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
void initialise(const JPBS_t &pbs)
Initialise.
Definition: JDBToolkit.hh:262

Member Data Documentation

◆ helper

JUPIHelper JDATABASE::JUPIHelper::helper
static

Helper object.

Definition at line 321 of file JDBToolkit.hh.


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