Jpp  16.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
JDATABASE::JUPIHelper Struct Reference

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

#include <JDBToolkit.hh>

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...
 

Protected Attributes

std::map< JPBS_t, std::map
< int, JUPI_t > > 
number2upi
 

Detailed Description

Auxiliary class for mapping UPI of product to serial number.

Definition at line 237 of file JDBToolkit.hh.

Member Function Documentation

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

Initialise.

Parameters
pbsPBS

Definition at line 243 of file JDBToolkit.hh.

244  {
245  ResultSet& rs = JDB::get()->StreamDS(getTable<JUPI>(), getSelector<JUPI>(pbs));
246 
247  for (JUPI parameters; rs >> parameters; ) {
248 
249  const JUPI_t upi(parameters.PBS,
250  parameters.VARIANT,
251  parameters.VERSION,
252  parameters.SERIALNUMBER);
253 
254  number2upi[pbs][parameters.SERIALNUMBER] = upi;
255  }
256 
257  rs.Close();
258  }
*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
Universal product identifier (UPI).
Definition: JUPI_t.hh:29
std::map< JPBS_t, std::map< int, JUPI_t > > number2upi
Definition: JDBToolkit.hh:308
Template definition for getting table specific selector.
static JDB & get()
Get connection to database.
Definition: JDB.hh:225
JUPI_t JDATABASE::JUPIHelper::operator() ( const JPBS_t pbs,
const int  number 
)
inline

Get UPI.

Parameters
pbsPBS
numberserial number
Returns
UPI

Definition at line 268 of file JDBToolkit.hh.

269  {
270  using namespace std;
271  using namespace JPP;
272 
273  map<JPBS_t, map<int, JUPI_t>>::const_iterator p = number2upi.find(pbs);
274 
275  if (p == number2upi.end()) {
276 
277  initialise(pbs);
278  p = number2upi.find(pbs);
279  }
280 
281  if (p != number2upi.end()) {
282 
283  map<int, JUPI_t>::const_iterator q = p->second.find(number);
284 
285  if (q != p->second.end()) {
286 
287  return q->second;
288 
289  } else {
290 
291  THROW(JValueOutOfRange, "Invalid serial number " << number);
292  }
293 
294  } else {
295 
296  THROW(JDatabaseException, "Invalid PBS " << pbs);
297  }
298  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
void initialise(const JPBS_t &pbs)
Initialise.
Definition: JDBToolkit.hh:243
std::map< JPBS_t, std::map< int, JUPI_t > > number2upi
Definition: JDBToolkit.hh:308

Member Data Documentation

JUPIHelper JDATABASE::JUPIHelper::helper
static

Helper object.

Definition at line 304 of file JDBToolkit.hh.

std::map<JPBS_t, std::map<int, JUPI_t> > JDATABASE::JUPIHelper::number2upi
protected

Definition at line 308 of file JDBToolkit.hh.


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