Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4THitsCollection.hh 67992 2013-03-13 10:59:57Z gcosmo $
|
||||
//
|
||||
|
||||
#ifndef G4THitsCollection_h
|
||||
@@ -59,9 +59,9 @@ class G4HitsCollection : public G4VHitsCollection
|
||||
};
|
||||
|
||||
#if defined G4DIGI_ALLOC_EXPORT
|
||||
extern G4DLLEXPORT G4Allocator<G4HitsCollection> anHCAllocator;
|
||||
extern G4DLLEXPORT G4ThreadLocal G4Allocator<G4HitsCollection> *anHCAllocator_G4MT_TLS_;
|
||||
#else
|
||||
extern G4DLLIMPORT G4Allocator<G4HitsCollection> anHCAllocator;
|
||||
extern G4DLLIMPORT G4ThreadLocal G4Allocator<G4HitsCollection> *anHCAllocator_G4MT_TLS_;
|
||||
#endif
|
||||
|
||||
template <class T> class G4THitsCollection : public G4HitsCollection
|
||||
@@ -85,15 +85,20 @@ template <class T> class G4THitsCollection : public G4HitsCollection
|
||||
|
||||
public: // with description
|
||||
inline T* operator[](size_t i) const
|
||||
{ return (*((std::vector<T*>*)theCollection))[i]; }
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
return (*((std::vector<T*>*)theCollection))[i];
|
||||
}
|
||||
// Returns a pointer to a concrete hit object.
|
||||
inline std::vector<T*>* GetVector() const
|
||||
{ return (std::vector<T*>*)theCollection; }
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
return (std::vector<T*>*)theCollection; }
|
||||
// Returns a collection vector.
|
||||
inline G4int insert(T* aHit)
|
||||
{
|
||||
std::vector<T*>*theHitsCollection
|
||||
= (std::vector<T*>*)theCollection;
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
std::vector<T*>*theHitsCollection = (std::vector<T*>*)theCollection;
|
||||
theHitsCollection->push_back(aHit);
|
||||
return theHitsCollection->size();
|
||||
}
|
||||
@@ -101,22 +106,29 @@ template <class T> class G4THitsCollection : public G4HitsCollection
|
||||
// collection is returned.
|
||||
inline G4int entries() const
|
||||
{
|
||||
std::vector<T*>*theHitsCollection
|
||||
= (std::vector<T*>*)theCollection;
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
std::vector<T*>*theHitsCollection = (std::vector<T*>*)theCollection;
|
||||
return theHitsCollection->size();
|
||||
}
|
||||
// Returns the number of hit objects stored in this collection
|
||||
|
||||
public:
|
||||
virtual G4VHit* GetHit(size_t i) const
|
||||
{ return (*((std::vector<T*>*)theCollection))[i]; }
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
return (*((std::vector<T*>*)theCollection))[i];
|
||||
}
|
||||
virtual size_t GetSize() const
|
||||
{ return ((std::vector<T*>*)theCollection)->size(); }
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
return ((std::vector<T*>*)theCollection)->size(); }
|
||||
|
||||
};
|
||||
|
||||
template <class T> inline void* G4THitsCollection<T>::operator new(size_t)
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
G4Allocator<G4HitsCollection> &anHCAllocator = *anHCAllocator_G4MT_TLS_; ;;;
|
||||
void* anHC;
|
||||
anHC = (void*)anHCAllocator.MallocSingle();
|
||||
return anHC;
|
||||
@@ -124,28 +136,30 @@ template <class T> inline void* G4THitsCollection<T>::operator new(size_t)
|
||||
|
||||
template <class T> inline void G4THitsCollection<T>::operator delete(void* anHC)
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
G4Allocator<G4HitsCollection> &anHCAllocator = *anHCAllocator_G4MT_TLS_; ;;;
|
||||
anHCAllocator.FreeSingle((G4HitsCollection*)anHC);
|
||||
}
|
||||
|
||||
template <class T> G4THitsCollection<T>::G4THitsCollection()
|
||||
{
|
||||
std::vector<T*> * theHitsCollection
|
||||
= new std::vector<T*>;
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
std::vector<T*> * theHitsCollection = new std::vector<T*>;
|
||||
theCollection = (void*)theHitsCollection;
|
||||
}
|
||||
|
||||
template <class T> G4THitsCollection<T>::G4THitsCollection(G4String detName,G4String colNam)
|
||||
: G4HitsCollection(detName,colNam)
|
||||
{
|
||||
std::vector<T*> * theHitsCollection
|
||||
= new std::vector<T*>;
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
std::vector<T*> * theHitsCollection = new std::vector<T*>;
|
||||
theCollection = (void*)theHitsCollection;
|
||||
}
|
||||
|
||||
template <class T> G4THitsCollection<T>::~G4THitsCollection()
|
||||
{
|
||||
std::vector<T*> * theHitsCollection
|
||||
= (std::vector<T*>*)theCollection;
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
std::vector<T*> * theHitsCollection = (std::vector<T*>*)theCollection;
|
||||
//theHitsCollection->clearAndDestroy();
|
||||
for(size_t i=0;i<theHitsCollection->size();i++)
|
||||
{ delete (*theHitsCollection)[i]; }
|
||||
@@ -154,12 +168,15 @@ template <class T> G4THitsCollection<T>::~G4THitsCollection()
|
||||
}
|
||||
|
||||
template <class T> G4int G4THitsCollection<T>::operator==(const G4THitsCollection<T> &right) const
|
||||
{ return (collectionName==right.collectionName); }
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
return (collectionName==right.collectionName);
|
||||
}
|
||||
|
||||
template <class T> void G4THitsCollection<T>::DrawAllHits()
|
||||
{
|
||||
std::vector<T*> * theHitsCollection
|
||||
= (std::vector<T*>*)theCollection;
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
std::vector<T*> * theHitsCollection = (std::vector<T*>*)theCollection;
|
||||
size_t n = theHitsCollection->size();
|
||||
for(size_t i=0;i<n;i++)
|
||||
{ (*theHitsCollection)[i]->Draw(); }
|
||||
@@ -167,6 +184,7 @@ template <class T> void G4THitsCollection<T>::DrawAllHits()
|
||||
|
||||
template <class T> void G4THitsCollection<T>::PrintAllHits()
|
||||
{
|
||||
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ = new G4Allocator<G4HitsCollection>;
|
||||
std::vector<T*> * theHitsCollection
|
||||
= (std::vector<T*>*)theCollection;
|
||||
size_t n = theHitsCollection->size();
|
||||
|
||||
Reference in New Issue
Block a user