New classes for shuttle (Laurent)
[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
20/// \class AliMUONObjectPair
21///
22/// The equivalent of a std::pair<TObject*,TObject*> ;-)
23///
24/// What else can be said ? That if we'd been using STL, that class
25/// would not be there, thus saving some octets ? No comment.
26///
27/// Well, in fact, there *is* a difference wrt to std::pair : here
28/// we decide on the ownership of the first and/or second object...
29///
30/// \author Laurent Aphecetche
31
32/// \cond CLASSIMP
33ClassImp(AliMUONObjectPair)
34/// \endcond
35
36//_____________________________________________________________________________
37AliMUONObjectPair::AliMUONObjectPair()
38: TObject(),
39fFirst(0x0),
40fSecond(0x0),
41fIsOwnerOfFirst(kTRUE),
42fIsOwnerOfSecond(kTRUE)
43{
44 /// ctor
45}
46
47//_____________________________________________________________________________
48AliMUONObjectPair::AliMUONObjectPair(TObject* first,
49 TObject* second,
50 Bool_t isOwnerOfFirst,
51 Bool_t isOwnerOfSecond)
52: TObject(),
53fFirst(first),
54fSecond(second),
55fIsOwnerOfFirst(isOwnerOfFirst),
56fIsOwnerOfSecond(isOwnerOfSecond)
57{
58 /// ctor
59}
60
61//_____________________________________________________________________________
62AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
63: TObject(other),
64fFirst(0x0),
65fSecond(0x0),
66fIsOwnerOfFirst(kTRUE),
67fIsOwnerOfSecond(kTRUE)
68{
69 /// copy ctor
70 other.Copy(*this);
71}
72
73//_____________________________________________________________________________
74AliMUONObjectPair&
75AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
76{
77 /// assignement operator
78 AliMUONObjectPair pair(other);
79 pair.Copy(*this);
80 return *this;
81}
82
83//_____________________________________________________________________________
84AliMUONObjectPair::~AliMUONObjectPair()
85{
86 /// dtor
87 if ( fIsOwnerOfFirst ) delete fFirst;
88 if ( fIsOwnerOfSecond ) delete fSecond;
89}
90
91//_____________________________________________________________________________
92void
93AliMUONObjectPair::Copy(TObject& other) const
94{
95 /// Copy this to other (used by copy ctor and operator=)
96
97 TObject::Copy(other);
98 AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
99 pair.fIsOwnerOfFirst = fIsOwnerOfFirst;
100 pair.fIsOwnerOfSecond = fIsOwnerOfSecond;
101 if ( fIsOwnerOfFirst )
102 {
103 pair.fFirst = fFirst->Clone();
104 }
105 else
106 {
107 pair.fFirst = fFirst;
108 }
109 if ( fIsOwnerOfSecond )
110 {
111 pair.fSecond = fSecond->Clone();
112 }
113 else
114 {
115 pair.fSecond = fSecond;
116 }
117}