]> git.uio.no Git - u/mrichter/AliRoot.git/blame - CONTAINERS/AliObjectArray.cxx
fRefVolumeId for reference volume identification added.
[u/mrichter/AliRoot.git] / CONTAINERS / AliObjectArray.cxx
CommitLineData
08edbb90 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/*
17$Log$
18*/
19///////////////////////////////////////////////////////////////////////////////
20// //
21// AliObjectArray //
22// //
23//AliObjectArray is an array of clone (identical) objects. //
24//In comparison with the TClonesArray objects in this array don't need //
25//to derive from TObject. They also don't need RTTI - type information. //
26// //
27//Objects type information is stored in object fClassInfo (instance of //
28//the AliClassInfo). //
29//Objects in array are stored sequentialy in buffers. Buffer is standart C++ //
30//array of objects. Buffers size is equal for all of the buffers. If we specify
31//fBufferSize==0 objects are stored in one big standart C++ array.
32//
33// Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk //
34//
35//Begin_Html
36/*
37<img src="../gif/AliObjectArray.gif">
38*/
39///////////////////////////////////////////////////////////////////////////////
40
41
42#include "AliObjectArray.h"
43
44ClassImp(AliObjectArray)
45
46AliObjectArray::AliObjectArray():AliMemArray()
47{
48 //
49 //default constructor
50 //
51 fClassInfo = 0;
52}
53
54AliObjectArray::AliObjectArray(const char * classname, Int_t buffersize):AliMemArray()
55{
56 //
57 // AliObject array constructor
58 // Set class information fClassInfo according specified type and set the array size -size
59 // Buufer size fBufferSize
60 fClassInfo = 0;
61 fBufferSize = buffersize;
62 SetClass(classname);
63}
64
65AliObjectArray::AliObjectArray(const AliObjectArray &arr)
66{
67 //
68 //
69 *((AliMemArray*)this) = *((AliMemArray*)&arr);
70 fClassInfo = arr.GetClassInfo();
71}
72
73
74AliObjectArray & AliObjectArray::operator=(const AliObjectArray &arr)
75{
76 //
77 //
78 *((AliMemArray*)this) = *((AliMemArray*)&arr);
79 fClassInfo = arr.GetClassInfo();
80 return (*this);
81}
82
83AliObjectArray::~AliObjectArray()
84{
85 //
86 //default destructor
87 Delete();
88}
89
90Bool_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
102void AliObjectArray::Dump(Int_t i)
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
109void AliObjectArray::Streamer(TBuffer& R__b)
110{
111 //
112 //Stream of the AliVector2D
113 //
114 TString s;
115 if (R__b.IsReading()) {
116 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
117 TObject::Streamer(R__b);
118 s.Streamer(R__b); //read class info
119 if (s!=" ") SetClass(s.Data());
120 else fClassInfo=0;
121 R__b >> fBufferSize;
122 R__b >> fObjectSize;
123 Int_t size;
124 R__b >> size;
125 Resize(size);
126 if (fSize>0){
127 if (fBufferSize==0) fClassInfo->StreamBuffer(R__b, GetArray(), fSize);
128 else
129 for (UInt_t i=0;i<GetNBuffers();i++)
130 fClassInfo->StreamBuffer(R__b, GetRow(i), fBufferSize);
131 }
132 } else {
133 R__b.WriteVersion(AliObjectArray::IsA());
134 TObject::Streamer(R__b);
135 if (fClassInfo) s = fClassInfo->GetClassName();
136 else s=" ";
137 s.Streamer(R__b);
138 R__b << fBufferSize;
139 R__b << fObjectSize;
140 R__b << fSize;
141
142 if (fSize>0){
143 if (fBufferSize==0) fClassInfo->StreamBuffer(R__b, GetArray(), fSize);
144 else
145 for (UInt_t i=0;i<GetNBuffers();i++)
146 fClassInfo->StreamBuffer(R__b, GetRow(i), fBufferSize);
147 }
148 }
149}
150
151
152
153
154