Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4ModelCompoundCommandsT.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id$
27//
28// Jane Tinslay September 2006
29//
30// Compound model commands.
31//
32#ifndef G4MODELCOMPOUNDCOMMANDST_HH
33#define G4MODELCOMPOUNDCOMMANDST_HH
34
37#include "G4ModelCommandsT.hh"
38#include "G4String.hh"
39
40////////////////////////////////////////////////////////////////////////
41// Set interval context
42template <typename M>
44
45public: // With description
46
47 G4ModelCmdAddIntervalContext(M* model, const G4String& placement,
48 const G4String& cmdName="addInterval")
49 :G4ModelCmdApplyString<M>(model, placement, cmdName)
50 {
52 cmd->SetGuidance("Add interval.");
53 }
54
56 std::vector<G4UImessenger*>::iterator iter = fMessengers.begin();
57
58 while (iter != fMessengers.end()) {
59 delete *iter;
60 iter++;
61 }
62 }
63
64protected:
65
66 virtual void Apply(const G4String& param) {
67 G4String myString(param);
68
69 G4String name;
70 std::istringstream is(param);
71
72 is >> name;
73
74 myString.erase(0, name.size());
75
77
78 G4VisTrajContext* context = new G4VisTrajContext(name);
79
80 G4ModelCommandUtils::AddContextMsgrs(context, fMessengers, dir);
81 G4VModelCommand<M>::Model()->AddIntervalContext(myString, context);
82 }
83
84private:
85
86 std::vector<G4UImessenger*> fMessengers;
87
88};
89
90////////////////////////////////////////////////////////////////////////
91// Set value context
92template <typename M>
94
95public: // With description
96
97 G4ModelCmdAddValueContext(M* model, const G4String& placement,
98 const G4String& cmdName="addValue")
99 :G4ModelCmdApplyString<M>(model, placement, cmdName)
100 {
102 cmd->SetGuidance("Add value.");
103 }
104
106 std::vector<G4UImessenger*>::iterator iter = fMessengers.begin();
107
108 while (iter != fMessengers.end()) {
109 delete *iter;
110 iter++;
111 }
112 }
113
114protected:
115
116 virtual void Apply(const G4String& param) {
117 G4String myString(param);
118
119 G4String name;
120 std::istringstream is(param);
121
122 is >> name;
123
124 myString.erase(0, name.size());
125
127
128 G4VisTrajContext* context = new G4VisTrajContext(name);
129
130 G4ModelCommandUtils::AddContextMsgrs(context, fMessengers, dir);
131 G4VModelCommand<M>::Model()->AddValueContext(myString, context);
132 }
133
134private:
135
136 std::vector<G4UImessenger*> fMessengers;
137
138};
139
140#endif
virtual void Apply(const G4String &param)
G4ModelCmdAddIntervalContext(M *model, const G4String &placement, const G4String &cmdName="addInterval")
virtual void Apply(const G4String &param)
G4ModelCmdAddValueContext(M *model, const G4String &placement, const G4String &cmdName="addValue")
G4UIcmdWithAString * Command()
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
G4String Placement()
void AddContextMsgrs(G4VisTrajContext *context, std::vector< G4UImessenger * > &messengers, const G4String &placement)