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 //-----------------------------------------------------------------------------
24 /// \class AliMUONObjectPair
26 /// The equivalent of a std::pair<TObject*,TObject*> ;-)
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.
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...
34 /// \author Laurent Aphecetche
35 //-----------------------------------------------------------------------------
40 ClassImp(AliMUONObjectPair)
43 //_____________________________________________________________________________
44 AliMUONObjectPair::AliMUONObjectPair()
48 fIsOwnerOfFirst(kTRUE),
49 fIsOwnerOfSecond(kTRUE)
52 AliDebug(1,Form("this=%p",this));
55 //_____________________________________________________________________________
56 AliMUONObjectPair::AliMUONObjectPair(TObject* first,
58 Bool_t isOwnerOfFirst,
59 Bool_t isOwnerOfSecond)
63 fIsOwnerOfFirst(isOwnerOfFirst),
64 fIsOwnerOfSecond(isOwnerOfSecond)
67 AliDebug(1,Form("this=%p first is %s second is %s",
69 (first ? first->ClassName() : "0x0"),
70 (second ? second->ClassName() : "0x0")
75 //_____________________________________________________________________________
76 AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
80 fIsOwnerOfFirst(kTRUE),
81 fIsOwnerOfSecond(kTRUE)
84 AliDebug(1,Form("this=%p copy ctor",this));
88 //_____________________________________________________________________________
90 AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
92 /// assignement operator
100 //_____________________________________________________________________________
101 AliMUONObjectPair::~AliMUONObjectPair()
104 AliDebug(1,Form("this=%p",this));
105 if ( fIsOwnerOfFirst ) delete fFirst;
106 if ( fIsOwnerOfSecond ) delete fSecond;
109 //_____________________________________________________________________________
111 AliMUONObjectPair::Clear(Option_t*)
114 if ( fIsOwnerOfFirst ) delete fFirst;
115 if ( fIsOwnerOfSecond ) delete fSecond;
120 //_____________________________________________________________________________
122 AliMUONObjectPair::Copy(TObject& other) const
124 /// Copy this to other (used by copy ctor and operator=)
126 TObject::Copy(other);
127 AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
128 pair.fIsOwnerOfFirst = fIsOwnerOfFirst;
129 pair.fIsOwnerOfSecond = fIsOwnerOfSecond;
130 if ( fIsOwnerOfFirst )
132 pair.fFirst = fFirst->Clone();
136 pair.fFirst = fFirst;
138 if ( fIsOwnerOfSecond )
140 pair.fSecond = fSecond->Clone();
144 pair.fSecond = fSecond;
148 //_____________________________________________________________________________
150 AliMUONObjectPair::Print(Option_t* opt) const
167 Second()->Print(opt);