]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONObjectPair.cxx
Coverity fix
[u/mrichter/AliRoot.git] / MUON / AliMUONObjectPair.cxx
index b55cd1c10a205e89ed4fddc4ff3f8c7037db1d7c..38b39ed8fba925de630d2edd524c7e3df9ebb1ee 100644 (file)
 
 #include "AliMUONObjectPair.h"
 
+#include "AliLog.h"
+#include <Riostream.h>
+
+//-----------------------------------------------------------------------------
 /// \class AliMUONObjectPair
 ///
 /// The equivalent of a std::pair<TObject*,TObject*> ;-)
@@ -28,6 +32,7 @@
 /// we decide on the ownership of the first and/or second object...
 ///
 /// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
 
 /// \cond CLASSIMP
 ClassImp(AliMUONObjectPair)
@@ -42,6 +47,7 @@ fIsOwnerOfFirst(kTRUE),
 fIsOwnerOfSecond(kTRUE)
 {
   /// ctor
+  AliDebug(1,Form("this=%p",this));
 }
 
 //_____________________________________________________________________________
@@ -56,6 +62,12 @@ fIsOwnerOfFirst(isOwnerOfFirst),
 fIsOwnerOfSecond(isOwnerOfSecond)
 {
   /// ctor
+  AliDebug(1,Form("this=%p first is %s second is %s",
+                  this,
+                  (first ? first->ClassName() : "0x0"),
+                  (second ? second->ClassName() : "0x0")
+                  ));
+
 }
 
 //_____________________________________________________________________________
@@ -67,6 +79,7 @@ fIsOwnerOfFirst(kTRUE),
 fIsOwnerOfSecond(kTRUE)
 {
   /// copy ctor
+  AliDebug(1,Form("this=%p copy ctor",this));
   other.Copy(*this);
 }
 
@@ -75,8 +88,10 @@ AliMUONObjectPair&
 AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
 {
   /// assignement operator
-  AliMUONObjectPair pair(other);
-  pair.Copy(*this);
+  if ( this != &other)
+  {
+    other.Copy(*this);
+  }
   return *this;
 }
 
@@ -84,8 +99,20 @@ AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
 AliMUONObjectPair::~AliMUONObjectPair()
 {
   /// dtor
+  AliDebug(1,Form("this=%p",this));
+  if ( fIsOwnerOfFirst ) delete fFirst;
+  if ( fIsOwnerOfSecond ) delete fSecond;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONObjectPair::Clear(Option_t*)
+{
+  /// Reset
   if ( fIsOwnerOfFirst ) delete fFirst;
   if ( fIsOwnerOfSecond ) delete fSecond;
+  fFirst = 0x0;
+  fSecond = 0x0;
 }
 
 //_____________________________________________________________________________
@@ -115,3 +142,31 @@ AliMUONObjectPair::Copy(TObject& other) const
     pair.fSecond = fSecond;
   }
 }
+
+//_____________________________________________________________________________
+void
+AliMUONObjectPair::Print(Option_t* opt) const
+{
+  /// Printout
+  
+  cout << "First:";
+  if ( First() ) 
+  {
+    First()->Print(opt);
+  }
+  else
+  {
+    cout << " NULL ";
+  }
+  cout << endl;
+  cout << "Second:";
+  if ( Second() ) 
+  {
+    Second()->Print(opt);
+  }
+  else
+  {
+    cout << " NULL ";
+  }
+  cout << endl;    
+}