|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
Calibration-database query: a map from QUERY_PAR keys to string values plus a stored query string. More...
#include <Query.hh>
Public Types | |
| enum | AXIS { AXIS_X =0 , AXIS_Y , AXIS_Z } |
| Axis selector; set_paremeters() stores it as the AXISNUM parameter. More... | |
| enum | CONSTR_TYPE { QUERY_DEFAULT =0 , QUERY_STRING , QUERY_MAP , QUERY_PARS } |
| Which constructor (or set_paremeters()) last set up the query; query() builds a query string only for QUERY_MAP and QUERY_PARS. More... | |
| enum | QUERY_PAR { DETECTOR =0 , EXPERIMENT , CALIBTYPE , RUN , TIME_SEC , VERSION , AXISNUM , MASKBITS , MASKBITSGEO } |
| Keys of the parameter map; parameter_default() gives each key's default string. More... | |
| typedef std::map< QUERY_PAR, std::string > | map_t |
| Map from QUERY_PAR key to its string value. | |
Public Member Functions | |
| Query () | |
| Default query: empty query string and all nine parameters at their defaults (set_qmap()). | |
| Query (const std::string &query) | |
| Store query as the query string and set all parameters to their defaults; query() returns the string unchanged. | |
| Query (const map_t &qmap) | |
| Copy qmap as the parameter map (no defaults are added). | |
| Query (const char *det, const char *exp=NULL, const char *ctype=NULL, const unsigned run=0, const unsigned time_sec=0, const char *version=NULL) | |
| Set the parameters with set_paremeters(det, exp, ctype, run, time_sec, version); axis and mask bits take their defaults (AXIS_X, 0377). | |
| virtual | ~Query () |
| Destructor; only logs a debug message. | |
| Query (const Query &)=delete | |
| Copy construction is disabled. | |
| Query & | operator= (const Query &)=delete |
| Copy assignment is disabled. | |
| const CONSTR_TYPE & | constr_type () |
| Return which constructor (or set_paremeters()) last set up the query. | |
| std::string | string_members (const char *sep="\n") |
| Return "DETECTOR: v", "EXPERIMENT: v", ... "MASKBITSGEO: v" for all nine parameters (values from parameter()), joined by sep. | |
| void | set_qmap (const map_t *map=NULL) |
| Replace the parameter map with *map, or, if map is NULL, set all nine parameters to their defaults. | |
| void | set_paremeters (const char *det, const char *exp=NULL, const char *ctype=NULL, const unsigned run=0, const unsigned time_sec=0, const char *version=NULL, const AXIS axis=AXIS_X, const unsigned mbits=0377, const unsigned mbitsgeo=0377) |
| Set all nine parameters: NULL char pointers (exp, ctype, version) become "NULL" and numbers become decimal strings (so mbits 0377 is stored as "255"). | |
| void | set_paremeter (const QUERY_PAR t, const char *p) |
| Set parameter t to the string p. | |
| void | set_calibtype (const CALIB_TYPE &ctype) |
| Set CALIBTYPE to name_of_calibtype(ctype). | |
| bool | is_set (const QUERY_PAR t) |
| Return true if the map has an entry for t. | |
| std::string | parameter_default (const QUERY_PAR t) |
| Return the default string for t: "NULL" for DETECTOR, EXPERIMENT, CALIBTYPE and VERSION; "0" for RUN, TIME_SEC and AXISNUM; "0377" for MASKBITS and MASKBITSGEO. | |
| std::string | parameter (const QUERY_PAR t) |
| Return the value stored for t, or parameter_default(t) if t is not set. | |
| int | parameter_int (const QUERY_PAR t) |
| Return std::stoi(parameter(t)); stoi throws std::invalid_argument for a non-numeric value such as "NULL". | |
| unsigned | parameter_uint (const QUERY_PAR t) |
| Return (unsigned)std::stoi(parameter(t)). | |
| uint16_t | parameter_uint16 (const QUERY_PAR t) |
| Return (uint16_t)std::stoi(parameter(t)). | |
| map_t & | qmap () |
| Return a reference to the parameter map. | |
| std::string | query () |
| For QUERY_MAP and QUERY_PARS, build the JSON query with dbnames_collection_query() from DETECTOR, EXPERIMENT, CALIBTYPE, RUN, TIME_SEC and VERSION, store it and return it; otherwise return the stored string. | |
Protected Attributes | |
| std::string | _query |
| map_t | _qmap |
Friends | |
| std::ostream & | operator<< (std::ostream &os, Query &o) |
| Write o.string_members(" ") to os and return os. | |
Calibration-database query: a map from QUERY_PAR keys to string values plus a stored query string.
query() builds the web-DB JSON query from the map.
| typedef std::map<QUERY_PAR, std::string> calib::Query::map_t |
Map from QUERY_PAR key to its string value.
| enum calib::Query::AXIS |
Axis selector; set_paremeters() stores it as the AXISNUM parameter.
| Enumerator | |
|---|---|
| AXIS_X | Value 0. |
| AXIS_Y | Value 1. |
| AXIS_Z | Value 2. |
Which constructor (or set_paremeters()) last set up the query; query() builds a query string only for QUERY_MAP and QUERY_PARS.
| Enumerator | |
|---|---|
| QUERY_DEFAULT | 0: set by Query(). |
| QUERY_STRING | 1: set by Query(const std::string&). |
| QUERY_MAP | 2: set by Query(const map_t&). |
| QUERY_PARS | 3: set by the parameter constructor and by set_paremeters(). |
Keys of the parameter map; parameter_default() gives each key's default string.
| calib::Query::Query | ( | ) |
Default query: empty query string and all nine parameters at their defaults (set_qmap()).
| calib::Query::Query | ( | const std::string & | query | ) |
Store query as the query string and set all parameters to their defaults; query() returns the string unchanged.
| calib::Query::Query | ( | const map_t & | qmap | ) |
Copy qmap as the parameter map (no defaults are added).
Reading DETECTOR for the debug message inserts an empty DETECTOR entry if it is missing.
| calib::Query::Query | ( | const char * | det, |
| const char * | exp = NULL, |
||
| const char * | ctype = NULL, |
||
| const unsigned | run = 0, |
||
| const unsigned | time_sec = 0, |
||
| const char * | version = NULL |
||
| ) |
Set the parameters with set_paremeters(det, exp, ctype, run, time_sec, version); axis and mask bits take their defaults (AXIS_X, 0377).
|
virtual |
Destructor; only logs a debug message.
|
delete |
Copy construction is disabled.
|
inline |
Return which constructor (or set_paremeters()) last set up the query.
| bool calib::Query::is_set | ( | const QUERY_PAR | t | ) |
Return true if the map has an entry for t.
| std::string calib::Query::parameter | ( | const QUERY_PAR | t | ) |
Return the value stored for t, or parameter_default(t) if t is not set.
| std::string calib::Query::parameter_default | ( | const QUERY_PAR | t | ) |
Return the default string for t: "NULL" for DETECTOR, EXPERIMENT, CALIBTYPE and VERSION; "0" for RUN, TIME_SEC and AXISNUM; "0377" for MASKBITS and MASKBITSGEO.
| int calib::Query::parameter_int | ( | const QUERY_PAR | t | ) |
Return std::stoi(parameter(t)); stoi throws std::invalid_argument for a non-numeric value such as "NULL".
| unsigned calib::Query::parameter_uint | ( | const QUERY_PAR | t | ) |
Return (unsigned)std::stoi(parameter(t)).
stoi reads decimal, so the default "0377" gives 377; it throws for a non-numeric value.
| uint16_t calib::Query::parameter_uint16 | ( | const QUERY_PAR | t | ) |
Return (uint16_t)std::stoi(parameter(t)).
stoi reads decimal, so the default "0377" gives 377; it throws for a non-numeric value.
|
inline |
Return a reference to the parameter map.
| std::string calib::Query::query | ( | ) |
For QUERY_MAP and QUERY_PARS, build the JSON query with dbnames_collection_query() from DETECTOR, EXPERIMENT, CALIBTYPE, RUN, TIME_SEC and VERSION, store it and return it; otherwise return the stored string.
Values are passed as strings, so a VERSION left at "NULL" is added to the query as "version":"NULL".
| void calib::Query::set_calibtype | ( | const CALIB_TYPE & | ctype | ) |
Set CALIBTYPE to name_of_calibtype(ctype).
| void calib::Query::set_paremeter | ( | const QUERY_PAR | t, |
| const char * | p | ||
| ) |
Set parameter t to the string p.
| void calib::Query::set_paremeters | ( | const char * | det, |
| const char * | exp = NULL, |
||
| const char * | ctype = NULL, |
||
| const unsigned | run = 0, |
||
| const unsigned | time_sec = 0, |
||
| const char * | version = NULL, |
||
| const AXIS | axis = AXIS_X, |
||
| const unsigned | mbits = 0377, |
||
| const unsigned | mbitsgeo = 0377 |
||
| ) |
Set all nine parameters: NULL char pointers (exp, ctype, version) become "NULL" and numbers become decimal strings (so mbits 0377 is stored as "255").
Sets constr_type() to QUERY_PARS. det must not be NULL, as it is passed straight to std::string.
| void calib::Query::set_qmap | ( | const map_t * | map = NULL | ) |
Replace the parameter map with *map, or, if map is NULL, set all nine parameters to their defaults.
| std::string calib::Query::string_members | ( | const char * | sep = "\n" | ) |
Return "DETECTOR: v", "EXPERIMENT: v", ... "MASKBITSGEO: v" for all nine parameters (values from parameter()), joined by sep.
|
friend |
Write o.string_members(" ") to os and return os.
|
protected |
|
protected |