AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONObjectPair.cxx
Go to the documentation of this file.
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 
20 #include "AliLog.h"
21 #include <Riostream.h>
22 
23 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
36 
37 using std::cout;
38 using std::endl;
42 
43 //_____________________________________________________________________________
45 : TObject(),
46 fFirst(0x0),
47 fSecond(0x0),
48 fIsOwnerOfFirst(kTRUE),
49 fIsOwnerOfSecond(kTRUE)
50 {
52  AliDebug(1,Form("this=%p",this));
53 }
54 
55 //_____________________________________________________________________________
57  TObject* second,
58  Bool_t isOwnerOfFirst,
59  Bool_t isOwnerOfSecond)
60 : TObject(),
61 fFirst(first),
62 fSecond(second),
63 fIsOwnerOfFirst(isOwnerOfFirst),
64 fIsOwnerOfSecond(isOwnerOfSecond)
65 {
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 
73 }
74 
75 //_____________________________________________________________________________
77 : TObject(other),
78 fFirst(0x0),
79 fSecond(0x0),
80 fIsOwnerOfFirst(kTRUE),
81 fIsOwnerOfSecond(kTRUE)
82 {
84  AliDebug(1,Form("this=%p copy ctor",this));
85  other.Copy(*this);
86 }
87 
88 //_____________________________________________________________________________
91 {
93  if ( this != &other)
94  {
95  other.Copy(*this);
96  }
97  return *this;
98 }
99 
100 //_____________________________________________________________________________
102 {
104  AliDebug(1,Form("this=%p",this));
105  if ( fIsOwnerOfFirst ) delete fFirst;
106  if ( fIsOwnerOfSecond ) delete fSecond;
107 }
108 
109 //_____________________________________________________________________________
110 void
112 {
114  if ( fIsOwnerOfFirst ) delete fFirst;
115  if ( fIsOwnerOfSecond ) delete fSecond;
116  fFirst = 0x0;
117  fSecond = 0x0;
118 }
119 
120 //_____________________________________________________________________________
121 void
122 AliMUONObjectPair::Copy(TObject& other) const
123 {
125 
126  TObject::Copy(other);
127  AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
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 }
147 
148 //_____________________________________________________________________________
149 void
150 AliMUONObjectPair::Print(Option_t* opt) const
151 {
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 }
Bool_t fIsOwnerOfSecond
whether we own the second element
TObject * First() const
Return the first element of the pair.
AliMUONObjectPair & operator=(const AliMUONObjectPair &other)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
TObject * fSecond
second element of the pair
TObject * Second() const
Return the second element of the pair.
virtual void Clear(Option_t *opt="")
Bool_t fIsOwnerOfFirst
whether we own the first element
TObject * fFirst
first element of the pair
virtual void Copy(TObject &other) const
virtual void Print(Option_t *opt="") const
The equivalent of a std::pair<TObject*,TObject*> ;-)