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++) {
119 return methods[
name] =
Method(fun,
object, cmd);
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);
141 if ( properties.find(command->
GetCommandName()) != properties.end()) {
159 if ( properties.find(command->
GetCommandName()) != properties.end()) {
163 else if (methods.find(command->
GetCommandName()) != methods.end()) {
186 #ifdef G4MULTITHREADED
189 ed<<
"G4GenericMessenger::Command::SetUnit() is thread-unsafe and should not be used\n"
190 <<
"in multi-threaded mode. For your command <"<<cmdpath<<
">, use\n"
191 <<
" DeclarePropertyWithUnit(const G4String& name, const G4String& defaultUnit,\n"
192 <<
" const G4AnyType& variable, const G4String& doc)\n"
194 <<
" DeclareMethodWithUnit(const G4String& name, const G4String& defaultUnit,\n"
195 <<
" const G4AnyType& variable, const G4String& doc)\n"
196 <<
"to define a command with a unit <"<<unit<<
">.";
197 if(spec!=
UnitDefault) { ed<<
"\nPlease use a default unit instead of unit category."; }
204 std::vector<G4String> guidance;
212 if (*
type ==
typeid(
float) || *
type ==
typeid(
double) ) {
226 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
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void SetOmittable(G4bool om)
void SetParameterCandidates(const char *theString)
const std::type_info * type
for(Int_t i=0;i< nentries;i++)
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
Declare Methods.
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
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)
REAL *8 function var(A, B, C, D)
std::string ToString() const
const G4ParticleDefinition const G4Material *G4double range
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
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
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)
G4GLOB_DLL std::ostream G4cerr
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)