Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
intercoms
include
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
42
class
G4UIdirectory
;
43
45
46
class
G4GenericMessenger
:
public
G4UImessenger
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
{
60
enum
UnitSpec
{
UnitCategory
,
UnitDefault
};
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
;}
65
Command
&
SetStates
(
G4ApplicationState
s0
,
G4ApplicationState
s1) {command->
AvailableForStates
(s0, s1);
return
*
this
;}
66
Command
&
SetStates
(
G4ApplicationState
s0
,
G4ApplicationState
s1,
G4ApplicationState
s2){command->
AvailableForStates
(s0,s1,s2);
return
*
this
;}
67
Command
&
SetStates
(
G4ApplicationState
s0
,
G4ApplicationState
s1,
G4ApplicationState
s2,
G4ApplicationState
s3) {command->
AvailableForStates
(s0,s1,s2,s3);
return
*
this
;}
68
Command
&
SetStates
(
G4ApplicationState
s0
,
G4ApplicationState
s1,
G4ApplicationState
s2,
G4ApplicationState
s3,
G4ApplicationState
s4) {command->
AvailableForStates
(s0,s1,s2,s3,s4);
return
*
this
;}
69
Command
&
SetRange
(
const
G4String
& range) {command->
SetRange
(range.c_str());
return
*
this
;}
70
Command
&
SetGuidance
(
const
G4String
&
s
) { command->
SetGuidance
(s);
return
*
this
; }
71
Command
&
SetUnit
(
const
G4String
&,
UnitSpec
=
UnitDefault
);
72
Command
&
SetUnitCategory
(
const
G4String
& u) {
return
SetUnit
(u,
UnitCategory
);}
73
Command
&
SetDefaultUnit
(
const
G4String
& u) {
return
SetUnit
(u,
UnitDefault
);}
74
Command
&
SetParameterName
(
const
G4String
&,
G4bool
,
G4bool
=
false
);
75
Command
&
SetDefaultValue
(
const
G4String
&);
76
Command
&
SetCandidates
(
const
G4String
&);
77
78
G4UIcommand
*
command
;
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) {}
83
Property
() {}
84
G4AnyType
variable
;
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) {}
89
G4AnyMethod
method
;
90
void
*
object
;
91
};
92
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
101
private
:
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
Generated on Sat May 25 2013 14:33:19 for Geant4 by
1.8.4