LCOV - code coverage report
Current view: top level - MUON/MUONcore - AliMUONObjectPair.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 27 66 40.9 %
Date: 2016-06-14 17:26:59 Functions: 9 14 64.3 %

          Line data    Source code
       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             : #include "AliMUONObjectPair.h"
      19             : 
      20             : #include "AliLog.h"
      21             : #include <Riostream.h>
      22             : 
      23             : //-----------------------------------------------------------------------------
      24             : /// \class AliMUONObjectPair
      25             : ///
      26             : /// The equivalent of a std::pair<TObject*,TObject*> ;-)
      27             : ///
      28             : /// What else can be said ? That if we'd been using STL, that class
      29             : /// would not be there, thus saving some octets ? No comment.
      30             : /// 
      31             : /// Well, in fact, there *is* a difference wrt to std::pair : here
      32             : /// we decide on the ownership of the first and/or second object...
      33             : ///
      34             : /// \author Laurent Aphecetche
      35             : //-----------------------------------------------------------------------------
      36             : 
      37             : using std::cout;
      38             : using std::endl;
      39             : /// \cond CLASSIMP
      40          18 : ClassImp(AliMUONObjectPair)
      41             : /// \endcond
      42             : 
      43             : //_____________________________________________________________________________
      44             : AliMUONObjectPair::AliMUONObjectPair() 
      45         137 : : TObject(),
      46         137 : fFirst(0x0),
      47         137 : fSecond(0x0),
      48         137 : fIsOwnerOfFirst(kTRUE),
      49         137 : fIsOwnerOfSecond(kTRUE)
      50         685 : {
      51             :   /// ctor
      52         685 :   AliDebug(1,Form("this=%p",this));
      53         274 : }
      54             : 
      55             : //_____________________________________________________________________________
      56             : AliMUONObjectPair::AliMUONObjectPair(TObject* first, 
      57             :                   TObject* second,
      58             :                   Bool_t isOwnerOfFirst,
      59             :                   Bool_t isOwnerOfSecond)
      60          90 : : TObject(),
      61          90 : fFirst(first),
      62          90 : fSecond(second),
      63          90 : fIsOwnerOfFirst(isOwnerOfFirst),
      64          90 : fIsOwnerOfSecond(isOwnerOfSecond)
      65         270 : {
      66             :   /// ctor
      67         450 :   AliDebug(1,Form("this=%p first is %s second is %s",
      68             :                   this,
      69             :                   (first ? first->ClassName() : "0x0"),
      70             :                   (second ? second->ClassName() : "0x0")
      71             :                   ));
      72             : 
      73         180 : }
      74             : 
      75             : //_____________________________________________________________________________
      76             : AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
      77           0 : : TObject(other),
      78           0 : fFirst(0x0),
      79           0 : fSecond(0x0),
      80           0 : fIsOwnerOfFirst(kTRUE),
      81           0 : fIsOwnerOfSecond(kTRUE)
      82           0 : {
      83             :   /// copy ctor
      84           0 :   AliDebug(1,Form("this=%p copy ctor",this));
      85           0 :   other.Copy(*this);
      86           0 : }
      87             : 
      88             : //_____________________________________________________________________________
      89             : AliMUONObjectPair& 
      90             : AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
      91             : {
      92             :   /// assignement operator
      93           0 :   if ( this != &other)
      94             :   {
      95           0 :     other.Copy(*this);
      96           0 :   }
      97           0 :   return *this;
      98             : }
      99             : 
     100             : //_____________________________________________________________________________
     101             : AliMUONObjectPair::~AliMUONObjectPair()
     102        1158 : {
     103             :   /// dtor
     104         965 :   AliDebug(1,Form("this=%p",this));
     105         579 :   if ( fIsOwnerOfFirst ) delete fFirst;
     106         579 :   if ( fIsOwnerOfSecond ) delete fSecond;
     107         579 : }
     108             : 
     109             : //_____________________________________________________________________________
     110             : void
     111             : AliMUONObjectPair::Clear(Option_t*)
     112             : {
     113             :   /// Reset
     114          56 :   if ( fIsOwnerOfFirst ) delete fFirst;
     115          28 :   if ( fIsOwnerOfSecond ) delete fSecond;
     116          28 :   fFirst = 0x0;
     117          28 :   fSecond = 0x0;
     118          28 : }
     119             : 
     120             : //_____________________________________________________________________________
     121             : void
     122             : AliMUONObjectPair::Copy(TObject& other) const
     123             : {
     124             :   /// Copy this to other (used by copy ctor and operator=)
     125             :   
     126           0 :   TObject::Copy(other);
     127           0 :   AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
     128           0 :   pair.fIsOwnerOfFirst = fIsOwnerOfFirst;
     129           0 :   pair.fIsOwnerOfSecond = fIsOwnerOfSecond;
     130           0 :   if ( fIsOwnerOfFirst ) 
     131             :   {
     132           0 :     pair.fFirst = fFirst->Clone();
     133           0 :   }
     134             :   else
     135             :   {
     136           0 :     pair.fFirst = fFirst;
     137             :   }
     138           0 :   if ( fIsOwnerOfSecond )
     139             :   {
     140           0 :     pair.fSecond = fSecond->Clone();
     141           0 :   }
     142             :   else
     143             :   {
     144           0 :     pair.fSecond = fSecond;
     145             :   }
     146           0 : }
     147             : 
     148             : //_____________________________________________________________________________
     149             : void
     150             : AliMUONObjectPair::Print(Option_t* opt) const
     151             : {
     152             :   /// Printout
     153             :   
     154           0 :   cout << "First:";
     155           0 :   if ( First() ) 
     156             :   {
     157           0 :     First()->Print(opt);
     158           0 :   }
     159             :   else
     160             :   {
     161           0 :     cout << " NULL ";
     162             :   }
     163           0 :   cout << endl;
     164           0 :   cout << "Second:";
     165           0 :   if ( Second() ) 
     166             :   {
     167           0 :     Second()->Print(opt);
     168           0 :   }
     169             :   else
     170             :   {
     171           0 :     cout << " NULL ";
     172             :   }
     173           0 :   cout << endl;    
     174           0 : }

Generated by: LCOV version 1.11