43 virtual const char*
what()
const throw() {
44 return "G4InvalidUICommand: command does not exists or is of invalid type";
52 size_t pos = dir.find_last_of(
'/', dir.size()-2);
53 while(pos != 0 && pos != std::string::npos) {
56 guidance += dir.substr(1,pos-1);
58 pos = dir.find_last_of(
'/', pos-1);
66 for (std::map<G4String, Property>::iterator i =
properties.begin(); i !=
properties.end(); i++)
delete i->second.command;
67 for (std::map<G4String, Method>::iterator i =
methods.begin(); i !=
methods.end(); i++)
delete i->second.command;
78 var.
TypeInfo() ==
typeid(
unsigned int) || var.
TypeInfo() ==
typeid(
unsigned long)) ptype =
'i';
79 else if(var.
TypeInfo() ==
typeid(float) || var.
TypeInfo() ==
typeid(double)) ptype =
'd';
80 else if(var.
TypeInfo() ==
typeid(bool)) ptype =
'b';
91 {
return DeclareProperty(name,var,doc); }
117 for (
size_t i = 0; i < fun.
NArg(); i++) {
128 ed<<
"G4GenericMessenger::DeclareMethodWithUnit() does not support a method that has more than\n"
129 <<
"one arguments (or no argument). Please use G4GenericMessenger::DeclareMethod method for\n"
130 <<
"your command <"<<fullpath<<
">.";
137 return methods[
name] =
Method(fun,
object, cmd);
147 G4cout<<
" GetCurrentValue() is not available for a command defined by G4GenericMessenger::DeclareMethod()."<<
G4endl;
193 ed<<
"G4GenericMessenger::Command::SetUnit() is thread-unsafe and should not be used\n"
194 <<
"in multi-threaded mode. For your command <"<<cmdpath<<
">, use\n"
195 <<
" DeclarePropertyWithUnit(const G4String& name, const G4String& defaultUnit,\n"
196 <<
" const G4AnyType& variable, const G4String& doc)\n"
198 <<
" DeclareMethodWithUnit(const G4String& name, const G4String& defaultUnit,\n"
199 <<
" const G4AnyType& variable, const G4String& doc)\n"
200 <<
"to define a command with a unit <"<<unit<<
">.";
201 if(spec!=
UnitDefault) { ed<<
"\nPlease use a default unit instead of unit category."; }
209 std::vector<G4String> guidance;
217 if (*
type ==
typeid(
float) || *
type ==
typeid(
double) ) {
231 G4cerr <<
"Only parameters of type <double> or <float> can be associated with units" <<
G4endl;
std::string ToString() const
void SetGuidance(const char *aGuidance)
void SetCurrentAsDefault(G4bool val)
CLHEP::Hep3Vector G4ThreeVector
std::ostringstream G4ExceptionDescription
Command & DeclarePropertyWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyType &variable, const G4String &doc="")
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static const G4double pos
void FromString(const std::string &val)
virtual const char * what() const
Command & DeclareMethodWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyMethod &fun, const G4String &doc="")
G4UImessenger * GetMessenger() const
std::map< G4String, Method > methods
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
void SetRange(const char *rs)
Command & SetDefaultValue(const G4String &)
G4int GetGuidanceEntries() const
void SetUnitCategory(const char *unitCategory)
const G4String & GetCommandName() const
Command & DeclareMethod(const G4String &name, const G4AnyMethod &fun, const G4String &doc="")
void SetParameter(G4UIparameter *const newParameter)
void SetDefaultValue(const char *theDefaultValue)
static constexpr double m
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)
const G4ParticleDefinition const G4Material *G4double range
void SetUnitCategory(const char *unitCategory)
G4GenericMessenger(void *obj, const G4String &dir="", const G4String &doc="")
Contructor.
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void SetGuidance(const G4String &s)
virtual ~G4GenericMessenger()
Destructor.
const std::type_info * type
std::map< G4String, Property > properties
const G4String & GetCommandPath() const
G4GLOB_DLL std::ostream G4cerr
Command & SetCandidates(const G4String &)
virtual G4String GetCurrentValue(G4UIcommand *command)
The concrete, but generic implementation of this method.
static G4String ConvertToString(G4bool boolVal)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Command & SetParameterName(const G4String &, G4bool, G4bool=false)
G4bool IsMultithreadedApplication()
void SetParameterName(const char *theName)
const std::type_info & TypeInfo() const
G4bool IsOmittable() const
G4GLOB_DLL std::ostream G4cout
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
The concrete, generic implementation of this method converts the string "newValue" to action...
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
static G4double ConvertToDimensionedDouble(const char *st)
void SetDefaultUnit(const char *defUnit)
void SetParameterCandidates(const char *theString)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetOmittable(G4bool om)
G4String GetParameterName() const
const G4String & GetRange() const
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
Declare Methods.
void SetDefaultUnit(const char *defUnit)