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