]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONObjectPair.cxx
No more misaligned_geometry
[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 /// \class AliMUONObjectPair
24 ///
25 /// The equivalent of a std::pair<TObject*,TObject*> ;-)
26 ///
27 /// What else can be said ? That if we'd been using STL, that class
28 /// would not be there, thus saving some octets ? No comment.
29 /// 
30 /// Well, in fact, there *is* a difference wrt to std::pair : here
31 /// we decide on the ownership of the first and/or second object...
32 ///
33 /// \author Laurent Aphecetche
34
35 /// \cond CLASSIMP
36 ClassImp(AliMUONObjectPair)
37 /// \endcond
38
39 //_____________________________________________________________________________
40 AliMUONObjectPair::AliMUONObjectPair() 
41 : TObject(),
42 fFirst(0x0),
43 fSecond(0x0),
44 fIsOwnerOfFirst(kTRUE),
45 fIsOwnerOfSecond(kTRUE)
46 {
47   /// ctor
48   AliDebug(1,Form("this=%p",this));
49 }
50
51 //_____________________________________________________________________________
52 AliMUONObjectPair::AliMUONObjectPair(TObject* first, 
53                   TObject* second,
54                   Bool_t isOwnerOfFirst,
55                   Bool_t isOwnerOfSecond)
56 : TObject(),
57 fFirst(first),
58 fSecond(second),
59 fIsOwnerOfFirst(isOwnerOfFirst),
60 fIsOwnerOfSecond(isOwnerOfSecond)
61 {
62   /// ctor
63   AliDebug(1,Form("this=%p first is %s second is %s",
64                   this,
65                   (first ? first->ClassName() : "0x0"),
66                   (second ? second->ClassName() : "0x0")
67                   ));
68
69 }
70
71 //_____________________________________________________________________________
72 AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
73 : TObject(other),
74 fFirst(0x0),
75 fSecond(0x0),
76 fIsOwnerOfFirst(kTRUE),
77 fIsOwnerOfSecond(kTRUE)
78 {
79   /// copy ctor
80   AliDebug(1,Form("this=%p copy ctor",this));
81   other.Copy(*this);
82 }
83
84 //_____________________________________________________________________________
85 AliMUONObjectPair& 
86 AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
87 {
88   /// assignement operator
89   AliDebug(1,"");
90   AliMUONObjectPair pair(other);
91   pair.Copy(*this);
92   return *this;
93 }
94
95 //_____________________________________________________________________________
96 AliMUONObjectPair::~AliMUONObjectPair()
97 {
98   /// dtor
99   AliDebug(1,Form("this=%p",this));
100   if ( fIsOwnerOfFirst ) delete fFirst;
101   if ( fIsOwnerOfSecond ) delete fSecond;
102 }
103
104 //_____________________________________________________________________________
105 void
106 AliMUONObjectPair::Clear(Option_t*)
107 {
108   /// Reset
109   if ( fIsOwnerOfFirst ) delete fFirst;
110   if ( fIsOwnerOfSecond ) delete fSecond;
111   fFirst = 0x0;
112   fSecond = 0x0;
113 }
114
115 //_____________________________________________________________________________
116 void
117 AliMUONObjectPair::Copy(TObject& other) const
118 {
119   /// Copy this to other (used by copy ctor and operator=)
120   
121   TObject::Copy(other);
122   AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
123   pair.fIsOwnerOfFirst = fIsOwnerOfFirst;
124   pair.fIsOwnerOfSecond = fIsOwnerOfSecond;
125   if ( fIsOwnerOfFirst ) 
126   {
127     pair.fFirst = fFirst->Clone();
128   }
129   else
130   {
131     pair.fFirst = fFirst;
132   }
133   if ( fIsOwnerOfSecond )
134   {
135     pair.fSecond = fSecond->Clone();
136   }
137   else
138   {
139     pair.fSecond = fSecond;
140   }
141 }
142
143 //_____________________________________________________________________________
144 void
145 AliMUONObjectPair::Print(Option_t* opt) const
146 {
147   /// Printout
148   
149   cout << "First:";
150   if ( First() ) 
151   {
152     First()->Print(opt);
153   }
154   else
155   {
156     cout << " NULL ";
157   }
158   cout << endl;
159   cout << "Second:";
160   if ( Second() ) 
161   {
162     Second()->Print(opt);
163   }
164   else
165   {
166     cout << " NULL ";
167   }
168   cout << endl;    
169 }