GCC Code Coverage Report


Directory: ./
File: src/iguana/services/RCDBReader.h
Date: 2025-01-06 17:10:42
Exec Total Coverage
Lines: 0 0 100.0%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec Source
1 #pragma once
2
3 #include "Object.h"
4 #include <mutex>
5
6 #ifdef USE_RCDB
7 #include <RCDB/Connection.h>
8 #endif
9
10 namespace iguana {
11
12 /// @brief RCDB reader
13 ///
14 /// This class interfaces to the RCDB. The database connection path is chosen from one of the following, in order:
15 /// - The global variable `iguana::GlobalRcdbUrl`; by default this is not set to any value (its type is `iguana::GlobalParam`)
16 /// - The environment variable `RCDB_CONNECTION` (which is likely set if you are on `ifarm`)
17 /// - A default URL, which will be printed in a warning; see `iguana::RCDBReader::m_default_url`
18 ///
19 /// RCDB will automatically use `mariadb` / `mysql` or `sqlite`, depending on the above RCDB database path,
20 /// and whether you have satisfied the dependencies.
21 class RCDBReader : public Object
22 {
23
24 public:
25
26 /// @param name the name of this reader
27 /// @param lev the log level
28 RCDBReader(std::string_view name = "rcdb", Logger::Level lev = Logger::DEFAULT_LEVEL);
29
30 /// @param runnum run number
31 /// @returns the beam energy in GeV
32 double GetBeamEnergy(int const runnum);
33
34 protected:
35
36 /// @brief default RCDB URL, used as a last resort
37 std::string const m_default_url = "mysql://rcdb@clasdb.jlab.org/rcdb";
38
39 private:
40
41 std::string m_url;
42 std::once_flag m_error_once;
43
44 #ifdef USE_RCDB
45 std::unique_ptr<rcdb::Connection> m_rcdb_connection;
46 #endif
47
48 };
49 }
50