Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | 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...
 

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 186 of file JDBToolkit.hh.

Member Function Documentation

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

Initialise.

Parameters
pbsPBS

Definition at line 192 of file JDBToolkit.hh.

193  {
194  ResultSet& rs = JDB::get()->StreamDS(getTable<JUPI>(), getSelector<JUPI>(pbs));
195 
196  for (JUPI parameters; rs >> parameters; ) {
197 
198  const JUPI_t upi(parameters.PBS,
199  parameters.VARIANT,
200  parameters.VERSION,
201  parameters.SERIALNUMBER);
202 
203  number2upi[pbs][parameters.SERIALNUMBER] = upi;
204  }
205 
206  rs.Close();
207  }
*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:236
Template definition for getting table specific selector.
static JDB & get()
Get connection to database.
Definition: JDB.hh:81
JUPI_t JDATABASE::JUPIHelper::operator() ( const JPBS_t pbs,
const int  number 
)
inline

Get UPI.

Parameters
pbsPBS
numberserial number
Returns
UPI

Definition at line 217 of file JDBToolkit.hh.

218  {
220 
221  if (p == number2upi[pbs].end()) {
222 
223  initialise(pbs);
224 
225  p = number2upi[pbs].find(number);
226 
227  if (p == number2upi[pbs].end()) {
228  THROW(JDatabaseException, "Invalid PBS / serial number " << pbs << " / " << number);
229  }
230  }
231 
232  return p->second;
233  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
void initialise(const JPBS_t &pbs)
Initialise.
Definition: JDBToolkit.hh:192
std::map< JPBS_t, std::map< int, JUPI_t > > number2upi
Definition: JDBToolkit.hh:236

Member Data Documentation

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

Definition at line 236 of file JDBToolkit.hh.


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