15bool GSystemSQLiteFactory::table_exists(sqlite3* db,
const char* name) {
16 sqlite3_stmt* st =
nullptr;
17 const char* sql =
"SELECT 1 FROM sqlite_master WHERE type='table' AND name=? LIMIT 1";
18 if (sqlite3_prepare_v2(db, sql, -1, &st,
nullptr) != SQLITE_OK)
return false;
19 sqlite3_bind_text(st, 1, name, -1, SQLITE_TRANSIENT);
20 bool exists = (sqlite3_step(st) == SQLITE_ROW);
26void GSystemSQLiteFactory::initialize_sqlite_db(
GSystem* system) {
31 system_name = system->
getName();
36 if (dbhost ==
"na") { dbhost = system->
get_dbhost(); }
37 log->
info(1,
"GSystemSQLiteFactory: dbhost set to <", dbhost,
">");
40 std::vector<std::string> dirs = {
49 if (sqlite3_open_v2(dbPath.value().c_str(), &db, SQLITE_OPEN_READONLY,
nullptr) != SQLITE_OK) {
54 log->
info(1,
"Opened database: " + dbhost,
" found at ", dbPath.value());
62void GSystemSQLiteFactory::closeSystem() {
66 log->
info(1,
"Closing sqlite database >", dbhost,
"<");
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
std::vector< std::string > possibleLocationOfFiles
List of candidate directories used by file-based factories.
Represents a single detector system (e.g., calorimeter, tracker).
std::string getVariation() const
std::string getName() const
std::string get_dbhost() const
Conventions and shared constants for the detector-system module.
#define ROOTWORLDGVOLUMENAME
Canonical name for the ROOT/world gvolume entry.
#define ERR_GSETUPFILENOTOFOUND
std::filesystem::path gemc_root()
std::optional< std::string > searchForFileInLocations(const std::vector< std::string > &locations, std::string_view filename)