File indexing completed on 2025-01-18 09:59:13
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
0032
0033
0034
0035 #ifndef G4TrajectoryContainer_hh
0036 #define G4TrajectoryContainer_hh 1
0037
0038 #include <vector>
0039
0040 #include "globals.hh"
0041 #include "evtdefs.hh"
0042 #include "G4VTrajectory.hh"
0043 #include "G4Allocator.hh"
0044
0045 using TrajectoryVector = std::vector<G4VTrajectory*>;
0046
0047 class G4TrajectoryContainer
0048 {
0049 public:
0050
0051 G4TrajectoryContainer();
0052 ~G4TrajectoryContainer();
0053
0054 G4TrajectoryContainer(const G4TrajectoryContainer&) = delete;
0055 G4TrajectoryContainer& operator=(const G4TrajectoryContainer&) = delete;
0056
0057 inline void *operator new(std::size_t);
0058 inline void operator delete(void* anEvent);
0059
0060 G4bool operator==(const G4TrajectoryContainer& right) const;
0061 G4bool operator!=(const G4TrajectoryContainer& right) const;
0062
0063 inline std::size_t size() const { return vect->size(); }
0064 inline void push_back(G4VTrajectory* p) { vect->push_back(p); }
0065 inline std::size_t entries() const { return size(); }
0066 inline G4bool insert(G4VTrajectory* p) { push_back(p); return true; }
0067 inline void clearAndDestroy()
0068 {
0069 for(std::size_t i=0; i<size(); ++i) delete (*vect)[i];
0070 vect->clear();
0071 }
0072 inline G4VTrajectory* operator[](std::size_t n) { return (*vect)[n]; }
0073 inline TrajectoryVector* GetVector() const { return vect; }
0074
0075 private:
0076
0077 TrajectoryVector* vect = nullptr;
0078 };
0079
0080 extern G4EVENT_DLL
0081 G4Allocator<G4TrajectoryContainer>*& aTrajectoryContainerAllocator();
0082
0083 inline void* G4TrajectoryContainer::operator new(std::size_t)
0084 {
0085 if (aTrajectoryContainerAllocator() == nullptr)
0086 {
0087 aTrajectoryContainerAllocator() = new G4Allocator<G4TrajectoryContainer>;
0088 }
0089 return (void*)aTrajectoryContainerAllocator()->MallocSingle();
0090 }
0091
0092 inline void G4TrajectoryContainer::operator delete(void* aTrajectoryContainer)
0093 {
0094 aTrajectoryContainerAllocator()
0095 ->FreeSingle((G4TrajectoryContainer*)aTrajectoryContainer);
0096 }
0097
0098 #endif