G4GenericMessenger::Command Struct Reference

#include <G4GenericMessenger.hh>

Inheritance diagram for G4GenericMessenger::Command:

G4GenericMessenger::Method G4GenericMessenger::Property

Public Types

 UnitCategory
 UnitDefault
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 &s)
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 &)

Data Fields

G4UIcommand * command
const std::type_info * type

Detailed Description

Definition at line 59 of file G4GenericMessenger.hh.


Member Enumeration Documentation

enum G4GenericMessenger::Command::UnitSpec

Enumerator:
UnitCategory 
UnitDefault 

Definition at line 60 of file G4GenericMessenger.hh.


Constructor & Destructor Documentation

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

Definition at line 61 of file G4GenericMessenger.hh.

00061 : command(cmd), type(&ti) {}

G4GenericMessenger::Command::Command (  )  [inline]

Definition at line 62 of file G4GenericMessenger.hh.

00062 : command(0), type(0) {}


Member Function Documentation

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

Definition at line 182 of file G4GenericMessenger.cc.

References command, G4UIcommand::GetParameter(), and G4UIparameter::SetParameterCandidates().

00182                                                                                             {
00183   G4UIparameter * theParam = command->GetParameter(0);
00184   theParam->SetParameterCandidates(candList);
00185   return *this;
00186 }

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

Definition at line 73 of file G4GenericMessenger.hh.

References SetUnit(), and UnitDefault.

00073 {return SetUnit(u, UnitDefault);}

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

Definition at line 188 of file G4GenericMessenger.cc.

References command, G4UIcommand::GetParameter(), and G4UIparameter::SetDefaultValue().

00188                                                                                             {
00189   G4UIparameter * theParam = command->GetParameter(0);
00190   theParam->SetDefaultValue(defVal);
00191   return *this;
00192 }

Command& G4GenericMessenger::Command::SetGuidance ( const G4String &  s  )  [inline]

Definition at line 70 of file G4GenericMessenger.hh.

References command, and G4UIcommand::SetGuidance().

00070 { command->SetGuidance(s); return *this; }

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

Definition at line 174 of file G4GenericMessenger.cc.

References command, G4UIcommand::GetParameter(), G4UIparameter::SetCurrentAsDefault(), G4UIparameter::SetOmittable(), and G4UIparameter::SetParameterName().

00174                                                                                                                                      {
00175   G4UIparameter* theParam = command->GetParameter(0);
00176   theParam->SetParameterName(name);
00177   theParam->SetOmittable(omittable);
00178   theParam->SetCurrentAsDefault(currentAsDefault);
00179   return *this;
00180 }

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

Definition at line 69 of file G4GenericMessenger.hh.

References command, and G4UIcommand::SetRange().

00069 {command->SetRange(range.c_str()); return *this;}

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(), and command.

00068 {command->AvailableForStates(s0,s1,s2,s3,s4); return *this;}

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

Definition at line 67 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates(), and command.

00067 {command->AvailableForStates(s0,s1,s2,s3); return *this;}

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

Definition at line 66 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates(), and command.

00066 {command->AvailableForStates(s0,s1,s2); return *this;}

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

Definition at line 65 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates(), and command.

00065 {command->AvailableForStates(s0, s1); return *this;}

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

Definition at line 64 of file G4GenericMessenger.hh.

References G4UIcommand::AvailableForStates(), and command.

00064 {command->AvailableForStates(s0); return *this;}

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

Definition at line 140 of file G4GenericMessenger.cc.

References command, G4cerr, G4endl, G4UIcommand::GetCommandPath(), G4UIcommand::GetGuidanceEntries(), G4UIcommand::GetGuidanceLine(), G4UIcommand::GetMessenger(), G4UIcommand::GetRange(), G4UIcmdWith3VectorAndUnit::SetDefaultUnit(), G4UIcmdWithADoubleAndUnit::SetDefaultUnit(), G4UIcommand::SetGuidance(), G4UIcommand::SetRange(), G4UIcmdWith3VectorAndUnit::SetUnitCategory(), G4UIcmdWithADoubleAndUnit::SetUnitCategory(), type, UnitCategory, and UnitDefault.

Referenced by SetDefaultUnit(), and SetUnitCategory().

00140                                                                                                  {
00141   // Change the type of command (unfortunatelly this is done a posteriory)
00142   // We need to delete the old command before creating the new one and therefore we need to recover the information
00143   // before the deletetion
00144   G4String cmdpath = command->GetCommandPath();
00145   G4UImessenger* messenger = command->GetMessenger();
00146   G4String range = command->GetRange();
00147   std::vector<G4String> guidance;
00148   for (G4int i = 0; i < command->GetGuidanceEntries(); i++) guidance.push_back(command->GetGuidanceLine(i));
00149   // Before deleting the command we need to add a fake one to avoid deleting the directory entry and with its guidance
00150   G4UIcommand tmp((cmdpath+"_tmp").c_str(), messenger);
00151   delete command;
00152 
00153   if (*type == typeid(float) || *type == typeid(double) ) {
00154     G4UIcmdWithADoubleAndUnit* cmd_t = new G4UIcmdWithADoubleAndUnit(cmdpath, messenger);
00155     if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
00156     else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
00157     command = cmd_t;
00158   }
00159   else if (*type == typeid(G4ThreeVector)) {
00160     G4UIcmdWith3VectorAndUnit* cmd_t = new G4UIcmdWith3VectorAndUnit(cmdpath, messenger);
00161     if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
00162     else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
00163     command = cmd_t;
00164   }
00165   else {
00166     G4cerr << "Only parameters of type <double> or <float> can be associated with units" << G4endl;
00167     return *this;
00168   }
00169   for (size_t i = 0; i < guidance.size(); i++) command->SetGuidance(guidance[i]);
00170   command->SetRange(range);
00171   return *this;
00172 }

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

Definition at line 72 of file G4GenericMessenger.hh.

References SetUnit(), and UnitCategory.

00072 {return SetUnit(u, UnitCategory);}


Field Documentation

G4UIcommand* G4GenericMessenger::Command::command

Definition at line 78 of file G4GenericMessenger.hh.

Referenced by SetCandidates(), SetDefaultValue(), SetGuidance(), SetParameterName(), SetRange(), SetStates(), and 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:
Generated on Mon May 27 17:52:04 2013 for Geant4 by  doxygen 1.4.7