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';
90 {
return DeclareProperty(name,var,doc); }
116 for (
size_t i = 0; i < fun.
NArg(); i++) {
127 ed<<
"G4GenericMessenger::DeclareMethodWithUnit() does not support a method that has more than\n"
128 <<
"one arguments (or no argument). Please use G4GenericMessenger::DeclareMethod method for\n"
129 <<
"your command <"<<fullpath<<
">.";
136 return methods[
name] =
Method(fun,
object, cmd);
146 G4cout<<
" GetCurrentValue() is not available for a command defined by G4GenericMessenger::DeclareMethod()."<<
G4endl;
190 #ifdef G4MULTITHREADED
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."; }
208 std::vector<G4String> guidance;
213 G4UIcommand tmp((cmdpath+
"_tmp").c_str(), messenger);
216 if (*
type ==
typeid(
float) || *
type ==
typeid(
double) ) {
230 G4cerr <<
"Only parameters of type <double> or <float> can be associated with units" <<
G4endl;
void SetParameter(G4UIparameter *const newParameter)
virtual G4String GetCurrentValue(G4UIcommand *command)
The concrete, but generic implementation of this method.
const G4String & GetRange() const
std::ostringstream G4ExceptionDescription
CLHEP::Hep3Vector G4ThreeVector
void SetOmittable(G4bool om)
void SetParameterCandidates(const char *theString)
const std::type_info * type
std::map< G4String, Method > methods
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
Declare Methods.
This class represents any object method.
G4String GetParameterName() const
void SetDefaultUnit(const char *defUnit)
void SetUnitCategory(const char *unitCategory)
Command & DeclareMethod(const G4String &name, const G4AnyMethod &fun, const G4String &doc="")
void SetDefaultValue(const char *theDefaultValue)
static G4String ConvertToString(G4bool boolVal)
virtual const char * what() const
Command & DeclareMethodWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyMethod &fun, const G4String &doc="")
void SetUnitCategory(const char *unitCategory)
void SetParameterName(const char *theName)
const std::type_info & TypeInfo() const
Query.
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
const G4String & GetGuidanceLine(G4int i) const
static G4double ConvertToDimensionedDouble(const char *st)
void SetCurrentAsDefault(G4bool val)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
The concrete, generic implementation of this method converts the string "newValue" to action...
G4bool IsOmittable() const
Command & SetDefaultValue(const G4String &)
void FromString(const std::string &val)
String conversion.
std::string ToString() const
String conversion.
G4GLOB_DLL std::ostream G4cout
size_t NArg() const
Number of arguments.
G4GenericMessenger(void *obj, const G4String &dir="", const G4String &doc="")
Contructor.
void SetRange(const char *rs)
virtual ~G4GenericMessenger()
Destructor.
void SetGuidance(const char *aGuidance)
G4UIparameter * GetParameter(G4int i) const
std::map< G4String, Property > properties
const G4String & GetCommandPath() const
void SetGuidance(const G4String &s)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const G4String & GetCommandName() const
This class represents any data type.
Command & SetCandidates(const G4String &)
void SetDefaultUnit(const char *defUnit)
G4UImessenger * GetMessenger() const
Command & SetParameterName(const G4String &, G4bool, G4bool=false)
G4int GetGuidanceEntries() const
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
G4GLOB_DLL std::ostream G4cerr
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)