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: G4ModelCompoundCommandsT.hh,v 1.1 2006/09/11 21:52:18 tinslay Exp $ |
---|
27 | // GEANT4 tag $Name: $ |
---|
28 | // |
---|
29 | // Jane Tinslay September 2006 |
---|
30 | // |
---|
31 | // Compound model commands. |
---|
32 | // |
---|
33 | #ifndef G4MODELCOMPOUNDCOMMANDST_HH |
---|
34 | #define G4MODELCOMPOUNDCOMMANDST_HH |
---|
35 | |
---|
36 | #include "G4ModelApplyCommandsT.hh" |
---|
37 | #include "G4ModelCommandUtils.hh" |
---|
38 | #include "G4ModelCommandsT.hh" |
---|
39 | #include "G4String.hh" |
---|
40 | |
---|
41 | //////////////////////////////////////////////////////////////////////// |
---|
42 | // Set interval context |
---|
43 | template <typename M> |
---|
44 | class G4ModelCmdAddIntervalContext: public G4ModelCmdApplyString<M> { |
---|
45 | |
---|
46 | public: // With description |
---|
47 | |
---|
48 | G4ModelCmdAddIntervalContext(M* model, const G4String& placement, |
---|
49 | const G4String& cmdName="addInterval") |
---|
50 | :G4ModelCmdApplyString<M>(model, placement, cmdName) |
---|
51 | { |
---|
52 | G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); |
---|
53 | cmd->SetGuidance("Add interval."); |
---|
54 | } |
---|
55 | |
---|
56 | virtual ~G4ModelCmdAddIntervalContext() { |
---|
57 | std::vector<G4UImessenger*>::iterator iter = fMessengers.begin(); |
---|
58 | |
---|
59 | while (iter != fMessengers.end()) { |
---|
60 | delete *iter; |
---|
61 | iter++; |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | protected: |
---|
66 | |
---|
67 | virtual void Apply(const G4String& param) { |
---|
68 | G4String myString(param); |
---|
69 | |
---|
70 | G4String name; |
---|
71 | std::istringstream is(param); |
---|
72 | |
---|
73 | is >> name; |
---|
74 | |
---|
75 | myString.erase(0, name.size()); |
---|
76 | |
---|
77 | G4String dir = G4VModelCommand<M>::Placement()+"/"+G4VModelCommand<M>::Model()->Name(); |
---|
78 | |
---|
79 | G4VisTrajContext* context = new G4VisTrajContext(name); |
---|
80 | |
---|
81 | G4ModelCommandUtils::AddContextMsgrs(context, fMessengers, dir); |
---|
82 | G4VModelCommand<M>::Model()->AddIntervalContext(myString, context); |
---|
83 | } |
---|
84 | |
---|
85 | private: |
---|
86 | |
---|
87 | std::vector<G4UImessenger*> fMessengers; |
---|
88 | |
---|
89 | }; |
---|
90 | |
---|
91 | //////////////////////////////////////////////////////////////////////// |
---|
92 | // Set value context |
---|
93 | template <typename M> |
---|
94 | class G4ModelCmdAddValueContext: public G4ModelCmdApplyString<M> { |
---|
95 | |
---|
96 | public: // With description |
---|
97 | |
---|
98 | G4ModelCmdAddValueContext(M* model, const G4String& placement, |
---|
99 | const G4String& cmdName="addValue") |
---|
100 | :G4ModelCmdApplyString<M>(model, placement, cmdName) |
---|
101 | { |
---|
102 | G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command(); |
---|
103 | cmd->SetGuidance("Add value."); |
---|
104 | } |
---|
105 | |
---|
106 | virtual ~G4ModelCmdAddValueContext() { |
---|
107 | std::vector<G4UImessenger*>::iterator iter = fMessengers.begin(); |
---|
108 | |
---|
109 | while (iter != fMessengers.end()) { |
---|
110 | delete *iter; |
---|
111 | iter++; |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | protected: |
---|
116 | |
---|
117 | virtual void Apply(const G4String& param) { |
---|
118 | G4String myString(param); |
---|
119 | |
---|
120 | G4String name; |
---|
121 | std::istringstream is(param); |
---|
122 | |
---|
123 | is >> name; |
---|
124 | |
---|
125 | myString.erase(0, name.size()); |
---|
126 | |
---|
127 | G4String dir = G4VModelCommand<M>::Placement()+"/"+G4VModelCommand<M>::Model()->Name(); |
---|
128 | |
---|
129 | G4VisTrajContext* context = new G4VisTrajContext(name); |
---|
130 | |
---|
131 | G4ModelCommandUtils::AddContextMsgrs(context, fMessengers, dir); |
---|
132 | G4VModelCommand<M>::Model()->AddValueContext(myString, context); |
---|
133 | } |
---|
134 | |
---|
135 | private: |
---|
136 | |
---|
137 | std::vector<G4UImessenger*> fMessengers; |
---|
138 | |
---|
139 | }; |
---|
140 | |
---|
141 | #endif |
---|