Back to home page

EIC code displayed by LXR

 
 

    


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 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // Jane Tinslay September 2006
0028 //
0029 // Compound model commands.
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 // Set interval context
0041 template <typename M>
0042 class G4ModelCmdAddIntervalContext: public G4ModelCmdApplyString<M> {
0043 
0044 public: // With description
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 // Set value context
0091 template <typename M>
0092 class G4ModelCmdAddValueContext: public G4ModelCmdApplyString<M> {
0093 
0094 public: // With description
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