gsystem
Loading...
Searching...
No Matches
systemFactory.h
Go to the documentation of this file.
1#pragma once
2
3// gemc
4#include "goptions.h"
5#include "gbase.h"
6#include "gutilities.h"
7
8// gsystem
9#include "gsystem_options.h"
10
34class GSystemFactory : public GBase<GSystemFactory>
35{
36public:
37 ~GSystemFactory() override = default;
38
44 explicit GSystemFactory(const std::shared_ptr<GOptions>& g) : GBase(g, GSFACTORY_LOGGER) {
45 }
46
63 void loadSystem(GSystem* system) {
64 log->info(1, "Loading system <", system->getName(), "> using factory <", system->getFactoryName(), ">");
65
66 // Default: allow local execution context to resolve relative paths.
67 possibleLocationOfFiles.emplace_back(".");
68
69 // GEMC installation root is a common fallback location for resources.
70 std::filesystem::path gemcRoot = gutilities::gemc_root();
71 possibleLocationOfFiles.push_back(gemcRoot.string());
72
73 // Some factories interpret dbhost as a directory hint; others interpret it as a filename.
74 possibleLocationOfFiles.push_back(system->get_dbhost());
75
76 // Materials first, then geometry.
77 loadMaterials(system);
78 loadGeometry(system);
79 }
80
89 virtual void closeSystem() { possibleLocationOfFiles.clear(); }
90
91private:
102 virtual void loadMaterials(GSystem* system) = 0;
103
114 virtual void loadGeometry(GSystem* system) = 0;
115
116protected:
118 std::vector<std::string> possibleLocationOfFiles;
119
120public:
129 void addPossibleFileLocation(const std::string& fl) { possibleLocationOfFiles.push_back(fl); }
130};
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
Abstract base class for loading a GSystem from a specific source.
virtual void closeSystem()
Factory cleanup hook.
std::vector< std::string > possibleLocationOfFiles
List of candidate directories used by file-based factories.
void loadSystem(GSystem *system)
Load a system by invoking the concrete factory steps.
void addPossibleFileLocation(const std::string &fl)
Add a candidate directory for file searches.
~GSystemFactory() override=default
GSystemFactory(const std::shared_ptr< GOptions > &g)
Construct the factory with shared configuration.
Represents a single detector system (e.g., calorimeter, tracker).
Definition gsystem.h:32
std::string getFactoryName() const
Definition gsystem.h:109
std::string getName() const
Definition gsystem.h:108
std::string get_dbhost() const
Definition gsystem.h:114
Option definitions and extraction helpers for the gsystem module.
constexpr const char * GSFACTORY_LOGGER
std::filesystem::path gemc_root()