Warning, file /include/Geant4/G4ModelCompoundCommandsT.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifndef G4MODELCOMPOUNDCOMMANDST_HH
0032 #define G4MODELCOMPOUNDCOMMANDST_HH
0033
0034 #include "G4ModelApplyCommandsT.hh"
0035 #include "G4ModelCommandUtils.hh"
0036 #include "G4ModelCommandsT.hh"
0037 #include "G4String.hh"
0038
0039
0040
0041 template <typename M>
0042 class G4ModelCmdAddIntervalContext: public G4ModelCmdApplyString<M> {
0043
0044 public:
0045
0046 G4ModelCmdAddIntervalContext(M* model, const G4String& placement,
0047 const G4String& cmdName="addInterval")
0048 :G4ModelCmdApplyString<M>(model, placement, cmdName)
0049 {
0050 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command();
0051 cmd->SetGuidance("Add interval.");
0052 }
0053
0054 virtual ~G4ModelCmdAddIntervalContext() {
0055 std::vector<G4UImessenger*>::iterator iter = fMessengers.begin();
0056
0057 while (iter != fMessengers.end()) {
0058 delete *iter;
0059 iter++;
0060 }
0061 }
0062
0063 protected:
0064
0065 virtual void Apply(const G4String& param) {
0066 G4String myString(param);
0067
0068 G4String name;
0069 std::istringstream is(param);
0070
0071 is >> name;
0072
0073 myString.erase(0, name.size());
0074
0075 G4String dir = G4VModelCommand<M>::Placement()+"/"+G4VModelCommand<M>::Model()->Name();
0076
0077 G4VisTrajContext* context = new G4VisTrajContext(name);
0078
0079 G4ModelCommandUtils::AddContextMsgrs(context, fMessengers, dir);
0080 G4VModelCommand<M>::Model()->AddIntervalContext(myString, context);
0081 }
0082
0083 private:
0084
0085 std::vector<G4UImessenger*> fMessengers;
0086
0087 };
0088
0089
0090
0091 template <typename M>
0092 class G4ModelCmdAddValueContext: public G4ModelCmdApplyString<M> {
0093
0094 public:
0095
0096 G4ModelCmdAddValueContext(M* model, const G4String& placement,
0097 const G4String& cmdName="addValue")
0098 :G4ModelCmdApplyString<M>(model, placement, cmdName)
0099 {
0100 G4UIcmdWithAString* cmd = G4ModelCmdApplyString<M>::Command();
0101 cmd->SetGuidance("Add value.");
0102 }
0103
0104 virtual ~G4ModelCmdAddValueContext() {
0105 std::vector<G4UImessenger*>::iterator iter = fMessengers.begin();
0106
0107 while (iter != fMessengers.end()) {
0108 delete *iter;
0109 iter++;
0110 }
0111 }
0112
0113 protected:
0114
0115 virtual void Apply(const G4String& param) {
0116 G4String myString(param);
0117
0118 G4String name;
0119 std::istringstream is(param);
0120
0121 is >> name;
0122
0123 myString.erase(0, name.size());
0124
0125 G4String dir = G4VModelCommand<M>::Placement()+"/"+G4VModelCommand<M>::Model()->Name();
0126
0127 G4VisTrajContext* context = new G4VisTrajContext(name);
0128
0129 G4ModelCommandUtils::AddContextMsgrs(context, fMessengers, dir);
0130 G4VModelCommand<M>::Model()->AddValueContext(myString, context);
0131 }
0132
0133 private:
0134
0135 std::vector<G4UImessenger*> fMessengers;
0136
0137 };
0138
0139 #endif