]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONObjectPair.cxx
typo fix
[u/mrichter/AliRoot.git] / MUON / AliMUONObjectPair.cxx
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 //-----------------------------------------------------------------------------
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
35 //-----------------------------------------------------------------------------
36
37 using std::cout;
38 using std::endl;
39 /// \cond CLASSIMP
40 ClassImp(AliMUONObjectPair)
41 /// \endcond
42
43 //_____________________________________________________________________________
44 AliMUONObjectPair::AliMUONObjectPair() 
45 : TObject(),
46 fFirst(0x0),
47 fSecond(0x0),
48 fIsOwnerOfFirst(kTRUE),
49 fIsOwnerOfSecond(kTRUE)
50 {
51   /// ctor
52   AliDebug(1,Form("this=%p",this));
53 }
54
55 //_____________________________________________________________________________
56 AliMUONObjectPair::AliMUONObjectPair(TObject* first, 
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 {
66   /// ctor
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 //_____________________________________________________________________________
76 AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
77 : TObject(other),
78 fFirst(0x0),
79 fSecond(0x0),
80 fIsOwnerOfFirst(kTRUE),
81 fIsOwnerOfSecond(kTRUE)
82 {
83   /// copy ctor
84   AliDebug(1,Form("this=%p copy ctor",this));
85   other.Copy(*this);
86 }
87
88 //_____________________________________________________________________________
89 AliMUONObjectPair& 
90 AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
91 {
92   /// assignement operator
93   if ( this != &other)
94   {
95     other.Copy(*this);
96   }
97   return *this;
98 }
99
100 //_____________________________________________________________________________
101 AliMUONObjectPair::~AliMUONObjectPair()
102 {
103   /// dtor
104   AliDebug(1,Form("this=%p",this));
105   if ( fIsOwnerOfFirst ) delete fFirst;
106   if ( fIsOwnerOfSecond ) delete fSecond;
107 }
108
109 //_____________________________________________________________________________
110 void
111 AliMUONObjectPair::Clear(Option_t*)
112 {
113   /// Reset
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 {
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 }
147
148 //_____________________________________________________________________________
149 void
150 AliMUONObjectPair::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 }