ATLAS Offline Software
Loading...
Searching...
No Matches
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
29namespace 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
82 void blobToPtree( const coral::Blob & blob, boost::property_tree::ptree & pt );
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
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
MsgStream for TrigConf classes.
std::vector< std::pair< std::string, std::string > > m_tables
std::unique_ptr< coral::IQuery > createQuery(coral::ISessionProxy *session)
void extendBinding(const std::string &fieldName)
const std::string & dataName()
coral::AttributeList m_bindList
void setBoundValue(const std::string &fieldName, const T &value)
void extendCondition(const std::string &condext)
void extendOutput(const std::string &fieldName)
std::set< std::string > m_bound
void addToTableList(const std::string &table, const std::string &table_short="")
coral::AttributeList m_attList
void setDataName(const std::string &dataName)
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
void stringToPtree(const std::string &json_string, boost::property_tree::ptree &pt)
void writeRawFile(const coral::Blob &data, const std::string &outFileName)
write coral data blob to file
void blobToPtree(const coral::Blob &blob, boost::property_tree::ptree &pt)