SQLamarr
The stand-alone ultra-fast simulation option for the LHCb experiment
TemporaryTable.h
1 // (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration.
2 //
3 // This software is distributed under the terms of the GNU General Public
4 // Licence version 3 (GPL Version 3), copied verbatim in the file "LICENCE".
5 //
6 // In applying this licence, CERN does not waive the privileges and immunities
7 // granted to it by virtue of its status as an Intergovernmental Organization
8 // or submit itself to any jurisdiction.
9 
10 
11 #pragma once
12 
13 // STL
14 #include <string>
15 #include <vector>
16 
17 // SQLamarr
18 #include "SQLamarr/BaseSqlInterface.h"
19 #include "SQLamarr/db_functions.h"
20 #include "SQLamarr/Transformer.h"
21 
22 
23 
24 namespace SQLamarr
25 {
54  class TemporaryTable: public BaseSqlInterface, public Transformer
55  {
56  public:
58  TemporaryTable (
59  SQLite3DB& db,
61  const std::string& output_table,
63  const std::vector<std::string>& columns,
65  const std::vector<std::string>& select_statements,
68  bool make_persistent = false
70  // the table "persistent"
71  );
72 
74  TemporaryTable (
75  SQLite3DB& db,
77  const std::string& output_table,
79  const std::vector<std::string>& columns,
81  const std::string& select_statement,
84  bool make_persistent = false
86  // the table "persistent"
87  );
88 
89 
91  void execute () override;
92 
93  private:
94  // Name of the output temporary table
95  const std::string m_output_table;
96 
97  // Name of the output temporary table
98  const std::vector<std::string> m_columns;
99 
100  // Select statement
101  const std::vector<std::string> m_select_statements;
102 
103  private:
104  std::string compose_create_query() const;
105  std::string compose_delete_query() const;
106  std::string compose_insert_query(const std::string& st) const;
107  bool m_make_persistent;
108  };
109 }
std::unique_ptr< sqlite3, void(*)(sqlite3 *)> SQLite3DB
Unique pointer to the sqlite3 connection.
Definition: db_functions.h:19