Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
JDATABASE::JDBReader< T > Struct Template Reference

Auxiliary class to read ROOT object from database. More...

#include <JDBReader.hh>

Inheritance diagram for JDATABASE::JDBReader< T >:
JLANG::JSingleton< T >

Public Types

typedef T data_type
 

Public Member Functions

 JDBReader ()
 Default constructor. More...
 
const Toperator() (ResultSet &rs)
 Read ROOT object from result set. More...
 

Static Public Member Functions

static void reset ()
 Reset internal lookup table. More...
 
static void set (const std::vector< Selector > &selection)
 Set default value corresponding to given selection. More...
 
static data_typegetInstance ()
 Get unique instance of template class. More...
 

Private Attributes

T object
 internal value More...
 
T value
 default value More...
 
JROOT::JRootReader reader
 
std::vector
< JROOT::JRootReadableClass
buffer
 

Detailed Description

template<class T>
struct JDATABASE::JDBReader< T >

Auxiliary class to read ROOT object from database.

The names of the table columns are one-to-one mapped to the names of the data members of the corresponding data structure using the ROOT dictionary.
The method JDBReader::set can be used to a priori assign default values to those data members that are defined by the selector used in the query.
Note that the list of column names associated to the template parameter is considered to be permanent.
If not, the static method JDBReader::reset should be called before the next read operation.

Definition at line 91 of file JDBReader.hh.

Member Typedef Documentation

template<class T>
typedef T JLANG::JSingleton< T >::data_type
inherited

Definition at line 20 of file JSingleton.hh.

Constructor & Destructor Documentation

template<class T>
JDATABASE::JDBReader< T >::JDBReader ( )
inline

Default constructor.

Definition at line 97 of file JDBReader.hh.

97  :
98  object(),
100  {}
JROOT::JRootReader reader
Definition: JDBReader.hh:172
Simple data structure to support I/O of equations (see class JLANG::JEquation).
T object
internal value
Definition: JDBReader.hh:170
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
static JNullStream null
Null I/O stream.
Definition: JNullStream.hh:51

Member Function Documentation

template<class T>
static void JDATABASE::JDBReader< T >::reset ( )
inlinestatic

Reset internal lookup table.

Definition at line 106 of file JDBReader.hh.

107  {
108  JDBReader<T>::getInstance().buffer.clear();
109 
110  JDBReader<T>::getInstance().value = T();
111  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27
template<class T>
static void JDATABASE::JDBReader< T >::set ( const std::vector< Selector > &  selection)
inlinestatic

Set default value corresponding to given selection.

Parameters
selectionselection

Definition at line 119 of file JDBReader.hh.

120  {
121  selection >> JDBReader<T>::getInstance().value;
122  }
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27
template<class T>
const T& JDATABASE::JDBReader< T >::operator() ( ResultSet &  rs)
inline

Read ROOT object from result set.

Parameters
rsresult set
Returns
object

Definition at line 131 of file JDBReader.hh.

132  {
133  using namespace std;
134  using namespace JPP;
135 
136  object = value;
137 
138  if (buffer.empty()) {
139 
140  JRootReadableClass cls(object);
141 
142  for (size_t i = 0; i != rs.FieldCount(); ++i) {
143 
144  string parameter = rs.FieldName(i);
145 
146  for (string::const_iterator i = SPECIAL_CHARACTERS.begin(); i != SPECIAL_CHARACTERS.end(); ++i) {
147  for (string::size_type pos; (pos = parameter.find(*i)) != string::npos; ) {
148  parameter.erase(pos);
149  }
150  }
151 
152  buffer.push_back(cls.find(parameter.c_str()));
153  }
154  }
155 
156  for (unsigned int i = 0; i != rs.FieldCount(); ++i) {
157 
158  if (buffer[i].is_valid()) {
159 
160  JRedirectString redirect(reader, rs.GetString(i));
161 
162  reader.getObject(buffer[i]);
163  }
164  }
165 
166  return object;
167  }
JROOT::JRootReader reader
Definition: JDBReader.hh:172
T object
internal value
Definition: JDBReader.hh:170
T value
default value
Definition: JDBReader.hh:171
bool is_valid(const json &js)
Check validity of JSon data.
std::vector< JROOT::JRootReadableClass > buffer
Definition: JDBReader.hh:174
JRootReader & getObject(T &object)
Read object.
static const std::string SPECIAL_CHARACTERS
Special characters.
Definition: JDBReader.hh:36
template<class T>
static data_type& JLANG::JSingleton< T >::getInstance ( )
inlinestaticinherited

Get unique instance of template class.

Returns
object

Definition at line 27 of file JSingleton.hh.

28  {
29  static data_type value;
30 
31  return value;
32  }

Member Data Documentation

template<class T>
T JDATABASE::JDBReader< T >::object
private

internal value

Definition at line 170 of file JDBReader.hh.

template<class T>
T JDATABASE::JDBReader< T >::value
private

default value

Definition at line 171 of file JDBReader.hh.

template<class T>
JROOT::JRootReader JDATABASE::JDBReader< T >::reader
private

Definition at line 172 of file JDBReader.hh.

template<class T>
std::vector<JROOT::JRootReadableClass> JDATABASE::JDBReader< T >::buffer
private

Definition at line 174 of file JDBReader.hh.


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