Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
JUPI_t operator() (const JPBS_t &pbs, const int number)
 Get UPI.
 

Static Public Attributes

static JUPIHelper helper
 Helper object.
 

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:235
const char * getTable()
Get table name.
Definition JDB.hh:373

◆ 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.
void initialise(const JPBS_t &pbs)
Initialise.

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: