1 #ifndef CondTools_RunInfo_OMSAccess_h 2 #define CondTools_RunInfo_OMSAccess_h 6 #include <boost/property_tree/ptree.hpp> 7 #include <boost/property_tree/json_parser.hpp> 8 #include <boost/date_time/posix_time/posix_time.hpp> 16 static constexpr
const char*
const OMS_TIME_FMT =
"%Y-%m-%dT%H:%M:%SZ";
18 template <
typename T, T fun(const std::
string&)>
21 if (not attributeValue.empty() && attributeValue !=
"null") {
22 ret = fun(attributeValue);
29 throw std::invalid_argument(
"");
40 return from_string_impl<float, &s_to_f>(attributeValue, 0.);
46 return from_string_impl<int, &s_to_i>(attributeValue, 0);
52 unsigned long int_val = from_string_impl<unsigned long, &s_to_ul>(attributeValue, 0);
53 return (
unsigned short)int_val;
57 boost::posix_time::time_input_facet* facet =
new boost::posix_time::time_input_facet(
OMS_TIME_FMT);
59 ss.imbue(std::locale(std::locale(), facet));
61 boost::posix_time::ptime
time;
67 return from_string_impl<boost::posix_time::ptime, &s_to_time>(attributeValue, boost::posix_time::ptime());
88 boost::posix_time::time_facet* facet =
new boost::posix_time::time_facet();
91 stream.imbue(std::locale(std::locale::classic(), facet));
107 template <
typename T>
109 return impl::from_string<T>(
getAttribute(attributeName));
112 template <
typename primitive>
114 std::vector<primitive>
ret;
115 for (
auto&
item :
m_row->get_child(attributeName)) {
123 const boost::property_tree::ptree*
m_row =
nullptr;
139 boost::property_tree::ptree::const_iterator
m_iter;
168 static constexpr
const char*
const NEQ =
"NEQ";
169 static constexpr
const char*
const EQ =
"EQ";
170 static constexpr
const char*
const LT =
"LT";
171 static constexpr
const char*
const LE =
"LE";
172 static constexpr
const char*
const GT =
"GT";
173 static constexpr
const char*
const GE =
"GE";
174 static constexpr
const char*
const SNULL =
"null";
185 template <
typename T>
201 template <
typename T>
203 return filter<T>(
EQ, varName,
value);
205 template <
typename T>
207 return filter<T>(
NEQ, varName,
value);
209 template <
typename T>
211 return filter<T>(
GT, varName,
value);
213 template <
typename T>
215 return filter<T>(
GE, varName,
value);
217 template <
typename T>
219 return filter<T>(
LT, varName,
value);
221 template <
typename T>
223 return filter<T>(
LE, varName,
value);
OMSServiceQuery & addOutputVars(const std::initializer_list< const char *> &varNames)
OMSServiceQuery & filterNEQ(const std::string &varName, const T &value)
OMSServiceResultRef()=delete
OMSServiceQuery & filterLT(const std::string &varName, const T &value)
boost::property_tree::ptree * m_data
std::string getAttribute(const std::string &attributeName)
OMSServiceQuery & addOutputVar(const std::string &varName)
static constexpr const char *const NEQ
OMSServiceResultRef operator*()
std::unique_ptr< OMSServiceQuery > query(const std::string &function) const
static constexpr const char *const GT
ret
prodAgent to be discontinued
T from_string(const std::string &attributeValue)
OMSServiceQuery & filterGT(const std::string &varName, const T &value)
OMSServiceQuery & filter(const char *cmp, const std::string &varName, const T &value)
std::string to_string(const V &value)
OMSServiceQuery & filterEQ(const std::string &varName, const T &value)
float s_to_f(const std::string &val)
std::vector< primitive > getArray(const std::string &attributeName)
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
constexpr char const * varNames[]
static constexpr const char *const EQ
Primitive< F, X >::type primitive(const F &f)
boost::posix_time::ptime s_to_time(const std::string &val)
int s_to_i(const std::string &val)
static constexpr const char *const OMS_TIME_FMT
bool operator!=(const OMSServiceResultIterator &rhs)
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
OMSServiceQuery & filterGE(const std::string &varName, const T &value)
OMSServiceResult & result()
boost::property_tree::ptree::const_iterator m_iter
const boost::property_tree::ptree * m_row
bool operator==(const OMSServiceResultIterator &rhs)
T from_string_impl(const std::string &attributeValue, T zero)
OMSServiceResultIterator & operator++()
static constexpr const char *const LE
OMSServiceResultIterator end() const
static constexpr const char *const LT
OMSServiceResultIterator()=delete
void addVar(const std::string &varName)
unsigned long s_to_ul(const std::string &val)
std::unique_ptr< OMSServiceResult > m_result
char data[epos_bytes_allocation]
OMSServiceQuery & filterLE(const std::string &varName, const T &value)
size_t parseData(const std::string &data)
OMSServiceQuery & filterNotNull(const std::string &varName)
void connect(const std::string &baseUrl)
OMSServiceResultIterator begin() const
boost::property_tree::ptree m_root
static constexpr const char *const SNULL
OMSServiceQuery & limit(int value)
std::string to_string(const boost::posix_time::ptime &value)
static constexpr const char *const GE