42 virtual const char*
what()
const throw() {
43 return "G4InvalidUICommand: command does not exists or is of invalid type";
51 size_t pos = dir.find_last_of(
'/', dir.size()-2);
52 while(pos != 0 && pos != std::string::npos) {
55 guidance += dir.substr(1,pos-1);
57 pos = dir.find_last_of(
'/', pos-1);
65 for (std::map<G4String, Property>::iterator i = properties.begin(); i != properties.end(); i++)
delete i->second.command;
66 for (std::map<G4String, Method>::iterator i = methods.begin(); i != methods.end(); i++)
delete i->second.command;
77 var.
TypeInfo() ==
typeid(
unsigned int) || var.
TypeInfo() ==
typeid(
unsigned long)) ptype =
'i';
78 else if(var.
TypeInfo() ==
typeid(
float) || var.
TypeInfo() ==
typeid(
double)) ptype =
'd';
79 else if(var.
TypeInfo() ==
typeid(
bool)) ptype =
'b';
83 return properties[name] =
Property(var, cmd);
92 for (
size_t i = 0; i < fun.
NArg(); i++) {
95 return methods[name] =
Method(fun,
object, cmd);
99 if ( properties.find(command->
GetCommandName()) != properties.end()) {
117 if ( properties.find(command->
GetCommandName()) != properties.end()) {
121 else if (methods.find(command->
GetCommandName()) != methods.end()) {
147 std::vector<G4String> guidance;
150 G4UIcommand tmp((cmdpath+
"_tmp").c_str(), messenger);
153 if (*
type ==
typeid(
float) || *
type ==
typeid(
double) ) {
166 G4cerr <<
"Only parameters of type <double> or <float> can be associated with units" <<
G4endl;
G4DLLIMPORT std::ostream G4cerr
void FromString(const std::string &val)
const std::type_info & TypeInfo() const
std::string ToString() const
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.
G4GenericMessenger(void *obj, const G4String &dir="", const G4String &doc="")
Contructor.
virtual const char * what() const
void SetDefaultUnit(const char *defUnit)
void SetUnitCategory(const char *unitCategory)
void SetUnitCategory(const char *unitCategory)
void SetDefaultUnit(const char *defUnit)
G4UImessenger * GetMessenger() const
const G4String & GetGuidanceLine(G4int i) const
G4int GetGuidanceEntries() const
static G4String ConvertToString(G4bool boolVal)
const G4String & GetCommandPath() const
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
void SetRange(const char *rs)
static G4double ConvertToDimensionedDouble(const char *st)
const G4String & GetCommandName() const
const G4String & GetRange() const
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
void SetDefaultValue(const char *theDefaultValue)
void SetOmittable(G4bool om)
void SetParameterName(const char *theName)
void SetParameterCandidates(const char *theString)
void SetCurrentAsDefault(G4bool val)
Command & SetParameterName(const G4String &, G4bool, G4bool=false)
Command & SetCandidates(const G4String &)
Command & SetDefaultValue(const G4String &)
const std::type_info * type
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)