Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Data Fields
G4GenericMessenger::Command Struct Reference

#include <G4GenericMessenger.hh>

Inheritance diagram for G4GenericMessenger::Command:
G4GenericMessenger::Method G4GenericMessenger::Property

Public Types

enum  UnitSpec { UnitCategory, UnitDefault }
 

Public Member Functions

 Command (G4UIcommand *cmd, const std::type_info &ti)
 
 Command ()
 
CommandSetStates (G4ApplicationState s0)
 
CommandSetStates (G4ApplicationState s0, G4ApplicationState s1)
 
CommandSetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2)
 
CommandSetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3)
 
CommandSetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4)
 
CommandSetRange (const G4String &range)
 
CommandSetGuidance (const G4String &s)
 
CommandSetUnit (const G4String &, UnitSpec=UnitDefault)
 
CommandSetUnitCategory (const G4String &u)
 
CommandSetDefaultUnit (const G4String &u)
 
CommandSetParameterName (const G4String &, G4bool, G4bool=false)
 
CommandSetDefaultValue (const G4String &)
 
CommandSetCandidates (const G4String &)
 

Data Fields

G4UIcommandcommand
 
const std::type_info * type
 

Detailed Description

Definition at line 59 of file G4GenericMessenger.hh.

Member Enumeration Documentation

Constructor & Destructor Documentation

G4GenericMessenger::Command::Command ( G4UIcommand cmd,
const std::type_info &  ti 
)
inline

Definition at line 61 of file G4GenericMessenger.hh.

61 : command(cmd), type(&ti) {}
const std::type_info * type
G4GenericMessenger::Command::Command ( )
inline

Definition at line 62 of file G4GenericMessenger.hh.

62 : command(0), type(0) {}
const std::type_info * type

Member Function Documentation

G4GenericMessenger::Command & G4GenericMessenger::Command::SetCandidates ( const G4String candList)

Definition at line 243 of file G4GenericMessenger.cc.

References G4UIparameter::SetParameterCandidates().

243  {
244  G4UIparameter * theParam = command->GetParameter(0);
245  theParam->SetParameterCandidates(candList);
246  return *this;
247 }
void SetParameterCandidates(const char *theString)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
Command& G4GenericMessenger::Command::SetDefaultUnit ( const G4String u)
inline

Definition at line 73 of file G4GenericMessenger.hh.

References SetUnit(), and UnitDefault.

73 {return SetUnit(u, UnitDefault);}
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)
G4GenericMessenger::Command & G4GenericMessenger::Command::SetDefaultValue ( const G4String defVal)

Definition at line 249 of file G4GenericMessenger.cc.

References G4UIparameter::SetDefaultValue().

249  {
250  G4UIparameter * theParam = command->GetParameter(0);
251  theParam->SetDefaultValue(defVal);
252  return *this;
253 }
void SetDefaultValue(const char *theDefaultValue)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
Command& G4GenericMessenger::Command::SetGuidance ( const G4String s)
inline

Definition at line 70 of file G4GenericMessenger.hh.

References G4UIcommand::SetGuidance().

70 { command->SetGuidance(s); return *this; }
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
G4GenericMessenger::Command & G4GenericMessenger::Command::SetParameterName ( const G4String name,
G4bool  omittable,
G4bool  currentAsDefault = false 
)

Definition at line 235 of file G4GenericMessenger.cc.

References G4UIparameter::SetCurrentAsDefault(), G4UIparameter::SetOmittable(), and G4UIparameter::SetParameterName().

235  {
236  G4UIparameter* theParam = command->GetParameter(0);
237  theParam->SetParameterName(name);
238  theParam->SetOmittable(omittable);
239  theParam->SetCurrentAsDefault(currentAsDefault);
240  return *this;
241 }
void SetOmittable(G4bool om)
void SetParameterName(const char *theName)
void SetCurrentAsDefault(G4bool val)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
Command& G4GenericMessenger::Command::SetRange ( const G4String range)
inline

Definition at line 69 of file G4GenericMessenger.hh.

References G4UIcommand::SetRange().

Referenced by Lesson1Wx.Counter::__init__(), and Lesson2Wx.Counter::__init__().

69 {command->SetRange(range.c_str()); return *this;}
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0)
inline

Definition at line 64 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates().

64 {command->AvailableForStates(s0); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1 
)
inline

Definition at line 65 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates().

65 {command->AvailableForStates(s0, s1); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2 
)
inline

Definition at line 66 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates().

66 {command->AvailableForStates(s0,s1,s2); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3 
)
inline

Definition at line 67 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates().

67 {command->AvailableForStates(s0,s1,s2,s3); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3,
G4ApplicationState  s4 
)
inline

Definition at line 68 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates().

68 {command->AvailableForStates(s0,s1,s2,s3,s4); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
G4GenericMessenger::Command & G4GenericMessenger::Command::SetUnit ( const G4String unit,
UnitSpec  spec = UnitDefault 
)

Definition at line 182 of file G4GenericMessenger.cc.

References command, FatalException, G4cerr, G4endl, G4Exception(), G4UIcommand::GetCommandPath(), G4UIcommand::GetGuidanceEntries(), G4UIcommand::GetGuidanceLine(), G4UIcommand::GetMessenger(), G4UIcommand::GetParameter(), G4UIparameter::GetParameterName(), G4UIcommand::GetRange(), G4UIparameter::IsOmittable(), G4UIcmdWithADoubleAndUnit::SetDefaultUnit(), G4UIcmdWith3VectorAndUnit::SetDefaultUnit(), G4UIcommand::SetGuidance(), G4UIcmdWithADoubleAndUnit::SetParameterName(), G4UIcommand::SetRange(), G4UIcmdWithADoubleAndUnit::SetUnitCategory(), G4UIcmdWith3VectorAndUnit::SetUnitCategory(), type, UnitCategory, and UnitDefault.

Referenced by SetDefaultUnit(), and SetUnitCategory().

182  {
183  // Change the type of command (unfortunatelly this is done a posteriory)
184  // We need to delete the old command before creating the new one and therefore we need to recover the information
185  // before the deletetion
186 #ifdef G4MULTITHREADED
187  G4String cmdpath = command->GetCommandPath();
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"
193  <<"or\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."; }
198  G4Exception("G4GenericMessenger::Command::SetUnit()","Intercom70001",FatalException,ed);
199  return *this;
200 #else
201  G4String cmdpath = command->GetCommandPath();
202  G4UImessenger* messenger = command->GetMessenger();
203  G4String range = command->GetRange();
204  std::vector<G4String> guidance;
205  G4String par_name = command->GetParameter(0)->GetParameterName();
206  bool par_omitable = command->GetParameter(0)->IsOmittable();
207  for (G4int i = 0; i < command->GetGuidanceEntries(); i++) guidance.push_back(command->GetGuidanceLine(i));
208  // Before deleting the command we need to add a fake one to avoid deleting the directory entry and with its guidance
209  G4UIcommand tmp((cmdpath+"_tmp").c_str(), messenger);
210  delete command;
211 
212  if (*type == typeid(float) || *type == typeid(double) ) {
213  G4UIcmdWithADoubleAndUnit* cmd_t = new G4UIcmdWithADoubleAndUnit(cmdpath, messenger);
214  if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
215  else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
216  cmd_t->SetParameterName(par_name, par_omitable);
217  command = cmd_t;
218  }
219  else if (*type == typeid(G4ThreeVector)) {
220  G4UIcmdWith3VectorAndUnit* cmd_t = new G4UIcmdWith3VectorAndUnit(cmdpath, messenger);
221  if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
222  else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
223  command = cmd_t;
224  }
225  else {
226  G4cerr << "Only parameters of type <double> or <float> can be associated with units" << G4endl;
227  return *this;
228  }
229  for (size_t i = 0; i < guidance.size(); i++) command->SetGuidance(guidance[i]);
230  command->SetRange(range);
231  return *this;
232 #endif
233 }
const G4String & GetRange() const
Definition: G4UIcommand.hh:133
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const std::type_info * type
G4String GetParameterName() const
void SetDefaultUnit(const char *defUnit)
void SetUnitCategory(const char *unitCategory)
void SetUnitCategory(const char *unitCategory)
int G4int
Definition: G4Types.hh:78
const G4String & GetGuidanceLine(G4int i) const
Definition: G4UIcommand.hh:137
G4bool IsOmittable() const
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:139
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetDefaultUnit(const char *defUnit)
G4UImessenger * GetMessenger() const
Definition: G4UIcommand.hh:149
#define G4endl
Definition: G4ios.hh:61
G4int GetGuidanceEntries() const
Definition: G4UIcommand.hh:135
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4GLOB_DLL std::ostream G4cerr
Command& G4GenericMessenger::Command::SetUnitCategory ( const G4String u)
inline

Definition at line 72 of file G4GenericMessenger.hh.

References SetUnit(), and UnitCategory.

72 {return SetUnit(u, UnitCategory);}
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)

Field Documentation

G4UIcommand* G4GenericMessenger::Command::command

Definition at line 78 of file G4GenericMessenger.hh.

Referenced by SetUnit().

const std::type_info* G4GenericMessenger::Command::type

Definition at line 79 of file G4GenericMessenger.hh.

Referenced by SetUnit().


The documentation for this struct was generated from the following files: