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++) {
120 return methods[
name] =
Method(fun,
object, cmd);
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);
142 if ( properties.find(command->
GetCommandName()) != properties.end()) {
146 else if ( methods.find(command->
GetCommandName()) != methods.end()) {
147 G4cout<<
" GetCurrentValue() is not available for a command defined by G4GenericMessenger::DeclareMethod()."<<
G4endl;
164 if ( properties.find(command->
GetCommandName()) != properties.end()) {
168 else if (methods.find(command->
GetCommandName()) != methods.end()) {
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;
214 G4UIcommand tmp((cmdpath+
"_tmp").c_str(), messenger);
217 if (*
type ==
typeid(
float) || *
type ==
typeid(
double) ) {
231 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
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)
std::string ToString() const
G4GLOB_DLL std::ostream G4cout
static constexpr double m
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
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const G4String & GetCommandPath() const
void SetGuidance(const G4String &s)
G4bool IsMultithreadedApplication()
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)
static const G4double pos
for(G4int i1=0;i1< theStableOnes.GetNumberOfIsotopes(static_cast< G4int >(anE->GetZ()));i1++)
G4GLOB_DLL std::ostream G4cerr
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)