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 GT =
"GT";
172 static constexpr
const char*
const SNULL =
"null";
183 template <
typename T>
191 filter <<
"filter[" << varName <<
"][" << cmp <<
"]=" <<
impl::to_string(value);
196 template <
typename T>
198 return filter<T>(
EQ, varName,
value);
200 template <
typename T>
202 return filter<T>(
NEQ, varName,
value);
204 template <
typename T>
206 return filter<T>(
GT, varName,
value);
208 template <
typename T>
210 return filter<T>(
LT, varName,
value);
OMSServiceQuery & addOutputVars(const std::initializer_list< const char * > &varNames)
tuple ret
prodAgent to be discontinued
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*()
static constexpr const char *const GT
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)
OMSServiceResultIterator begin() const
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
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 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]
size_t parseData(const std::string &data)
OMSServiceQuery & filterNotNull(const std::string &varName)
void connect(const std::string &baseUrl)
boost::property_tree::ptree m_root
OMSServiceResultIterator end() const
static constexpr const char *const SNULL
std::unique_ptr< OMSServiceQuery > query(const std::string &function) const