Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4GenericMessenger::Command Struct Reference

#include <G4GenericMessenger.hh>

Inheritance diagram for G4GenericMessenger::Command:
Collaboration diagram for G4GenericMessenger::Command:

Public Types

enum  UnitSpec { UnitCategory, UnitDefault }
 

Public Member Functions

 Command (G4UIcommand *cmd, const std::type_info &ti)
 
 Command ()
 
Command & SetStates (G4ApplicationState s0)
 
Command & SetStates (G4ApplicationState s0, G4ApplicationState s1)
 
Command & SetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2)
 
Command & SetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3)
 
Command & SetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4)
 
Command & SetRange (const G4String &range)
 
Command & SetGuidance (const G4String &s0)
 
Command & SetUnit (const G4String &, UnitSpec=UnitDefault)
 
Command & SetUnitCategory (const G4String &u)
 
Command & SetDefaultUnit (const G4String &u)
 
Command & SetParameterName (const G4String &, G4bool, G4bool=false)
 
Command & SetDefaultValue (const G4String &)
 
Command & SetCandidates (const G4String &)
 
Command & SetToBeBroadcasted (G4bool s0)
 
Command & SetToBeFlushed (G4bool s0)
 
Command & SetWorkerThreadOnly (G4bool s0)
 

Public Attributes

G4UIcommand * command
 
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 247 of file G4GenericMessenger.cc.

247  {
248  G4UIparameter * theParam = command->GetParameter(0);
249  theParam->SetParameterCandidates(candList);
250  return *this;
251 }
void SetParameterCandidates(const char *theString)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145

Here is the call graph for this function:

Here is the caller graph for this function:

Command& G4GenericMessenger::Command::SetDefaultUnit ( const G4String &  u)
inline

Definition at line 73 of file G4GenericMessenger.hh.

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

Here is the call graph for this function:

G4GenericMessenger::Command & G4GenericMessenger::Command::SetDefaultValue ( const G4String &  defVal)

Definition at line 253 of file G4GenericMessenger.cc.

253  {
254  G4UIparameter * theParam = command->GetParameter(0);
255  theParam->SetDefaultValue(defVal);
256  return *this;
257 }
void SetDefaultValue(const char *theDefaultValue)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145

Here is the call graph for this function:

Here is the caller graph for this function:

Command& G4GenericMessenger::Command::SetGuidance ( const G4String &  s0)
inline

Definition at line 70 of file G4GenericMessenger.hh.

70 { command->SetGuidance(s0); return *this; }
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161

Here is the call graph for this function:

G4GenericMessenger::Command & G4GenericMessenger::Command::SetParameterName ( const G4String &  name,
G4bool  omittable,
G4bool  currentAsDefault = false 
)

Definition at line 239 of file G4GenericMessenger.cc.

239  {
240  G4UIparameter* theParam = command->GetParameter(0);
241  theParam->SetParameterName(name);
242  theParam->SetOmittable(omittable);
243  theParam->SetCurrentAsDefault(currentAsDefault);
244  return *this;
245 }
void SetOmittable(G4bool om)
void SetParameterName(const char *theName)
void SetCurrentAsDefault(G4bool val)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145

Here is the call graph for this function:

Here is the caller graph for this function:

Command& G4GenericMessenger::Command::SetRange ( const G4String &  range)
inline

Definition at line 69 of file G4GenericMessenger.hh.

69 {command->SetRange(range.c_str()); return *this;}
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125

Here is the call graph for this function:

Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0)
inline

Definition at line 64 of file G4GenericMessenger.hh.

64 {command->AvailableForStates(s0); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:240

Here is the call graph for this function:

Here is the caller graph for this function:

Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1 
)
inline

Definition at line 65 of file G4GenericMessenger.hh.

65 {command->AvailableForStates(s0, s1); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:240

Here is the call graph for this function:

Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2 
)
inline

Definition at line 66 of file G4GenericMessenger.hh.

66 {command->AvailableForStates(s0,s1,s2); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:240

Here is the call graph for this function:

Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3 
)
inline

Definition at line 67 of file G4GenericMessenger.hh.

67 {command->AvailableForStates(s0,s1,s2,s3); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:240

Here is the call graph for this function:

Command& G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3,
G4ApplicationState  s4 
)
inline

Definition at line 68 of file G4GenericMessenger.hh.

68 {command->AvailableForStates(s0,s1,s2,s3,s4); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:240

Here is the call graph for this function:

Command& G4GenericMessenger::Command::SetToBeBroadcasted ( G4bool  s0)
inline

Definition at line 77 of file G4GenericMessenger.hh.

77 { command->SetToBeBroadcasted(s0); return *this; }
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:184

Here is the call graph for this function:

Command& G4GenericMessenger::Command::SetToBeFlushed ( G4bool  s0)
inline

Definition at line 78 of file G4GenericMessenger.hh.

78 { command->SetToBeFlushed(s0); return *this; }
void SetToBeFlushed(G4bool val)
Definition: G4UIcommand.hh:188

Here is the call graph for this function:

G4GenericMessenger::Command & G4GenericMessenger::Command::SetUnit ( const G4String &  unit,
UnitSpec  spec = UnitDefault 
)

Definition at line 186 of file G4GenericMessenger.cc.

186  {
187  // Change the type of command (unfortunatelly this is done a posteriory)
188  // We need to delete the old command before creating the new one and therefore we need to recover the information
189  // before the deletetion
190 #ifdef G4MULTITHREADED
191  G4String cmdpath = command->GetCommandPath();
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"
197  <<"or\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."; }
202  G4Exception("G4GenericMessenger::Command::SetUnit()","Intercom70001",FatalException,ed);
203  return *this;
204 #else
205  G4String cmdpath = command->GetCommandPath();
206  G4UImessenger* messenger = command->GetMessenger();
207  G4String range = command->GetRange();
208  std::vector<G4String> guidance;
209  G4String par_name = command->GetParameter(0)->GetParameterName();
210  bool par_omitable = command->GetParameter(0)->IsOmittable();
211  for (G4int i = 0; i < command->GetGuidanceEntries(); i++) guidance.push_back(command->GetGuidanceLine(i));
212  // Before deleting the command we need to add a fake one to avoid deleting the directory entry and with its guidance
213  G4UIcommand tmp((cmdpath+"_tmp").c_str(), messenger);
214  delete command;
215 
216  if (*type == typeid(float) || *type == typeid(double) ) {
217  G4UIcmdWithADoubleAndUnit* cmd_t = new G4UIcmdWithADoubleAndUnit(cmdpath, messenger);
218  if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
219  else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
220  cmd_t->SetParameterName(par_name, par_omitable);
221  command = cmd_t;
222  }
223  else if (*type == typeid(G4ThreeVector)) {
224  G4UIcmdWith3VectorAndUnit* cmd_t = new G4UIcmdWith3VectorAndUnit(cmdpath, messenger);
225  if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
226  else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
227  command = cmd_t;
228  }
229  else {
230  G4cerr << "Only parameters of type <double> or <float> can be associated with units" << G4endl;
231  return *this;
232  }
233  for (size_t i = 0; i < guidance.size(); i++) command->SetGuidance(guidance[i]);
234  command->SetRange(range);
235  return *this;
236 #endif
237 }
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

Here is the call graph for this function:

Here is the caller graph for this function:

Command& G4GenericMessenger::Command::SetUnitCategory ( const G4String &  u)
inline

Definition at line 72 of file G4GenericMessenger.hh.

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

Here is the call graph for this function:

Command& G4GenericMessenger::Command::SetWorkerThreadOnly ( G4bool  s0)
inline

Definition at line 79 of file G4GenericMessenger.hh.

79 { command->SetWorkerThreadOnly(s0); return *this; }
void SetWorkerThreadOnly(G4bool val=true)
Definition: G4UIcommand.hh:192

Here is the call graph for this function:

Member Data Documentation

G4UIcommand* G4GenericMessenger::Command::command

Definition at line 81 of file G4GenericMessenger.hh.

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

Definition at line 82 of file G4GenericMessenger.hh.


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