ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataCont/interface/PVector.h
Revision: 1.1
Committed: Tue Jul 29 10:36:20 2008 UTC (16 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: MITHEP_2_0_x
Log Message:
Added submodule for containers only

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2     // $Id: PVector.h,v 1.10 2008/07/14 09:41:59 loizides Exp $
3     //
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     #ifndef DATATREE_PVECTOR_H
15     #define DATATREE_PVECTOR_H
16    
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     ClassDefT(PVector, 1) // Wrapper around std::vector class
35     };
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     for (UInt_t i=0; i<Vector<ArrayElement>::GetEntries(); ++i) {
53     delete Vector<ArrayElement>::fV[i];
54     }
55     Vector<ArrayElement>::fV.clear();
56     }
57     #endif