ATLAS Offline Software
TrigDBHelper.h
Go to the documentation of this file.
1 /* Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */
2 
3 #ifndef TRIGCONFIO_TRIGDBHELPER_H
4 #define TRIGCONFIO_TRIGDBHELPER_H
5 
6 #include "CoralBase/Blob.h"
7 #include "CoralBase/Attribute.h"
8 #include "CoralBase/AttributeList.h"
9 #include "RelationalAccess/ISessionProxy.h"
10 #include "RelationalAccess/IQuery.h"
11 
12 #define BOOST_BIND_GLOBAL_PLACEHOLDERS // Needed to silence Boost pragma message
13 #include "boost/property_tree/ptree.hpp"
14 #include "boost/property_tree/json_parser.hpp"
15 #include "boost/iostreams/stream.hpp"
16 
17 #include <vector>
18 #include <string>
19 #include <memory>
20 #include <set>
21 
22 #include "RelationalAccess/ICursor.h"
23 #include "RelationalAccess/ITransaction.h"
24 #include "RelationalAccess/SchemaException.h"
25 
27 namespace TrigConf {
29  public:
30 
31  void addToTableList(const std::string & table, const std::string & table_short = "");
32 
33  void extendCondition(const std::string & condext);
34 
35  template<typename T>
36  void extendOutput(const std::string & fieldName);
37 
38  template<typename T>
39  void extendBinding(const std::string & fieldName);
40 
41  template<typename T>
42  void setBoundValue(const std::string & fieldName, const T & value);
43 
44  std::unique_ptr< coral::IQuery >
45  createQuery( coral::ISessionProxy * session );
46 
47  void setDataName(const std::string & dataName) {
49  }
50 
51  const std::string & dataName() {
52  return m_dataName;
53  }
54 
55  private:
56  std::vector<std::pair<std::string,std::string>> m_tables{}; // tables needed in the query
57  std::string m_condition{""}; // where clause
58  coral::AttributeList m_attList; // select variables
59  coral::AttributeList m_bindList; // bound variables
60  std::string m_dataName; // the name of the field with the datablob
61  std::set<std::string> m_bound; // bound variables that were set
62  };
63 
64  template<typename T>
65  void QueryDefinition::extendOutput(const std::string & fieldName) {
66  m_attList.extend<T>( fieldName );
67  }
68 
69  template<typename T>
70  void QueryDefinition::extendBinding(const std::string & fieldName) {
71  m_bindList.extend<T>( fieldName );
72  }
73 
74  template<typename T>
75  void QueryDefinition::setBoundValue(const std::string & fieldName, const T & value) {
76  m_bindList[fieldName].setValue(value);
77  m_bound.insert(fieldName);
78  }
79 
81 
82 }
83 
84 #endif
TrigConf::QueryDefinition::m_condition
std::string m_condition
Definition: TrigDBHelper.h:57
test_pyathena.pt
pt
Definition: test_pyathena.py:11
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
athena.value
value
Definition: athena.py:122
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::QueryDefinition
Definition: TrigDBHelper.h:28
TrigConf::QueryDefinition::setDataName
void setDataName(const std::string &dataName)
Definition: TrigDBHelper.h:47
TrigConf::QueryDefinition::extendOutput
void extendOutput(const std::string &fieldName)
Definition: TrigDBHelper.h:65
TrigConf::QueryDefinition::setBoundValue
void setBoundValue(const std::string &fieldName, const T &value)
Definition: TrigDBHelper.h:75
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
taskman.fieldName
fieldName
Definition: taskman.py:492
TrigConf::QueryDefinition::m_attList
coral::AttributeList m_attList
Definition: TrigDBHelper.h:58
TrigConf::QueryDefinition::createQuery
std::unique_ptr< coral::IQuery > createQuery(coral::ISessionProxy *session)
Definition: TrigDBHelper.cxx:10
TrigConf::QueryDefinition::m_bindList
coral::AttributeList m_bindList
Definition: TrigDBHelper.h:59
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
python.ext.table_printer.table
list table
Definition: table_printer.py:81
TrigConf::QueryDefinition::extendBinding
void extendBinding(const std::string &fieldName)
Definition: TrigDBHelper.h:70
TrigConf::QueryDefinition::extendCondition
void extendCondition(const std::string &condext)
Definition: TrigDBHelper.cxx:48
TrigConf::QueryDefinition::m_tables
std::vector< std::pair< std::string, std::string > > m_tables
Definition: TrigDBHelper.h:56
TrigConf::QueryDefinition::m_dataName
std::string m_dataName
Definition: TrigDBHelper.h:60
TrigConf::blobToPtree
void blobToPtree(const coral::Blob &blob, boost::property_tree::ptree &pt)
Definition: TrigDBHelper.cxx:58
TrigConf::QueryDefinition::m_bound
std::set< std::string > m_bound
Definition: TrigDBHelper.h:61
TrigConf::QueryDefinition::dataName
const std::string & dataName()
Definition: TrigDBHelper.h:51
TrigConf::QueryDefinition::addToTableList
void addToTableList(const std::string &table, const std::string &table_short="")
Definition: TrigDBHelper.cxx:42
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96