OMSim
Geant4 for IceCube optical module studies
Loading...
Searching...
No Matches
OMSimUIinterface.hh
Go to the documentation of this file.
1
6#pragma once
7
9#include <G4UImanager.hh>
10
17{
18public:
19 // Public static access for the singleton instance
20 static OMSimUIinterface &getInstance()
21 {
22 static OMSimUIinterface instance;
23 return instance;
24 }
25 static void init();
26 static void shutdown();
34 template <typename... Args>
35 void applyCommand(const std::string &p_command, const Args &...p_args)
36 {
37 std::stringstream stream;
38 stream << p_command;
39 appendToStream(stream, p_args...);
40 log_trace(stream.str().c_str());
41 m_uiManager->ApplyCommand(stream.str());
42 }
43
44 void setUI(G4UImanager *p_ui);
45 void runBeamOn(G4int p_numberOfEvents = -1);
46
47private:
48 G4UImanager *m_uiManager;
49
50 OMSimUIinterface() = default;
51 ~OMSimUIinterface() = default;
52 OMSimUIinterface(const OMSimUIinterface &) = delete; // disable copying
53 OMSimUIinterface &operator=(const OMSimUIinterface &) = delete; // disable assignment
54
55 void appendToStream(std::stringstream &p_stream)
56 {
57 // if no additional arguments, do nothing
58 }
59
66 template <typename T>
67 void appendToStream(std::stringstream &p_stream, const T &p_val)
68 {
69 p_stream << ' ' << p_val;
70 }
71
80 template <typename T, typename... Args>
81 void appendToStream(std::stringstream &p_stream, const T &p_val, const Args &...p_args)
82 {
83 p_stream << ' ' << p_val;
84 appendToStream(p_stream, p_args...);
85 }
86};
87
88inline OMSimUIinterface *g_OMSimUIinterface = nullptr;
Definition of the OMSimCommandArgsTable singleton class, which controls user args.
Singleton interface to Geant4's UI manager.
Definition OMSimUIinterface.hh:17
void appendToStream(std::stringstream &p_stream, const T &p_val)
Append arguments to the command string p_stream.
Definition OMSimUIinterface.hh:67
void appendToStream(std::stringstream &p_stream, const T &p_val, const Args &...p_args)
Append multiple arguments to the command string p_stream.
Definition OMSimUIinterface.hh:81
void applyCommand(const std::string &p_command, const Args &...p_args)
Apply a command to Geant4's UI manager and log it. It accept any number of arguments that are then ap...
Definition OMSimUIinterface.hh:35
void runBeamOn(G4int p_numberOfEvents=-1)
Executes a run with a given number of events.
Definition OMSimUIinterface.cc:39
static void init()
Initializes the global instance of OMSimUIinterface This method is normally called in OMSim::initiali...
Definition OMSimUIinterface.cc:7
static void shutdown()
Deletes the global instance of OMSimUIinterface This method is normally called in the destructor ~OMS...
Definition OMSimUIinterface.cc:19
void setUI(G4UImanager *p_ui)
Set the UI manager for the OMSimUIinterface class.
Definition OMSimUIinterface.cc:29