Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: G4ModelCompoundCommandsT.hh 66373 2012-12-18 09:41:34Z gcosmo $
27 //
28 // Jane Tinslay September 2006
29 //
30 // Compound model commands.
31 //
32 #ifndef G4MODELCOMPOUNDCOMMANDST_HH
33 #define G4MODELCOMPOUNDCOMMANDST_HH
34 
35 #include "G4ModelApplyCommandsT.hh"
36 #include "G4ModelCommandUtils.hh"
37 #include "G4ModelCommandsT.hh"
38 #include "G4String.hh"
39 
40 ////////////////////////////////////////////////////////////////////////
41 // Set interval context
42 template <typename M>
44 
45 public: // With description
46 
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 
64 protected:
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 
79 
80  G4ModelCommandUtils::AddContextMsgrs(context, fMessengers, dir);
81  G4VModelCommand<M>::Model()->AddIntervalContext(myString, context);
82  }
83 
84 private:
85 
86  std::vector<G4UImessenger*> fMessengers;
87 
88 };
89 
90 ////////////////////////////////////////////////////////////////////////
91 // Set value context
92 template <typename M>
94 
95 public: // 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 
114 protected:
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 
129 
130  G4ModelCommandUtils::AddContextMsgrs(context, fMessengers, dir);
131  G4VModelCommand<M>::Model()->AddValueContext(myString, context);
132  }
133 
134 private:
135 
136  std::vector<G4UImessenger*> fMessengers;
137 
138 };
139 
140 #endif
char cmd[1024]
Definition: tracer.cxx:25
virtual void Apply(const G4String &param)
const XML_Char * name
G4String Placement()
void AddContextMsgrs(G4VisTrajContext *context, std::vector< G4UImessenger * > &messengers, const G4String &placement)
G4UIcmdWithAString * Command()
virtual void Apply(const G4String &param)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
const XML_Char XML_Content * model
const XML_Char * context
G4ModelCmdAddValueContext(M *model, const G4String &placement, const G4String &cmdName="addValue")
G4ModelCmdAddIntervalContext(M *model, const G4String &placement, const G4String &cmdName="addInterval")