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 //-----------------------------------------------------------------------------
38 ClassImp(AliMUONObjectPair)
41 //_____________________________________________________________________________
42 AliMUONObjectPair::AliMUONObjectPair()
46 fIsOwnerOfFirst(kTRUE),
47 fIsOwnerOfSecond(kTRUE)
50 AliDebug(1,Form("this=%p",this));
53 //_____________________________________________________________________________
54 AliMUONObjectPair::AliMUONObjectPair(TObject* first,
56 Bool_t isOwnerOfFirst,
57 Bool_t isOwnerOfSecond)
61 fIsOwnerOfFirst(isOwnerOfFirst),
62 fIsOwnerOfSecond(isOwnerOfSecond)
65 AliDebug(1,Form("this=%p first is %s second is %s",
67 (first ? first->ClassName() : "0x0"),
68 (second ? second->ClassName() : "0x0")
73 //_____________________________________________________________________________
74 AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
78 fIsOwnerOfFirst(kTRUE),
79 fIsOwnerOfSecond(kTRUE)
82 AliDebug(1,Form("this=%p copy ctor",this));
86 //_____________________________________________________________________________
88 AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
90 /// assignement operator
98 //_____________________________________________________________________________
99 AliMUONObjectPair::~AliMUONObjectPair()
102 AliDebug(1,Form("this=%p",this));
103 if ( fIsOwnerOfFirst ) delete fFirst;
104 if ( fIsOwnerOfSecond ) delete fSecond;
107 //_____________________________________________________________________________
109 AliMUONObjectPair::Clear(Option_t*)
112 if ( fIsOwnerOfFirst ) delete fFirst;
113 if ( fIsOwnerOfSecond ) delete fSecond;
118 //_____________________________________________________________________________
120 AliMUONObjectPair::Copy(TObject& other) const
122 /// Copy this to other (used by copy ctor and operator=)
124 TObject::Copy(other);
125 AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
126 pair.fIsOwnerOfFirst = fIsOwnerOfFirst;
127 pair.fIsOwnerOfSecond = fIsOwnerOfSecond;
128 if ( fIsOwnerOfFirst )
130 pair.fFirst = fFirst->Clone();
134 pair.fFirst = fFirst;
136 if ( fIsOwnerOfSecond )
138 pair.fSecond = fSecond->Clone();
142 pair.fSecond = fSecond;
146 //_____________________________________________________________________________
148 AliMUONObjectPair::Print(Option_t* opt) const
165 Second()->Print(opt);