Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4ToolsAnalysisMessenger Class Reference

#include <G4ToolsAnalysisMessenger.hh>

Inheritance diagram for G4ToolsAnalysisMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4ToolsAnalysisMessenger (G4ToolsAnalysisManager *manager)
 
G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool operator== (const G4UImessenger &messenger) const
 
virtual void SetNewValue (G4UIcommand *command, G4String value) final
 
virtual ~G4ToolsAnalysisMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Member Functions

template<typename HT >
G4String GetHnAddress (G4int id, G4THnManager< HT > *htManager) const
 

Private Attributes

std::unique_ptr< G4UIcommandfGetH1Cmd
 
std::unique_ptr< G4UIcommandfGetH2Cmd
 
std::unique_ptr< G4UIcommandfGetH3Cmd
 
std::unique_ptr< G4UIcommandfGetP1Cmd
 
std::unique_ptr< G4UIcommandfGetP2Cmd
 
G4String fH1Value
 
G4String fH2Value
 
G4String fH3Value
 
G4ToolsAnalysisManagerfManager
 Associated class. More...
 
G4String fP1Value
 
G4String fP2Value
 

Detailed Description

Definition at line 43 of file G4ToolsAnalysisMessenger.hh.

Constructor & Destructor Documentation

◆ G4ToolsAnalysisMessenger()

G4ToolsAnalysisMessenger::G4ToolsAnalysisMessenger ( G4ToolsAnalysisManager manager)
explicit

Definition at line 40 of file G4ToolsAnalysisMessenger.cc.

41 : G4UImessenger(),
42 fManager(manager)
43{
44 // Create get commands
45 G4AnalysisMessengerHelper helper("h1");
46 fGetH1Cmd = helper.CreateGetCommand(this);
47
48 helper.SetHnType("h2");
49 fGetH2Cmd = helper.CreateGetCommand(this);
50
51 helper.SetHnType("h3");
52 fGetH3Cmd = helper.CreateGetCommand(this);
53
54 helper.SetHnType("p1");
55 fGetP1Cmd = helper.CreateGetCommand(this);
56
57 helper.SetHnType("p2");
58 fGetP2Cmd = helper.CreateGetCommand(this);
59}
std::unique_ptr< G4UIcommand > fGetH1Cmd
std::unique_ptr< G4UIcommand > fGetP2Cmd
std::unique_ptr< G4UIcommand > fGetH2Cmd
std::unique_ptr< G4UIcommand > fGetP1Cmd
std::unique_ptr< G4UIcommand > fGetH3Cmd
G4ToolsAnalysisManager * fManager
Associated class.

References G4AnalysisMessengerHelper::CreateGetCommand(), fGetH1Cmd, fGetH2Cmd, fGetH3Cmd, fGetP1Cmd, fGetP2Cmd, and G4AnalysisMessengerHelper::SetHnType().

◆ ~G4ToolsAnalysisMessenger()

G4ToolsAnalysisMessenger::~G4ToolsAnalysisMessenger ( )
virtualdefault

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4ToolsAnalysisMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 69 of file G4ToolsAnalysisMessenger.cc.

70{
71 if ( command == fGetH1Cmd.get() ) return fH1Value;
72 if ( command == fGetH2Cmd.get() ) return fH2Value;
73 if ( command == fGetH3Cmd.get() ) return fH3Value;
74 if ( command == fGetP1Cmd.get() ) return fP1Value;
75 if ( command == fGetP2Cmd.get() ) return fP2Value;
76 return "";
77}

References fGetH1Cmd, fGetH2Cmd, fGetH3Cmd, fGetP1Cmd, fGetP2Cmd, fH1Value, fH2Value, fH3Value, fP1Value, and fP2Value.

◆ GetHnAddress()

template<typename HT >
G4String G4ToolsAnalysisMessenger::GetHnAddress ( G4int  id,
G4THnManager< HT > *  htManager 
) const
inlineprivate

Definition at line 76 of file G4ToolsAnalysisMessenger.hh.

78{
79 auto ht = htManager->GetT(id);
80 if ( ht != nullptr ) {
81 std::ostringstream os;
82 os << static_cast<void*>(ht);
83 return os.str();
84 }
85 return G4String();
86}
HT * GetT(G4int id) const

References G4THnManager< HT >::GetT().

Referenced by SetNewValue().

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetNewValue()

void G4ToolsAnalysisMessenger::SetNewValue ( G4UIcommand command,
G4String  value 
)
finalvirtual

Reimplemented from G4UImessenger.

Definition at line 80 of file G4ToolsAnalysisMessenger.cc.

81{
82 auto id = G4UIcommand::ConvertToInt(value);
83 if ( command == fGetH1Cmd.get() ) {
85 }
86 else if ( command == fGetH2Cmd.get() ) {
88 }
89 else if ( command == fGetH3Cmd.get() ) {
91 }
92 else if ( command == fGetP1Cmd.get() ) {
94 }
95 else if ( command == fGetP2Cmd.get() ) {
97 }
98}
G4String GetHnAddress(G4int id, G4THnManager< HT > *htManager) const
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:557

References G4UIcommand::ConvertToInt(), fGetH1Cmd, fGetH2Cmd, fGetH3Cmd, fGetP1Cmd, fGetP2Cmd, G4ToolsAnalysisManager::fH1Manager, fH1Value, G4ToolsAnalysisManager::fH2Manager, fH2Value, G4ToolsAnalysisManager::fH3Manager, fH3Value, fManager, G4ToolsAnalysisManager::fP1Manager, fP1Value, G4ToolsAnalysisManager::fP2Manager, fP2Value, and GetHnAddress().

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ fGetH1Cmd

std::unique_ptr<G4UIcommand> G4ToolsAnalysisMessenger::fGetH1Cmd
private

◆ fGetH2Cmd

std::unique_ptr<G4UIcommand> G4ToolsAnalysisMessenger::fGetH2Cmd
private

◆ fGetH3Cmd

std::unique_ptr<G4UIcommand> G4ToolsAnalysisMessenger::fGetH3Cmd
private

◆ fGetP1Cmd

std::unique_ptr<G4UIcommand> G4ToolsAnalysisMessenger::fGetP1Cmd
private

◆ fGetP2Cmd

std::unique_ptr<G4UIcommand> G4ToolsAnalysisMessenger::fGetP2Cmd
private

◆ fH1Value

G4String G4ToolsAnalysisMessenger::fH1Value
private

Definition at line 65 of file G4ToolsAnalysisMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().

◆ fH2Value

G4String G4ToolsAnalysisMessenger::fH2Value
private

Definition at line 66 of file G4ToolsAnalysisMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().

◆ fH3Value

G4String G4ToolsAnalysisMessenger::fH3Value
private

Definition at line 67 of file G4ToolsAnalysisMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().

◆ fManager

G4ToolsAnalysisManager* G4ToolsAnalysisMessenger::fManager
private

Associated class.

Definition at line 59 of file G4ToolsAnalysisMessenger.hh.

Referenced by SetNewValue().

◆ fP1Value

G4String G4ToolsAnalysisMessenger::fP1Value
private

Definition at line 68 of file G4ToolsAnalysisMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().

◆ fP2Value

G4String G4ToolsAnalysisMessenger::fP2Value
private

Definition at line 69 of file G4ToolsAnalysisMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().


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