ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataCont/interface/PVector.h
Revision: 1.5
Committed: Fri Mar 6 13:52:54 2009 UTC (16 years, 2 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.4: +2 -2 lines
Log Message:
Have Entries also implemented for BaseCollection avoiding successive virtual calls.

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.5 // $Id: PVector.h,v 1.4 2009/03/02 12:34:00 loizides Exp $
3 loizides 1.1 //
4     // PVector
5     //
6     // Implementation of Collection interface using std:vector class for pointers pointing
7     // to allocated objects on heap.
8     //
9     // Persistency not tested, likely to not work, ask Constantin for help if you are in trouble.
10     //
11     // Authors: C.Loizides
12     //--------------------------------------------------------------------------------------------------
13    
14 loizides 1.2 #ifndef MITANA_DATACONT_PVECTOR_H
15     #define MITANA_DATACONT_PVECTOR_H
16 loizides 1.1
17     #include "MitAna/DataCont/interface/Vector.h"
18    
19     namespace mithep
20     {
21     template<class ArrayElement>
22     class PVector : public Vector<ArrayElement>
23     {
24     public:
25     PVector(UInt_t rsv=0) : Vector<ArrayElement>(0) {}
26     PVector(std::vector<ArrayElement> &v) : Vector<ArrayElement>(v) {}
27     ~PVector() { Reset(); }
28    
29     void Clear(Option_t *opt="");
30     void Reset();
31    
32     protected:
33    
34 loizides 1.4 ClassDef(PVector, 1) // Wrapper around std::vector class
35 loizides 1.1 };
36     }
37    
38     //--------------------------------------------------------------------------------------------------
39     template<class ArrayElement>
40     inline void mithep::PVector<ArrayElement>::Clear(Option_t *opt)
41     {
42     // Destruct container.
43    
44     Reset();
45     Vector<ArrayElement>::Clear(opt);
46     }
47    
48     //__________________________________________________________________________________________________
49     template<class ArrayElement>
50     inline void mithep::PVector<ArrayElement>::Reset()
51     {
52 loizides 1.3 // Reset container.
53    
54 loizides 1.5 for (UInt_t i=0; i<Vector<ArrayElement>::Entries(); ++i) {
55 loizides 1.1 delete Vector<ArrayElement>::fV[i];
56     }
57     Vector<ArrayElement>::fV.clear();
58     }
59     #endif