1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONObjectPair.h"
21 #include <Riostream.h>
23 /// \class AliMUONObjectPair
25 /// The equivalent of a std::pair<TObject*,TObject*> ;-)
27 /// What else can be said ? That if we'd been using STL, that class
28 /// would not be there, thus saving some octets ? No comment.
30 /// Well, in fact, there *is* a difference wrt to std::pair : here
31 /// we decide on the ownership of the first and/or second object...
33 /// \author Laurent Aphecetche
36 ClassImp(AliMUONObjectPair)
39 //_____________________________________________________________________________
40 AliMUONObjectPair::AliMUONObjectPair()
44 fIsOwnerOfFirst(kTRUE),
45 fIsOwnerOfSecond(kTRUE)
48 AliDebug(1,Form("this=%p",this));
51 //_____________________________________________________________________________
52 AliMUONObjectPair::AliMUONObjectPair(TObject* first,
54 Bool_t isOwnerOfFirst,
55 Bool_t isOwnerOfSecond)
59 fIsOwnerOfFirst(isOwnerOfFirst),
60 fIsOwnerOfSecond(isOwnerOfSecond)
63 AliDebug(1,Form("this=%p first is %s second is %s",
65 (first ? first->ClassName() : "0x0"),
66 (second ? second->ClassName() : "0x0")
71 //_____________________________________________________________________________
72 AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
76 fIsOwnerOfFirst(kTRUE),
77 fIsOwnerOfSecond(kTRUE)
80 AliDebug(1,Form("this=%p copy ctor",this));
84 //_____________________________________________________________________________
86 AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
88 /// assignement operator
90 AliMUONObjectPair pair(other);
95 //_____________________________________________________________________________
96 AliMUONObjectPair::~AliMUONObjectPair()
99 AliDebug(1,Form("this=%p",this));
100 if ( fIsOwnerOfFirst ) delete fFirst;
101 if ( fIsOwnerOfSecond ) delete fSecond;
104 //_____________________________________________________________________________
106 AliMUONObjectPair::Clear(Option_t*)
109 if ( fIsOwnerOfFirst ) delete fFirst;
110 if ( fIsOwnerOfSecond ) delete fSecond;
115 //_____________________________________________________________________________
117 AliMUONObjectPair::Copy(TObject& other) const
119 /// Copy this to other (used by copy ctor and operator=)
121 TObject::Copy(other);
122 AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
123 pair.fIsOwnerOfFirst = fIsOwnerOfFirst;
124 pair.fIsOwnerOfSecond = fIsOwnerOfSecond;
125 if ( fIsOwnerOfFirst )
127 pair.fFirst = fFirst->Clone();
131 pair.fFirst = fFirst;
133 if ( fIsOwnerOfSecond )
135 pair.fSecond = fSecond->Clone();
139 pair.fSecond = fSecond;
143 //_____________________________________________________________________________
145 AliMUONObjectPair::Print(Option_t* opt) const
162 Second()->Print(opt);