Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GenericMessenger.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4UImessenger.hh,v 1.9 2006-06-29 19:08:19 gunter Exp $
28//
29
30#ifndef G4GenericMessenger_h
31#define G4GenericMmessenger_h 1
32
33#include "G4UImessenger.hh"
34#include "G4UIcommand.hh"
35#include "G4AnyType.hh"
36#include "G4AnyMethod.hh"
37#include "G4ApplicationState.hh"
38
39#include <map>
40#include <vector>
41
42class G4UIdirectory;
43
44/// This class is generic messenger.
45
47{
48public:
49 /// Contructor
50 G4GenericMessenger(void* obj, const G4String& dir = "", const G4String& doc = "");
51 /// Destructor
52 virtual ~G4GenericMessenger();
53 /// The concrete, but generic implementation of this method.
54 virtual G4String GetCurrentValue(G4UIcommand* command);
55 /// The concrete, generic implementation of this method converts the string "newValue" to action.
56 virtual void SetNewValue(G4UIcommand* command, G4String newValue);
57
58public:
59 struct Command {
61 Command(G4UIcommand* cmd, const std::type_info& ti) : command(cmd), type(&ti) {}
62 Command() : command(0), type(0) {}
63 // Command& operator =(const Command& rhs) { command = rhs.command; type = rhs.type; }
69 Command& SetRange(const G4String& range) {command->SetRange(range.c_str()); return *this;}
70 Command& SetGuidance(const G4String& s) { command->SetGuidance(s); return *this; }
77
79 const std::type_info* type;
80 };
81 struct Property : public Command {
82 Property(const G4AnyType& var, G4UIcommand* cmd) : Command(cmd, var.TypeInfo()) , variable(var) {}
85 };
86 struct Method : public Command {
87 Method(const G4AnyMethod& fun, void* obj, G4UIcommand* cmd) : Command(cmd, fun.ArgType()), method(fun), object(obj) {}
88 Method() : object(0) {}
90 void* object;
91 };
92
93 ///Declare Methods
94 //Command& DeclarePropertyWithUnit(const G4String& name, const G4Any& variable, const G4String& unit, const G4String& doc = "");
95 Command& DeclareProperty(const G4String& name, const G4AnyType& variable, const G4String& doc = "");
96 Command& DeclareMethod(const G4String& name, const G4AnyMethod& fun, const G4String& doc = "");
97 //Command& DeclareMethodWithUnit(const G4String& name, const G4AnyFunc& fun, const G4String& unit, const G4String& doc = "");
98 void SetDirectory(const G4String& dir) {directory = dir;}
99 void SetGuidance(const G4String& s);
100
101private:
102 std::map<G4String, Property> properties;
103 std::map<G4String, Method> methods;
104 G4UIdirectory* dircmd;
105 G4String directory;
106 void* object;
107};
108
109
110#endif
111
G4ApplicationState
bool G4bool
Definition: G4Types.hh:67
This class is generic messenger.
Command & DeclareMethod(const G4String &name, const G4AnyMethod &fun, const G4String &doc="")
void SetGuidance(const G4String &s)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
The concrete, generic implementation of this method converts the string "newValue" to action.
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
Declare Methods.
virtual G4String GetCurrentValue(G4UIcommand *command)
The concrete, but generic implementation of this method.
virtual ~G4GenericMessenger()
Destructor.
void SetDirectory(const G4String &dir)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:219
Command & SetUnitCategory(const G4String &u)
Command & SetParameterName(const G4String &, G4bool, G4bool=false)
Command & SetStates(G4ApplicationState s0)
Command & SetDefaultUnit(const G4String &u)
Command & SetRange(const G4String &range)
Command & SetGuidance(const G4String &s)
Command & SetCandidates(const G4String &)
Command & SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2)
Command & SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4)
Command & SetDefaultValue(const G4String &)
const std::type_info * type
Command(G4UIcommand *cmd, const std::type_info &ti)
Command & SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3)
Command & SetStates(G4ApplicationState s0, G4ApplicationState s1)
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)
Method(const G4AnyMethod &fun, void *obj, G4UIcommand *cmd)
Property(const G4AnyType &var, G4UIcommand *cmd)