Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4GenericMessenger.hh
이 파일의 문서화 페이지로 가기
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 G4GenericMessenger_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 
42 class G4UIdirectory;
43 
45 
47 {
48 public:
50  G4GenericMessenger(void* obj, const G4String& dir = "", const G4String& doc = "");
52  virtual ~G4GenericMessenger();
54  virtual G4String GetCurrentValue(G4UIcommand* command);
56  virtual void SetNewValue(G4UIcommand* command, G4String newValue);
57 
58 public:
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; }
64  Command& SetStates(G4ApplicationState s0) {command->AvailableForStates(s0); return *this;}
69  Command& SetRange(const G4String& range) {command->SetRange(range.c_str()); return *this;}
70  Command& SetGuidance(const G4String& s0) { command->SetGuidance(s0); return *this; }
74  Command& SetParameterName(const G4String&, G4bool, G4bool =false);
77  Command& SetToBeBroadcasted(G4bool s0) { command->SetToBeBroadcasted(s0); return *this; }
78  Command& SetToBeFlushed(G4bool s0) { command->SetToBeFlushed(s0); return *this; }
79  Command& SetWorkerThreadOnly(G4bool s0) { command->SetWorkerThreadOnly(s0); return *this; }
80 
82  const std::type_info* type;
83  };
84  struct Property : public Command {
85  Property(const G4AnyType& var, G4UIcommand* cmd) : Command(cmd, var.TypeInfo()) , variable(var) {}
86  Property() {}
88  };
89  struct Method : public Command {
90  Method(const G4AnyMethod& fun, void* obj, G4UIcommand* cmd) : Command(cmd, fun.ArgType()), method(fun), object(obj) {}
91  Method() : object(0) {}
93  void* object;
94  };
95 
97  Command& DeclareProperty(const G4String& name, const G4AnyType& variable, const G4String& doc = "");
99  (const G4String& name, const G4String& defaultUnit, const G4AnyType& variable, const G4String& doc = "");
100  Command& DeclareMethod(const G4String& name, const G4AnyMethod& fun, const G4String& doc = "");
102  (const G4String& name, const G4String& defaultUnit, const G4AnyMethod& fun, const G4String& doc = "");
104  void SetGuidance(const G4String& s);
105 
106 private:
107  std::map<G4String, Property> properties;
108  std::map<G4String, Method> methods;
111  void* object;
112 };
113 
114 
115 #endif
116 
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
Method(const G4AnyMethod &fun, void *obj, G4UIcommand *cmd)
const XML_Char * name
Definition: expat.h:151
This class is generic messenger.
Command & DeclarePropertyWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyType &variable, const G4String &doc="")
Command & DeclareMethodWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyMethod &fun, const G4String &doc="")
std::map< G4String, Method > methods
void SetDirectory(const G4String &dir)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
Command & SetDefaultValue(const G4String &)
Command & SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3)
Property(const G4AnyType &var, G4UIcommand *cmd)
Command & DeclareMethod(const G4String &name, const G4AnyMethod &fun, const G4String &doc="")
const XML_Char * s
Definition: expat.h:262
bool G4bool
Definition: G4Types.hh:79
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)
const G4ParticleDefinition const G4Material *G4double range
Command & SetToBeBroadcasted(G4bool s0)
Command & SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2)
Command & SetStates(G4ApplicationState s0)
G4GenericMessenger(void *obj, const G4String &dir="", const G4String &doc="")
Contructor.
void SetGuidance(const G4String &s)
G4UIdirectory * dircmd
virtual ~G4GenericMessenger()
Destructor.
Command & SetRange(const G4String &range)
const std::type_info * type
std::map< G4String, Property > properties
Command & SetCandidates(const G4String &)
virtual G4String GetCurrentValue(G4UIcommand *command)
The concrete, but generic implementation of this method.
Command & SetParameterName(const G4String &, G4bool, G4bool=false)
Command & SetToBeFlushed(G4bool s0)
Command & SetWorkerThreadOnly(G4bool s0)
static int variable(const string &name, double &result, const dic_type &dictionary)
Definition: Evaluator.cc:71
TDirectory * dir
Command & SetUnitCategory(const G4String &u)
void SetWorkerThreadOnly(G4bool val=true)
Definition: G4UIcommand.hh:192
Command & SetStates(G4ApplicationState s0, G4ApplicationState s1)
void SetToBeFlushed(G4bool val)
Definition: G4UIcommand.hh:188
G4ApplicationState
Command(G4UIcommand *cmd, const std::type_info &ti)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
The concrete, generic implementation of this method converts the string &quot;newValue&quot; to action...
Command & SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4)
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:184
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
Declare Methods.
Command & SetGuidance(const G4String &s0)
Command & SetDefaultUnit(const G4String &u)