DBTable Class Reference

Ratpac-two: RAT::DBTable Class Reference
Ratpac-two

Public Types

enum  FieldType {
  NOTFOUND , INTEGER , DOUBLE , BOOLEAN ,
  STRING , INTEGER_ARRAY , DOUBLE_ARRAY , BOOLEAN_ARRAY ,
  STRING_ARRAY , EMPTY_ARRAY , JSON
}
 

Public Member Functions

 DBTable ()
 
 DBTable (json::Value &jsonDoc)
 
 DBTable (std::string tblname, std::string index="")
 
 ~DBTable ()
 
std::string GetName () const
 
void SetName (std::string _tblname)
 
std::string GetIndex () const
 
void SetIndex (std::string _index)
 
int GetRunBegin () const
 
int GetRunEnd () const
 
std::vector< int > GetValidRuns () const
 
bool IsUser () const
 
bool IsDefault () const
 
bool IsValidRun (const int run)
 
bool UsesRunList () const
 
void SetRunRange (int _run_begin, int _run_end)
 
void SetRunList (std::vector< int > _run_list)
 
void SetUser ()
 
void SetDefault ()
 
FieldType GetFieldType (std::string name) const
 
std::vector< std::string > GetFieldList () const
 
int GetI (const std::string &name) const
 
double GetD (const std::string &name) const
 
std::string GetS (const std::string &name) const
 
bool GetZ (const std::string &name) const
 
std::vector< int > GetIArray (const std::string &name) const
 
std::vector< double > GetDArray (const std::string &name) const
 
std::vector< std::string > GetSArray (const std::string &name) const
 
std::vector< bool > GetZArray (const std::string &name) const
 
json::Value GetJSON (const std::string &name) const
 
json::Value GetCompleteJSON ()
 
template<typename T >
Get (const std::string &name) const
 
template<typename T >
void Set (const std::string &name, const T &value)
 
void SetIArrayDeferred (std::string name, DBFieldCallback *callback)
 
void SetDArrayDeferred (std::string name, DBFieldCallback *callback)
 
template<>
int Get (const std::string &name) const
 
template<>
double Get (const std::string &name) const
 
template<>
bool Get (const std::string &name) const
 

Protected Attributes

std::string tblname
 
std::string index
 
int run_begin
 
int run_end
 
bool useRunList = false
 
std::vector< int > run_list
 
json::Value table
 
stlplus::hash< std::string, FieldType, pyhasharrayTypeCache
 
stlplus::hash< std::string, RAT::DBFieldCallback *, pyhashiatbl_deferred
 
stlplus::hash< std::string, RAT::DBFieldCallback *, pyhashdatbl_deferred
 

Member Enumeration Documentation

◆ FieldType

Data type of field.

Enumerator
NOTFOUND 

Type for fields that don't exist

Constructor & Destructor Documentation

◆ DBTable() [1/3]

DBTable::DBTable ( )

Create new empty table.

◆ DBTable() [2/3]

DBTable::DBTable ( json::Value jsonDoc)

Create new table from json object.

◆ DBTable() [3/3]

DBTable::DBTable ( std::string  tblname,
std::string  index = "" 
)

Create new table with specific name and index.

◆ ~DBTable()

DBTable::~DBTable ( )

Destroy table.

Member Function Documentation

◆ Get()

template<typename T >
T RAT::DBTable::Get ( const std::string &  name) const
inline

Template version of the Get method.

Provided as a convenience to the DBLink implementation. Fetches field based on type of T.

◆ GetD()

double DBTable::GetD ( const std::string &  name) const

Get value of double field.

Warning
Due to the hash table implementation used here, this method raises an assertion error if name is not a valid field. Always use GetFieldType() to check if field exists if you are not sure!

◆ GetDArray()

std::vector< double > DBTable::GetDArray ( const std::string &  name) const

Get value of double array field.

Warning
Due to the hash table implementation used here, this method raises an assertion error if name is not a valid field. Always use GetFieldType() to check if field exists if you are not sure!

◆ GetFieldList()

std::vector< std::string > DBTable::GetFieldList ( ) const

Get a vector of field names. Call GetFieldType() to determine the type of each.

◆ GetFieldType()

DBTable::FieldType DBTable::GetFieldType ( std::string  name) const

Get data type of field in this table.

Returns
DBTable::NOTFOUND if the field does not exist, otherwise returns field type.

◆ GetI()

int DBTable::GetI ( const std::string &  name) const

Get value of integer field.

Warning
Due to the hash table implementation used here, this method raises an assertion error if name is not a valid field. Always use GetFieldType() to check if field exists if you are not sure!

◆ GetIArray()

std::vector< int > DBTable::GetIArray ( const std::string &  name) const

Get value of integer array field.

Warning
Due to the hash table implementation used here, this method raises an assertion error if name is not a valid field. Always use GetFieldType() to check if field exists if you are not sure!

◆ GetJSON()

json::Value DBTable::GetJSON ( const std::string &  name) const

Get a JSON value for any field.

This returns a json::Value for any field. This includes arbitrary JSON values that cannot be parsed by RATDB into standard C++ types.

◆ GetRunBegin()

int RAT::DBTable::GetRunBegin ( ) const
inline

Get run number for which this table is valid.

◆ GetRunEnd()

int RAT::DBTable::GetRunEnd ( ) const
inline

Get run number for which this table is valid.

◆ GetS()

std::string DBTable::GetS ( const std::string &  name) const

Get value of string field.

Warning
Due to the hash table implementation used here, this method raises an assertion error if name is not a valid field. Always use GetFieldType() to check if field exists if you are not sure!

◆ GetSArray()

std::vector< std::string > DBTable::GetSArray ( const std::string &  name) const

Get value of string array field.

Warning
Due to the hash table implementation used here, this method raises an assertion error if name is not a valid field. Always use GetFieldType() to check if field exists if you are not sure!

◆ GetValidRuns()

std::vector< int > DBTable::GetValidRuns ( ) const

Get list of runs for which this table is valid.

◆ GetZ()

bool DBTable::GetZ ( const std::string &  name) const

Get value of bool field.

Warning
Due to the hash table implementation used here, this method raises an assertion error if name is not a valid field. Always use GetFieldType() to check if field exists if you are not sure!

◆ GetZArray()

std::vector< bool > DBTable::GetZArray ( const std::string &  name) const

Get value of bool array field.

Warning
Due to the hash table implementation used here, this method raises an assertion error if name is not a valid field. Always use GetFieldType() to check if field exists if you are not sure!

◆ IsDefault()

bool DBTable::IsDefault ( ) const

Returns true if validity range flags this as a default-plane table.

◆ IsUser()

bool DBTable::IsUser ( ) const

Returns true if validity range flags this as a user-plane table.

◆ IsValidRun()

bool DBTable::IsValidRun ( const int  run)

Returns true if this table is valid for the run given

◆ Set()

template<typename T >
void RAT::DBTable::Set ( const std::string &  name,
const T &  value 
)
inline

Set any type that is convertable to a json::Value

◆ SetDArrayDeferred()

void RAT::DBTable::SetDArrayDeferred ( std::string  name,
DBFieldCallback callback 
)
inline

Set a deferred double array field that will be fetched on demand

◆ SetDefault()

void RAT::DBTable::SetDefault ( )
inline

Set this as a default table

◆ SetIArrayDeferred()

void RAT::DBTable::SetIArrayDeferred ( std::string  name,
DBFieldCallback callback 
)
inline

Set a deferred integer array field that will be fetched on demand

◆ SetRunList()

void DBTable::SetRunList ( std::vector< int >  _run_list)

Set run list for which this table is valid.

◆ SetRunRange()

void RAT::DBTable::SetRunRange ( int  _run_begin,
int  _run_end 
)
inline

Set run range for which this table is valid. Begin and end are inclusive

◆ SetUser()

void RAT::DBTable::SetUser ( )
inline

Set this as a user-override table

◆ UsesRunList()

bool RAT::DBTable::UsesRunList ( ) const
inline

Returns true if this table uses run list instead of range

Member Data Documentation

◆ arrayTypeCache

stlplus::hash<std::string, FieldType, pyhash> RAT::DBTable::arrayTypeCache
protected

Stores the data type of homogeneous arrays to make GetFieldType easier

◆ datbl_deferred

stlplus::hash<std::string, RAT::DBFieldCallback *, pyhash> RAT::DBTable::datbl_deferred
protected

Hashtable storage of callbacks for deferred integer array fields.

◆ iatbl_deferred

stlplus::hash<std::string, RAT::DBFieldCallback *, pyhash> RAT::DBTable::iatbl_deferred
protected

Hashtable storage of callbacks for deferred integer array fields.

◆ index

std::string RAT::DBTable::index
protected

Index of table

◆ run_begin

int RAT::DBTable::run_begin
protected

First run in which this table is valid

◆ run_end

int RAT::DBTable::run_end
protected

Last run in which this table is valid

◆ run_list

std::vector<int> RAT::DBTable::run_list
protected

List of runs in which this table is valid

◆ table

json::Value RAT::DBTable::table
protected

JSON object storage of all fields, except callbacks

◆ tblname

std::string RAT::DBTable::tblname
protected

Name of table

◆ useRunList

bool RAT::DBTable::useRunList = false
protected

Whether to use run list instead of range


The documentation for this class was generated from the following files:
  • /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/db/include/RAT/DBTable.hh
  • /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/db/src/DBTable.cc