DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4UIMessenger.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 #ifndef DDG4_GEANT4UIMESSENGER_H
15 #define DDG4_GEANT4UIMESSENGER_H
16 
17 // Framework include files
19 #include <DD4hep/Callback.h>
20 #include <G4UImessenger.hh>
21 #include <G4UIdirectory.hh>
22 
24 namespace dd4hep {
25 
27  namespace sim {
28 
30 
36  public:
37  typedef std::map<G4UIcommand*, std::string> Commands;
38  typedef std::map<G4UIcommand*, Callback> Actions;
39  protected:
41  G4UIdirectory* m_directory;
45  std::string m_name;
47  std::string m_path;
52 
53  public:
55  Geant4UIMessenger(const std::string& name, const std::string& path);
57  virtual ~Geant4UIMessenger();
59  void addCall(const std::string& name, const std::string& description, const Callback& cb, size_t npar=0);
61  template <typename Q, typename R, typename T>
62  void addCall(const std::string& name, const std::string& description, Q* p, R (T::*f)()) {
63  CallbackSequence::checkTypes(typeid(Q), typeid(T), dynamic_cast<T*>(p));
64  addCall(name, description, Callback(p).make(f), 0);
65  }
67  template <typename Q, typename R, typename T, typename A1>
68  void addCall(const std::string& name, const std::string& description, Q* p, R (T::*f)(A1)) {
69  CallbackSequence::checkTypes(typeid(Q), typeid(T), dynamic_cast<T*>(p));
70  addCall(name, description, Callback(p).make(f), 1);
71  }
75  void SetNewValue(G4UIcommand *c, G4String val) override;
77  G4String GetCurrentValue(G4UIcommand *c) override;
78  };
79 
80  } // End namespace sim
81 } // End namespace dd4hep
82 
83 #endif // DDG4_GEANT4UIMESSENGER_H
dd4hep::sim::Geant4UIMessenger::Geant4UIMessenger
Geant4UIMessenger(const std::string &name, const std::string &path)
Initializing constructor.
Definition: Geant4UIMessenger.cpp:46
dd4hep::sim::Geant4UIMessenger::exportProperties
void exportProperties(PropertyManager &mgr)
Export all properties to the Geant4 UI.
Definition: Geant4UIMessenger.cpp:78
dd4hep::sim::Geant4UIMessenger::~Geant4UIMessenger
virtual ~Geant4UIMessenger()
Default destructor.
Definition: Geant4UIMessenger.cpp:54
dd4hep::CallbackSequence::checkTypes
static void checkTypes(const std::type_info &typ1, const std::type_info &typ2, void *test)
Check the compatibility of two typed objects. The test is the result of a dynamic_cast.
Definition: Callback.cpp:19
dd4hep::sim::Geant4UIMessenger::Actions
std::map< G4UIcommand *, Callback > Actions
Definition: Geant4UIMessenger.h:38
dd4hep::sim::Geant4UIMessenger::addCall
void addCall(const std::string &name, const std::string &description, Q *p, R(T::*f)(A1))
Add any callback with ONE parameter to the messenger.
Definition: Geant4UIMessenger.h:68
Callback.h
dd4hep::sim::Geant4UIMessenger::m_path
std::string m_path
Path in the UI hierarchy of this component.
Definition: Geant4UIMessenger.h:47
ComponentProperties.h
G4UImessenger
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:15
dd4hep::sim::Geant4UIMessenger::m_actionCmd
Actions m_actionCmd
Action map.
Definition: Geant4UIMessenger.h:51
dd4hep::Callback
Definition of the generic callback structure for member functions.
Definition: Callback.h:38
dd4hep::sim::Geant4UIMessenger::m_propertyCmd
Commands m_propertyCmd
Property update command map.
Definition: Geant4UIMessenger.h:49
dd4hep::sim::Geant4UIMessenger::Commands
std::map< G4UIcommand *, std::string > Commands
Definition: Geant4UIMessenger.h:37
dd4hep::sim::Geant4UIMessenger::m_properties
PropertyManager * m_properties
Reference to the property manager corresponding to the component.
Definition: Geant4UIMessenger.h:43
dd4hep::sim::Geant4UIMessenger::SetNewValue
void SetNewValue(G4UIcommand *c, G4String val) override
Accept ne property value from Geant4 UI.
Definition: Geant4UIMessenger.cpp:99
dd4hep::PropertyManager
Manager to ease the handling of groups of properties.
Definition: ComponentProperties.h:174
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4UIMessenger::addCall
void addCall(const std::string &name, const std::string &description, const Callback &cb, size_t npar=0)
Add a new callback structure.
Definition: Geant4UIMessenger.cpp:60
dd4hep::sim::Geant4UIMessenger::addCall
void addCall(const std::string &name, const std::string &description, Q *p, R(T::*f)())
Add any callback without parameters to the messenger.
Definition: Geant4UIMessenger.h:62
dd4hep::sim::Geant4UIMessenger::m_name
std::string m_name
Component name.
Definition: Geant4UIMessenger.h:45
dd4hep::sim::Geant4UIMessenger::m_directory
G4UIdirectory * m_directory
The UI directory of this component.
Definition: Geant4UIMessenger.h:41
dd4hep::sim::Geant4UIMessenger::GetCurrentValue
G4String GetCurrentValue(G4UIcommand *c) override
Pass current property value to Geant4 UI.
Definition: Geant4UIMessenger.cpp:87
dd4hep::sim::Geant4UIMessenger
Generic implementation to export properties and actions to the Geant4 command prompt.
Definition: Geant4UIMessenger.h:35