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