]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CONTAINERS/AliObjectArray.cxx
skip corrupted events
[u/mrichter/AliRoot.git] / CONTAINERS / AliObjectArray.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  AliObjectArray                                                           //
21 //                                                                           // 
22 //AliObjectArray is an array of clone (identical) objects.                   //
23 //In comparison with the TClonesArray objects in this array don't need       //
24 //to derive from TObject. They also don't need RTTI - type information.      // 
25 //                                                                           //
26 //Objects type information is stored in object fClassInfo (instance of       //
27 //the AliClassInfo).                                                         //
28 //Objects in array are stored sequentialy in buffers. Buffer is standart C++ //
29 //array of objects. Buffers size is equal for all of the buffers. If we specify
30 //fBufferSize==0 objects are stored in one big standart C++ array.
31 //
32 //  Origin:  Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk // 
33 //
34 //Begin_Html 
35 /*
36 <img src="../gif/AliObjectArray.gif">
37 */
38 ///////////////////////////////////////////////////////////////////////////////
39
40
41 #include "AliObjectArray.h"
42
43 ClassImp(AliObjectArray) 
44
45 AliObjectArray::AliObjectArray():AliMemArray()
46
47   //
48   //default constructor
49   //
50   fClassInfo = 0;
51 }
52
53 AliObjectArray::AliObjectArray(const char * classname, Int_t buffersize):AliMemArray()
54 {
55   //
56   // AliObject array constructor 
57   // Set class information  fClassInfo according specified type and set the array size -size
58   // Buufer size fBufferSize 
59   fClassInfo = 0;
60   fBufferSize = buffersize;
61   SetClass(classname);
62 }
63
64 AliObjectArray::AliObjectArray(const AliObjectArray &arr):
65   AliMemArray(arr)
66 {  
67   //
68   //
69   *((AliMemArray*)this) = *((AliMemArray*)&arr);
70   fClassInfo = arr.GetClassInfo();
71 }
72
73
74 AliObjectArray & AliObjectArray::operator=(const AliObjectArray &arr)
75 {  
76   //
77   //
78   *((AliMemArray*)this) = *((AliMemArray*)&arr);
79   fClassInfo = arr.GetClassInfo();
80   return (*this);
81 }
82
83 AliObjectArray::~AliObjectArray()  
84 {
85   //
86   //default destructor
87   Delete();  
88 }
89
90 Bool_t AliObjectArray::SetClass(const char * classname) 
91 {
92   //
93   // Set class information fClassInfo  according class name
94   //  
95   Delete();
96   
97   fClassInfo = AliClassInfo::GenerClassInfo(classname);
98   fObjectSize = fClassInfo->Size();
99   return (fClassInfo!=0);  
100 }
101
102 void   AliObjectArray::Dump(Int_t i) const
103 {
104   //dump object at position i 
105   if (At(i)) fClassInfo->ObjectDump(At(i));
106   else printf("index %d - out of range\n",i);
107 }
108
109 void   AliObjectArray::Dump() const
110 {
111   //dump all objects 
112   for (UInt_t i=0;i<fSize;i++) {
113     if (At(i)) fClassInfo->ObjectDump(At(i));
114     else printf("index %d - out of range\n",i);
115   }
116 }
117
118 void AliObjectArray::Streamer(TBuffer& R__b) 
119 {
120   //
121   //Stream of the AliVector2D
122   //
123   TString s; 
124   if (R__b.IsReading()) {
125     Version_t R__v = R__b.ReadVersion(); if (R__v) { }
126     TObject::Streamer(R__b); 
127     s.Streamer(R__b);  //read class info
128     if (s!=" ") SetClass(s.Data());
129     else fClassInfo=0;
130     R__b >> fBufferSize;
131     R__b >> fObjectSize;
132     Int_t size;
133     R__b >> size;
134     Resize(size); 
135     if (fSize>0){
136       if (fBufferSize==0) fClassInfo->StreamBuffer(R__b, GetArray(), fSize);
137       else
138         for (UInt_t i=0;i<GetNBuffers();i++)
139           fClassInfo->StreamBuffer(R__b, GetRow(i), fBufferSize);
140     }   
141   } else {
142     R__b.WriteVersion(AliObjectArray::IsA());
143     TObject::Streamer(R__b);     
144     if (fClassInfo) s = fClassInfo->GetClassName();
145     else s=" ";
146     s.Streamer(R__b);
147     R__b << fBufferSize;
148     R__b << fObjectSize;
149     R__b << fSize;
150    
151     if (fSize>0){
152       if (fBufferSize==0) fClassInfo->StreamBuffer(R__b, GetArray(), fSize);
153       else
154         for (UInt_t i=0;i<GetNBuffers();i++)
155           fClassInfo->StreamBuffer(R__b, GetRow(i), fBufferSize);
156     }
157   }
158 }
159
160
161
162
163