Geant4  10.00.p03
G4VTrackState.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 /*
27  * G4VTrackState.hh
28  *
29  * Created on: 8 avr. 2013
30  * Author: kara
31  */
32 
33 #ifndef G4VTRACKSTATE_HH_
34 #define G4VTRACKSTATE_HH_
35 
36 #include <CLHEP/Utility/memory.h>
37 
39 {
40 public :
41  virtual int GetStateID() = 0;
42 protected :
44  virtual ~G4VTrackStateID(){;}
45 
46  static int fgLastID;
47 };
48 
49 class G4TrackState;
50 
51 template <class T>
53 {
54 public :
55  static CLHEP::shared_ptr<G4VTrackStateID> Get()
56  {
57  if(!fgTrackStateID)
58  {
60  }
61 
62  return fgTrackStateID;
63  }
64 
66 
67  virtual int GetStateID()
68  {
69  return fID;
70  }
71 
72  static int GetID()
73  {
74  if(fgTrackStateID)
75  return fgTrackStateID->fID;
76  else
77  return -1; // TODO Exception
78  }
79 
80 private:
82  {
83  fgLastID++;
84  fgTrackStateID = this;
85  }
86 
87  static CLHEP::shared_ptr<G4TrackStateID<T> > fgTrackStateID;
88  const int fID;
89 };
90 
91 
93 {
94 public:
95  template <class T> static G4TrackState* Create()
96  {
98  return output;
99  }
100 
101  int GetID()
102  {
103  return fpTrackStateID->GetStateID();
104  }
105 
106 protected:
107  virtual ~G4TrackState(){}
108 
109 private :
110  G4TrackState(CLHEP::shared_ptr<G4VTrackStateID> _trackStateID) : fpTrackStateID(_trackStateID)
111  {}
112 
113  CLHEP::shared_ptr<G4VTrackStateID> fpTrackStateID;
114 };
115 
116 #endif /* G4VTRACKSTATE_HH_ */
virtual ~G4TrackState()
CLHEP::shared_ptr< G4VTrackStateID > fpTrackStateID
virtual int GetStateID()=0
static int GetID()
G4TrackState(CLHEP::shared_ptr< G4VTrackStateID > _trackStateID)
static CLHEP::shared_ptr< G4VTrackStateID > Get()
virtual int GetStateID()
static G4TrackState * Create()
virtual ~G4VTrackStateID()
static int fgLastID
static CLHEP::shared_ptr< G4TrackStateID< T > > fgTrackStateID