]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliObjMatrix.cxx
Update of package classes.
[u/mrichter/AliRoot.git] / RALICE / AliObjMatrix.cxx
index 87173c413a25da4083cc118af092e7b943bd6031..1d93c7b838f1c826f83f91ee3dc96b281be8d10d 100644 (file)
@@ -81,7 +81,7 @@
  
 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.
@@ -110,6 +110,40 @@ AliObjMatrix::~AliObjMatrix()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
+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.
@@ -159,7 +193,7 @@ void AliObjMatrix::SetOwner(Int_t own)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetOwner()
+Int_t AliObjMatrix::GetOwner() const
 {
 // Provide the owner flag for the stored objects.
  return fOwn;
@@ -189,7 +223,7 @@ void AliObjMatrix::SetSwapMode(Int_t swap)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliObjMatrix::GetSwapMode()
+Int_t AliObjMatrix::GetSwapMode() const
 {
 // Provide the swap mode flag for this matrix.
  return fSwap;
@@ -369,7 +403,7 @@ void AliObjMatrix::RemoveObjects(TObject* obj,Int_t row,Int_t col)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-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
@@ -396,7 +430,7 @@ TObject* AliObjMatrix::GetObject(Int_t row,Int_t col)
  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.
@@ -428,19 +462,19 @@ TObjArray* AliObjMatrix::GetObjects()
  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;
@@ -449,7 +483,7 @@ Int_t AliObjMatrix::GetNobjects()
  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.
@@ -466,7 +500,7 @@ Int_t AliObjMatrix::GetNrefs(TObject* obj)
  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.
@@ -528,7 +562,7 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,TArrayI& cols)
  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.
@@ -629,7 +663,7 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,Int_t row,TArrayI& cols)
  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.
@@ -730,3 +764,18 @@ Int_t AliObjMatrix::GetIndices(TObject* obj,TArrayI& rows,Int_t col)
  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;
+}
+///////////////////////////////////////////////////////////////////////////