46 virtual const char*
what()
const throw()
48 return "G4InvalidUICommand: command does not exist or is of invalid type";
60 std::size_t pos = dir.find_last_of(
'/', dir.size() - 2);
61 while(pos != 0 && pos != std::string::npos)
65 guidance += dir.substr(1, pos - 1);
67 pos = dir.find_last_of(
'/', pos - 1);
76 for(
auto i = properties.cbegin(); i != properties.cend(); ++i)
77 delete i->second.command;
78 for(
auto i = methods.cbegin(); i != methods.cend(); ++i)
79 delete i->second.command;
85 G4String fullpath = directory + name;
91 var.
TypeInfo() ==
typeid(
unsigned int) ||
92 var.
TypeInfo() ==
typeid(
unsigned long))
96 else if(var.
TypeInfo() ==
typeid(
bool))
103 return properties[name] =
Property(var, cmd);
115 G4String fullpath = directory + name;
121 ->SetParameterName(
"value",
false,
false);
128 ->SetParameterName(
"valueX",
"valueY",
"valueZ",
false,
false);
134 return properties[name] =
Property(var, cmd);
140 G4String fullpath = directory + name;
144 for(std::size_t i = 0; i < fun.
NArg(); ++i)
148 return methods[name] =
Method(fun,
object, cmd);
155 G4String fullpath = directory + name;
159 ed <<
"G4GenericMessenger::DeclareMethodWithUnit() does not support a "
160 "method that has more than\n"
161 <<
"one arguments (or no argument). Please use "
162 "G4GenericMessenger::DeclareMethod method for\n"
163 <<
"your command <" << fullpath <<
">.";
164 G4Exception(
"G4GenericMessenger::DeclareMethodWithUnit()",
"Intercom70002",
169 ->SetParameterName(
"value",
false,
false);
173 return methods[name] =
Method(fun,
object, cmd);
178 if(properties.find(command->
GetCommandName()) != properties.cend())
183 else if(methods.find(command->
GetCommandName()) != methods.cend())
185 G4cout <<
" GetCurrentValue() is not available for a command defined by "
186 "G4GenericMessenger::DeclareMethod()."
210 if(properties.find(command->
GetCommandName()) != properties.cend())
215 else if(methods.find(command->
GetCommandName()) != methods.cend())
246 ed <<
"G4GenericMessenger::Command::SetUnit() is thread-unsafe and should "
248 <<
"in multi-threaded mode. For your command <" << cmdpath <<
">, use\n"
249 <<
" DeclarePropertyWithUnit(const G4String& name, const G4String& "
251 <<
" const G4AnyType& variable, const G4String& "
254 <<
" DeclareMethodWithUnit(const G4String& name, const G4String& "
256 <<
" const G4AnyType& variable, const G4String& "
258 <<
"to define a command with a unit <" << unit <<
">.";
261 ed <<
"\nPlease use a default unit instead of unit category.";
263 G4Exception(
"G4GenericMessenger::Command::SetUnit()",
"Intercom70001",
271 std::vector<G4String> guidance;
278 G4UIcommand tmp((cmdpath +
"_tmp").c_str(), messenger);
281 if(*
type ==
typeid(
float) || *
type ==
typeid(
double))
304 G4cerr <<
"Only parameters of type <double> or <float> can be associated "
309 for(std::size_t i = 0; i < guidance.size(); ++i)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
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)
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
virtual G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4GenericMessenger()
Command & DeclareMethodWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyMethod &fun, const G4String &doc="")
G4GenericMessenger(void *obj, const G4String &dir="", const G4String &doc="")
Command & DeclarePropertyWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyType &variable, const G4String &doc="")
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)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UImessenger * GetMessenger() const
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
static G4String ConvertToString(G4bool boolVal)
const G4String & GetCommandPath() const
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
std::size_t GetGuidanceEntries() const
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 SetParameterName(const char *pName)
G4bool IsOmittable() const
void SetOmittable(G4bool om)
void SetParameterCandidates(const char *theString)
void SetCurrentAsDefault(G4bool val)
const G4String & GetParameterName() const
G4bool IsMultithreadedApplication()
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)