]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONObjectPair.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / MUON / AliMUONObjectPair.cxx
CommitLineData
ea199e33 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
17fa9d8f 20#include "AliLog.h"
21#include <Riostream.h>
22
3d1463c8 23//-----------------------------------------------------------------------------
ea199e33 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
3d1463c8 35//-----------------------------------------------------------------------------
ea199e33 36
b80faac0 37using std::cout;
38using std::endl;
ea199e33 39/// \cond CLASSIMP
40ClassImp(AliMUONObjectPair)
41/// \endcond
42
43//_____________________________________________________________________________
44AliMUONObjectPair::AliMUONObjectPair()
45: TObject(),
46fFirst(0x0),
47fSecond(0x0),
48fIsOwnerOfFirst(kTRUE),
49fIsOwnerOfSecond(kTRUE)
50{
51 /// ctor
17fa9d8f 52 AliDebug(1,Form("this=%p",this));
ea199e33 53}
54
55//_____________________________________________________________________________
56AliMUONObjectPair::AliMUONObjectPair(TObject* first,
57 TObject* second,
58 Bool_t isOwnerOfFirst,
59 Bool_t isOwnerOfSecond)
60: TObject(),
61fFirst(first),
62fSecond(second),
63fIsOwnerOfFirst(isOwnerOfFirst),
64fIsOwnerOfSecond(isOwnerOfSecond)
65{
66 /// ctor
17fa9d8f 67 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
ea199e33 73}
74
75//_____________________________________________________________________________
76AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
77: TObject(other),
78fFirst(0x0),
79fSecond(0x0),
80fIsOwnerOfFirst(kTRUE),
81fIsOwnerOfSecond(kTRUE)
82{
83 /// copy ctor
17fa9d8f 84 AliDebug(1,Form("this=%p copy ctor",this));
ea199e33 85 other.Copy(*this);
86}
87
88//_____________________________________________________________________________
89AliMUONObjectPair&
90AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
91{
92 /// assignement operator
0c8556b9 93 if ( this != &other)
94 {
95 other.Copy(*this);
96 }
ea199e33 97 return *this;
98}
99
100//_____________________________________________________________________________
101AliMUONObjectPair::~AliMUONObjectPair()
102{
103 /// dtor
17fa9d8f 104 AliDebug(1,Form("this=%p",this));
ea199e33 105 if ( fIsOwnerOfFirst ) delete fFirst;
106 if ( fIsOwnerOfSecond ) delete fSecond;
107}
108
17fa9d8f 109//_____________________________________________________________________________
110void
111AliMUONObjectPair::Clear(Option_t*)
112{
113 /// Reset
114 if ( fIsOwnerOfFirst ) delete fFirst;
115 if ( fIsOwnerOfSecond ) delete fSecond;
116 fFirst = 0x0;
117 fSecond = 0x0;
118}
119
ea199e33 120//_____________________________________________________________________________
121void
122AliMUONObjectPair::Copy(TObject& other) const
123{
124 /// Copy this to other (used by copy ctor and operator=)
125
126 TObject::Copy(other);
127 AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
128 pair.fIsOwnerOfFirst = fIsOwnerOfFirst;
129 pair.fIsOwnerOfSecond = fIsOwnerOfSecond;
130 if ( fIsOwnerOfFirst )
131 {
132 pair.fFirst = fFirst->Clone();
133 }
134 else
135 {
136 pair.fFirst = fFirst;
137 }
138 if ( fIsOwnerOfSecond )
139 {
140 pair.fSecond = fSecond->Clone();
141 }
142 else
143 {
144 pair.fSecond = fSecond;
145 }
146}
17fa9d8f 147
148//_____________________________________________________________________________
149void
150AliMUONObjectPair::Print(Option_t* opt) const
151{
152 /// Printout
153
154 cout << "First:";
155 if ( First() )
156 {
157 First()->Print(opt);
158 }
159 else
160 {
161 cout << " NULL ";
162 }
163 cout << endl;
164 cout << "Second:";
165 if ( Second() )
166 {
167 Second()->Print(opt);
168 }
169 else
170 {
171 cout << " NULL ";
172 }
173 cout << endl;
174}