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 
26 #include "TrigConfBase/MsgStream.h"
27 
29 namespace TrigConf {
31  public:
32 
33  void addToTableList(const std::string & table, const std::string & table_short = "");
34 
35  void extendCondition(const std::string & condext);
36 
37  template<typename T>
38  void extendOutput(const std::string & fieldName);
39 
40  template<typename T>
41  void extendBinding(const std::string & fieldName);
42 
43  template<typename T>
44  void setBoundValue(const std::string & fieldName, const T & value);
45 
46  std::unique_ptr< coral::IQuery >
47  createQuery( coral::ISessionProxy * session );
48 
49  void setDataName(const std::string & dataName) {
51  }
52 
53  const std::string & dataName() {
54  return m_dataName;
55  }
56 
57  private:
58  std::vector<std::pair<std::string,std::string>> m_tables{}; // tables needed in the query
59  std::string m_condition{""}; // where clause
60  coral::AttributeList m_attList; // select variables
61  coral::AttributeList m_bindList; // bound variables
62  std::string m_dataName; // the name of the field with the datablob
63  std::set<std::string> m_bound; // bound variables that were set
64  };
65 
66  template<typename T>
67  void QueryDefinition::extendOutput(const std::string & fieldName) {
68  m_attList.extend<T>( fieldName );
69  }
70 
71  template<typename T>
72  void QueryDefinition::extendBinding(const std::string & fieldName) {
73  m_bindList.extend<T>( fieldName );
74  }
75 
76  template<typename T>
77  void QueryDefinition::setBoundValue(const std::string & fieldName, const T & value) {
78  m_bindList[fieldName].setValue(value);
79  m_bound.insert(fieldName);
80  }
81 
83 
84  void stringToPtree( const std::string & json_string, boost::property_tree::ptree & pt );
85 
94  void writeRawFile(const coral::Blob & data, const std::string & outFileName);
95 
104  void writeRawFile(const std::string & data, const std::string & outFileName);
105 
106 }
107 
108 #endif
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
TrigConf::QueryDefinition::m_condition
std::string m_condition
Definition: TrigDBHelper.h:59
test_pyathena.pt
pt
Definition: test_pyathena.py:11
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
athena.value
value
Definition: athena.py:124
MsgStream.h
MsgStream for TrigConf classes.
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::QueryDefinition
Definition: TrigDBHelper.h:30
TrigConf::QueryDefinition::setDataName
void setDataName(const std::string &dataName)
Definition: TrigDBHelper.h:49
TrigConf::QueryDefinition::extendOutput
void extendOutput(const std::string &fieldName)
Definition: TrigDBHelper.h:67
TrigConf::QueryDefinition::setBoundValue
void setBoundValue(const std::string &fieldName, const T &value)
Definition: TrigDBHelper.h:77
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
TrigConf::writeRawFile
void writeRawFile(const coral::Blob &data, const std::string &outFileName)
write coral data blob to file
Definition: TrigDBHelper.cxx:72
taskman.fieldName
fieldName
Definition: taskman.py:489
TrigConf::QueryDefinition::m_attList
coral::AttributeList m_attList
Definition: TrigDBHelper.h:60
TrigConf::QueryDefinition::createQuery
std::unique_ptr< coral::IQuery > createQuery(coral::ISessionProxy *session)
Definition: TrigDBHelper.cxx:13
TrigConf::QueryDefinition::m_bindList
coral::AttributeList m_bindList
Definition: TrigDBHelper.h:61
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
TrigConf::stringToPtree
void stringToPtree(const std::string &json_string, boost::property_tree::ptree &pt)
Definition: TrigDBHelper.cxx:65
dumpNswErrorDb.outFileName
string outFileName
Definition: dumpNswErrorDb.py:131
python.ext.table_printer.table
list table
Definition: table_printer.py:78
TrigConf::QueryDefinition::extendBinding
void extendBinding(const std::string &fieldName)
Definition: TrigDBHelper.h:72
TrigConf::QueryDefinition::extendCondition
void extendCondition(const std::string &condext)
Definition: TrigDBHelper.cxx:50
TrigConf::QueryDefinition::m_tables
std::vector< std::pair< std::string, std::string > > m_tables
Definition: TrigDBHelper.h:58
TrigConf::QueryDefinition::m_dataName
std::string m_dataName
Definition: TrigDBHelper.h:62
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:63
TrigConf::QueryDefinition::dataName
const std::string & dataName()
Definition: TrigDBHelper.h:53
TrigConf::QueryDefinition::addToTableList
void addToTableList(const std::string &table, const std::string &table_short="")
Definition: TrigDBHelper.cxx:44
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:95