ClassImp(AliObjMatrix) // Class implementation to enable ROOT I/O
-AliObjMatrix::AliObjMatrix() : TObject()
+AliObjMatrix::AliObjMatrix() : TNamed()
{
// Default constructor.
// Note : The owner and swap mode flags will be initialised to 0.
}
}
///////////////////////////////////////////////////////////////////////////
+AliObjMatrix::AliObjMatrix(const AliObjMatrix& m) : TNamed(m)
+{
+// Copy constructor
+
+ fRows=0;
+ fMaxrow=0;
+ fMaxcol=0;
+ fObjects=0;
+
+ fOwn=m.fOwn;
+ fSwap=m.fSwap;
+
+ Int_t maxrow=m.GetMaxRow();
+ Int_t maxcol=m.GetMaxColumn();
+ for (Int_t irow=1; irow<=maxrow; irow++)
+ {
+ for (Int_t icol=1; icol<=maxcol; icol++)
+ {
+ TObject* obj=m.GetObject(irow,icol);
+ if (obj)
+ {
+ if (!fOwn)
+ {
+ EnterObject(irow,icol,obj);
+ }
+ else
+ {
+ EnterObject(irow,icol,obj->Clone());
+ }
+ }
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
void AliObjMatrix::Reset()
{
// Reset the whole matrix structure.
}
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetOwner()
+Int_t AliObjMatrix::GetOwner() const
{
// Provide the owner flag for the stored objects.
return fOwn;
}
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetSwapMode()
+Int_t AliObjMatrix::GetSwapMode() const
{
// Provide the swap mode flag for this matrix.
return fSwap;
}
}
///////////////////////////////////////////////////////////////////////////
-TObject* AliObjMatrix::GetObject(Int_t row,Int_t col)
+TObject* AliObjMatrix::GetObject(Int_t row,Int_t col) const
{
// Provide a pointer to the object stored at the matrix location (row,col).
// In case no object was stored at the indicated location or the location
return obj;
}
///////////////////////////////////////////////////////////////////////////
-TObject* AliObjMatrix::GetObject(Int_t j)
+TObject* AliObjMatrix::GetObject(Int_t j) const
{
// Provide a pointer to the j-th stored object.
// In case the index j is invalid, a value 0 will be returned.
return fObjects;
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetMaxRow()
+Int_t AliObjMatrix::GetMaxRow() const
{
// Provide the maximum row number index.
return fMaxrow;
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetMaxColumn()
+Int_t AliObjMatrix::GetMaxColumn() const
{
// Provide the maximum column number index.
return fMaxcol;
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetNobjects()
+Int_t AliObjMatrix::GetNobjects() const
{
// Provide the number of stored objects.
Int_t nobj=0;
return nobj;
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetNrefs(TObject* obj)
+Int_t AliObjMatrix::GetNrefs(TObject* obj) const
{
// Provide the number of stored references to the specified object.
// If obj=0 the total number of stored references for all objects is returned.
return nrefs;
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,TArrayI& cols)
+Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,TArrayI& cols) const
{
// Provide the (row,col) indices of all the storage locations of the
// specified object.
return nrefs;
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetIndices(TObject* obj,Int_t row,TArrayI& cols)
+Int_t AliObjMatrix::GetIndices(TObject* obj,Int_t row,TArrayI& cols) const
{
// Provide the column indices of all the storage locations of the
// specified object in the specified row of the matrix.
return jref;
}
///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,Int_t col)
+Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,Int_t col) const
{
// Provide the row indices of all the storage locations of the
// specified object in the specified column of the matrix.
return jref;
}
///////////////////////////////////////////////////////////////////////////
+TObject* AliObjMatrix::Clone(const char* name) const
+{
+// Make a deep copy of the current object and provide the pointer to the copy.
+// This memberfunction enables automatic creation of new objects of the
+// correct type depending on the object type, a feature which may be very useful
+// for containers when adding objects in case the container owns the objects.
+
+ AliObjMatrix* m=new AliObjMatrix(*this);
+ if (name)
+ {
+ if (strlen(name)) m->SetName(name);
+ }
+ return m;
+}
+///////////////////////////////////////////////////////////////////////////