Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDATABASE::JSelector Class Reference

Auxiliary class for specifying selection of database data. More...

#include <JSelector.hh>

Inheritance diagram for JDATABASE::JSelector:
std::vector< Selector > JMATH::JMath< JFirst_t, JSecond_t > JDATABASE::getSelector< T, APIV2::JCalibration_t, true > JDATABASE::getSelector< T, APIV2::JRunCalibration, true > JDATABASE::getSelector< T, JAHRS, true > JDATABASE::getSelector< T, JAHRSDetectorCalibration, true > JDATABASE::getSelector< T, JAllParams, true > JDATABASE::getSelector< T, JCLBID, true > JDATABASE::getSelector< T, JCLBMap, true > JDATABASE::getSelector< T, JDatalogNumbers, true > JDATABASE::getSelector< T, JDetCalibrations, true > JDATABASE::getSelector< T, JDetectorIntegration, true > JDATABASE::getSelector< T, JDetectors, true > JDATABASE::getSelector< T, JPMTHVRunSettings, true > JDATABASE::getSelector< T, JPMTHVSettings, true > JDATABASE::getSelector< T, JPersons, true > JDATABASE::getSelector< T, JRunSummaryNumbers, true > JDATABASE::getSelector< T, JRuns, true > JDATABASE::getSelector< T, JRunsetupParams, true > JDATABASE::getSelector< T, JToAshort, true > JDATABASE::getSelector< T, JUPI, true > JDATABASE::getSelector< T, JVendorHV, true >

Public Member Functions

 JSelector ()
 Default constructor.
 
template<class T >
 JSelector (const std::string &key, const T value, const Selector::RelOp &operand=Selector::RelOp::Equal)
 Constructor.
 
template<class JClass_t , class JType_t >
 JSelector (JType_t JClass_t::*data_member, const JType_t value, const Selector::RelOp &operand=Selector::RelOp::Equal)
 Constructor.
 
template<class JClass_t >
 JSelector (std::string JClass_t::*data_member, const std::string value, const Selector::RelOp &operand=Selector::RelOp::Equal)
 Constructor.
 
JSelectoradd (const JSelector &selection)
 Add selection.
 
template<class T >
JSelectoradd (const std::string &key, const T value, const Selector::RelOp &operand=Selector::RelOp::Equal)
 Add selection.
 
template<class JClass_t , class JType_t >
JSelectoradd (JType_t JClass_t::*data_member, const JType_t value, const Selector::RelOp &operand=Selector::RelOp::Equal)
 Add selection.
 
template<class JClass_t >
JSelectoradd (std::string JClass_t::*data_member, const std::string &value, const Selector::RelOp &operand=Selector::RelOp::Equal)
 Add selection.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 

Static Public Attributes

static const char EOL = ';'
 End-of-line.
 

Friends

std::istream & operator>> (std::istream &in, JSelector &selector)
 Read selector from input stream.
 
std::ostream & operator<< (std::ostream &out, const JSelector &selector)
 Write selector to output stream.
 

Detailed Description

Auxiliary class for specifying selection of database data.

Definition at line 68 of file JDB/JSelector.hh.

Constructor & Destructor Documentation

◆ JSelector() [1/4]

JDATABASE::JSelector::JSelector ( )
inline

Default constructor.

Definition at line 82 of file JDB/JSelector.hh.

83 {}

◆ JSelector() [2/4]

template<class T >
JDATABASE::JSelector::JSelector ( const std::string & key,
const T value,
const Selector::RelOp & operand = Selector::RelOp::Equal )
inline

Constructor.

Parameters
keykey
valuevalue
operandoperand

Definition at line 94 of file JDB/JSelector.hh.

95 {
96 add(key, value, operand);
97 }
JSelector & add(const JSelector &selection)
Add selection.

◆ JSelector() [3/4]

template<class JClass_t , class JType_t >
JDATABASE::JSelector::JSelector ( JType_t JClass_t::* data_member,
const JType_t value,
const Selector::RelOp & operand = Selector::RelOp::Equal )
inline

Constructor.

Parameters
data_memberdata member
valuevalue
operandoperand

Definition at line 108 of file JDB/JSelector.hh.

109 {
110 add(data_member, value, operand);
111 }

◆ JSelector() [4/4]

template<class JClass_t >
JDATABASE::JSelector::JSelector ( std::string JClass_t::* data_member,
const std::string value,
const Selector::RelOp & operand = Selector::RelOp::Equal )
inline

Constructor.

Parameters
data_memberdata member
valuevalue
operandoperand

Definition at line 122 of file JDB/JSelector.hh.

123 {
124 add(data_member, value, operand);
125 }

Member Function Documentation

◆ add() [1/4]

JSelector & JDATABASE::JSelector::add ( const JSelector & selection)
inline

Add selection.

Parameters
selectionselection
Returns
this selection

Definition at line 134 of file JDB/JSelector.hh.

135 {
136 using namespace std;
137
138 copy(selection.begin(), selection.end(), back_inserter(*this));
139
140 return *this;
141 }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163

◆ add() [2/4]

template<class T >
JSelector & JDATABASE::JSelector::add ( const std::string & key,
const T value,
const Selector::RelOp & operand = Selector::RelOp::Equal )
inline

Add selection.

Parameters
keykey
valuevalue
operandoperand
Returns
this selection

Definition at line 153 of file JDB/JSelector.hh.

154 {
155 using namespace std;
156
157 ostringstream os;
158
159 os << value;
160
161 push_back(Selector(key.c_str(), os.str().c_str(), operand));
162
163 return *this;
164 }

◆ add() [3/4]

template<class JClass_t , class JType_t >
JSelector & JDATABASE::JSelector::add ( JType_t JClass_t::* data_member,
const JType_t value,
const Selector::RelOp & operand = Selector::RelOp::Equal )
inline

Add selection.

Parameters
data_memberdata member
valuevalue
operandoperand
Returns
this selection

Definition at line 176 of file JDB/JSelector.hh.

177 {
178 return add(getColumn(data_member), value, operand);
179 }
const char * getColumn(JType_t JTable_t::*data_member)
Get column name.
Definition JDB.hh:386

◆ add() [4/4]

template<class JClass_t >
JSelector & JDATABASE::JSelector::add ( std::string JClass_t::* data_member,
const std::string & value,
const Selector::RelOp & operand = Selector::RelOp::Equal )
inline

Add selection.

Parameters
data_memberdata member
valuevalue
operandoperand
Returns
this selection

Definition at line 191 of file JDB/JSelector.hh.

192 {
193 return add(getColumn(data_member), value, operand);
194 }

◆ mul()

template<class JFirst_t , class JSecond_t >
JFirst_t & JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t & object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355 {
356 return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357 }

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JSelector & selector )
friend

Read selector from input stream.

Parameters
ininput stream
selectorselector
Returns
input stream

Definition at line 204 of file JDB/JSelector.hh.

205 {
206 using namespace std;
207 using namespace JPP;
208
209 for (string buffer; getline(in, buffer, JSelector::EOL); ) {
210
211 int operand = -1;
212
213 for (int i = 0; i != NUMBER_OF_OPERANDS; ++i) {
214
215 const string::size_type pos = buffer.find(getOperand(i).Render());
216
217 if (pos != string::npos && (operand == -1 || getOperand(i).Render().length() > getOperand(operand).Render().length())) {
218 operand = i;
219 }
220 }
221
222 if (operand != -1) {
223
224 const string::size_type pos = buffer.find(getOperand(operand).Render());
225
226 const string key = JPP::trim(buffer.substr(0, pos));
227 const string value = JPP::trim(buffer.substr(pos + getOperand(operand).Render().length()));
228
229 if (key .find_first_of("=!<>") == string::npos &&
230 value.find_first_of("=!<>") == string::npos) {
231
232 selector.push_back(Selector(key.c_str(), value.c_str(), getOperand(operand)));
233
234 } else {
235
236 in.setstate(ios::badbit);
237 }
238
239 } else {
240
241 in.setstate(ios::badbit);
242 }
243 }
244
245 return in;
246 }
static const char EOL
End-of-line.
static const int NUMBER_OF_OPERANDS
Number of available operands.
const Selector::RelOp & getOperand(const int index)
Get operand.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478
std::string trim(const std::string &buffer)
Trim string.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JSelector & selector )
friend

Write selector to output stream.

Parameters
outoutput stream
selectorselector
Returns
output stream

Definition at line 256 of file JDB/JSelector.hh.

257 {
258 for (const_iterator i = selector.begin(); i != selector.end(); ++i) {
259 out << i->Name << i->RelationalOperator.Render() << i->Value << JSelector::EOL << std::endl;
260 }
261
262 return out;
263 }

Member Data Documentation

◆ EOL

const char JDATABASE::JSelector::EOL = ';'
static

End-of-line.

Definition at line 76 of file JDB/JSelector.hh.


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