#include <RecArrayAllocator.h>
Public Types | |
| typedef std::map< TClonesArray *, bool >::iterator | ArrayMapItr |
| typedef std::map< TClonesArray *, bool >::const_iterator | ArrayMapConstItr |
Public Member Functions | |
| UInt_t | GetNumArray () const |
| std::ostream & | Print (std::ostream &s) const |
| TClonesArray *const | GetArray (const char *className) |
| void | ReleaseArray (TClonesArray *array) |
Static Public Member Functions | |
| RecArrayAllocator & | Instance () |
Protected Member Functions | |
| RecArrayAllocator () | |
| virtual | ~RecArrayAllocator () |
Private Member Functions | |
| RecArrayAllocator (RecArrayAllocator &rlm) | |
| RecArrayAllocator & | operator= (const RecArrayAllocator &rlm) |
Private Attributes | |
| std::map< TClonesArray *, bool > | fArrayMap |
Static Private Attributes | |
| RecArrayAllocator * | fgInstance = 0 |
Friends | |
| struct | Cleaner |
|
|
Definition at line 51 of file RecArrayAllocator.h. Referenced by Print(). |
|
|
Definition at line 50 of file RecArrayAllocator.h. Referenced by ReleaseArray(), and ~RecArrayAllocator(). |
|
|
Definition at line 162 of file RecArrayAllocator.cxx. Referenced by Instance(). 00162 {
00163 // Purpose: Default constructor.
00164 //
00165 // Arguments: none.
00166 //
00167 // Return: n/a.
00168 //
00169 // Contact: S. Kasahara
00170 //
00171 // Notes: Not called directly, use RecArrayAllocator::Instance() instead.
00172
00173 }
|
|
|
Definition at line 175 of file RecArrayAllocator.cxx. References ArrayMapItr, fArrayMap, and MSG. 00175 {
00176 // Purpose: Destructor.
00177 //
00178 // Arguments: none.
00179 //
00180 // Return: none.
00181 //
00182 // Contact: S. Kasahara
00183 //
00184
00185 // Close all managed arrays and retrieve allocated memory
00186 MSG("Rec",Msg::kDebug) << "RecArrayAllocator destructor for addr "
00187 << this << endl;
00188
00189 for( ArrayMapItr itr = fArrayMap.begin(); itr != fArrayMap.end(); itr++ ) {
00190 TClonesArray* array = itr -> first;
00191 if ( array ) {
00192 if ( !(itr->second) ) {
00193 MSG("Rec",Msg::kWarning) << "RecArrayAllocator dtor deleting array "
00194 << array->GetClass()->GetName()
00195 << " which has not been released!" << endl;
00196 }
00197 else {
00198 MSG("Rec",Msg::kDebug) << "Clearing and Deleting array of type "
00199 << array->GetClass()->GetName() << endl;
00200 }
00201 array -> Clear("C");
00202 delete array; array = 0;
00203 }
00204 fArrayMap.erase(itr);
00205 }
00206
00207 }
|
|
|
|
|
|
Definition at line 42 of file RecArrayAllocator.cxx. References MSG. Referenced by GfxDigitList::GfxDigitList(), GfxMCVecList::GfxMCVecList(), GfxShowerList::GfxShowerList(), GfxStripList::GfxStripList(), GfxTrackList::GfxTrackList(), UberRecordLite::Init(), UberRecord::Init(), NtpTHRecord::Init(), NtpStRecord::Init(), NtpSRRecord::Init(), NtpMRRecord::Init(), NtpMCRecord::Init(), NtpFitSARecord::Init(), NtpEMRecord::Init(), NtpCluster3DRecord::Init(), NtpCandRecord::Init(), NtpAlignmentRecord::Init(), DemoNtupleRecord::Init(), CandRecordSRNtuple::Init(), and RecValidate::TestArrayAllocator(). 00042 {
00043 // Purpose: Return TClonesArray of requested type, creating it if
00044 // necessary.
00045 //
00046 // Arguments: none.
00047 //
00048 // Return: const ptr to non-const TClonesArray.
00049 //
00050 // Contact: S. Kasahara
00051 //
00052
00053 for ( ArrayMapItr itr = fArrayMap.begin(); itr != fArrayMap.end(); itr++ ) {
00054 if ( itr->second ) {
00055 // Array is free, check type
00056 TClonesArray* array = itr->first;
00057 if ( !strcmp(array->GetClass()->GetName(),className) ) {
00058 itr->second = false;
00059 MSG("Rec",Msg::kVerbose)
00060 << "GetArray retrieved existing TClonesArray of type " << className
00061 << endl;
00062 return array;
00063 }
00064 }
00065 }
00066
00067 // No existing TClonesArray is available for use, create one here
00068 TClonesArray* array = new TClonesArray(className);
00069 fArrayMap.insert(std::make_pair(array,false));
00070 MSG("Rec",Msg::kVerbose)
00071 << "GetArray created new TClonesArray to support type " << className
00072 << endl;
00073 return array;
00074
00075 }
|
|
|
Definition at line 54 of file RecArrayAllocator.h. Referenced by RecValidate::TestArrayAllocator(). 00054 { return fArrayMap.size(); }
|
|
|
|
|
|
|
Definition at line 131 of file RecArrayAllocator.cxx. References ArrayMapConstItr, and fArrayMap. Referenced by operator<<(), and DemoNtupleRecord::Print(). 00131 {
00132 // Purpose: Print current map of arrays maintained by array allocator on
00133 // ostream.
00134 //
00135 // Arguments: ms ostream to display on.
00136 //
00137 // Return: ostream reference.
00138 //
00139 // Contact: S. Kasahara
00140 //
00141
00142 int size = fArrayMap.size();
00143 if ( size <= 0 ) {
00144 os << "RecArrayAllocator is currently not managing any arrays." << endl;
00145 return os;
00146 }
00147
00148 os << "RecArrayAllocator is currently managing " << size
00149 << " array" << ((size > 1) ? "s:" : ":") << endl;
00150
00151 int i=0;
00152 for( ArrayMapConstItr itr = fArrayMap.begin();itr != fArrayMap.end();itr++) {
00153 os << " " << i << ")Serves class " << itr->first->GetClass()->GetName()
00154 << ((itr->second) ? " and is available." :
00155 " and is in use.") << endl;
00156 i++;
00157 }
00158 return os;
00159
00160 }
|
|
|
Definition at line 99 of file RecArrayAllocator.cxx. References ArrayMapItr, fArrayMap, and MSG. Referenced by CandRecordSRNtuple::Init(), RecValidate::TestArrayAllocator(), DemoNtupleRecord::~DemoNtupleRecord(), GfxDigitList::~GfxDigitList(), GfxMCVecList::~GfxMCVecList(), GfxShowerList::~GfxShowerList(), GfxStripList::~GfxStripList(), GfxTrackList::~GfxTrackList(), NtpAlignmentRecord::~NtpAlignmentRecord(), NtpCandRecord::~NtpCandRecord(), NtpCluster3DRecord::~NtpCluster3DRecord(), NtpEMRecord::~NtpEMRecord(), NtpFitSARecord::~NtpFitSARecord(), NtpMCRecord::~NtpMCRecord(), NtpMRRecord::~NtpMRRecord(), NtpSRRecord::~NtpSRRecord(), NtpStRecord::~NtpStRecord(), NtpTHRecord::~NtpTHRecord(), UberRecord::~UberRecord(), and UberRecordLite::~UberRecordLite(). 00099 {
00100 // Purpose: Dereference use of TClonesArray, freeing it for reuse.
00101 //
00102 // Arguments: ptr to TClonesArray to be dereferenced.
00103 //
00104 // Return: none.
00105 //
00106 // Contact: S. Kasahara
00107 //
00108
00109 // clears array. The user has the responsibility of i)calling
00110 // TClonesArray::Delete() before releasing array if the stored objects
00111 // allocate memory, or ii)alternatively implementing a Clear method for these
00112 // objects that frees up any allocated memory. This method will be called
00113 // by the array->Clear("C") call below.
00114 if ( array ) {
00115 ArrayMapItr itr = fArrayMap.find(array);
00116 if ( itr != fArrayMap.end() ) {
00117 MSG("Rec",Msg::kVerbose) << "ReleaseArray of type "
00118 << array->GetClass()->GetName() << endl;
00119 array -> Clear("C");
00120 itr->second = true;
00121 }
00122 else {
00123 MSG("Rec",Msg::kWarning) << "Release array request for type "
00124 << array->GetClass()->GetName() << " ptr "
00125 << array << " is not in array map! Ignored."
00126 << endl;
00127 }
00128 }
00129 }
|
|
|
Definition at line 85 of file RecArrayAllocator.h. |
|
|
Definition at line 74 of file RecArrayAllocator.h. Referenced by Print(), ReleaseArray(), and ~RecArrayAllocator(). |
|
|
Definition at line 36 of file RecArrayAllocator.cxx. Referenced by Instance(), and RecArrayAllocator::Cleaner::~Cleaner(). |
1.3.9.1