]>
Commit | Line | Data |
---|---|---|
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 | |
33 | ClassImp(AliMUONObjectPair) | |
34 | /// \endcond | |
35 | ||
36 | //_____________________________________________________________________________ | |
37 | AliMUONObjectPair::AliMUONObjectPair() | |
38 | : TObject(), | |
39 | fFirst(0x0), | |
40 | fSecond(0x0), | |
41 | fIsOwnerOfFirst(kTRUE), | |
42 | fIsOwnerOfSecond(kTRUE) | |
43 | { | |
44 | /// ctor | |
45 | } | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliMUONObjectPair::AliMUONObjectPair(TObject* first, | |
49 | TObject* second, | |
50 | Bool_t isOwnerOfFirst, | |
51 | Bool_t isOwnerOfSecond) | |
52 | : TObject(), | |
53 | fFirst(first), | |
54 | fSecond(second), | |
55 | fIsOwnerOfFirst(isOwnerOfFirst), | |
56 | fIsOwnerOfSecond(isOwnerOfSecond) | |
57 | { | |
58 | /// ctor | |
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other) | |
63 | : TObject(other), | |
64 | fFirst(0x0), | |
65 | fSecond(0x0), | |
66 | fIsOwnerOfFirst(kTRUE), | |
67 | fIsOwnerOfSecond(kTRUE) | |
68 | { | |
69 | /// copy ctor | |
70 | other.Copy(*this); | |
71 | } | |
72 | ||
73 | //_____________________________________________________________________________ | |
74 | AliMUONObjectPair& | |
75 | AliMUONObjectPair::operator=(const AliMUONObjectPair& other) | |
76 | { | |
77 | /// assignement operator | |
78 | AliMUONObjectPair pair(other); | |
79 | pair.Copy(*this); | |
80 | return *this; | |
81 | } | |
82 | ||
83 | //_____________________________________________________________________________ | |
84 | AliMUONObjectPair::~AliMUONObjectPair() | |
85 | { | |
86 | /// dtor | |
87 | if ( fIsOwnerOfFirst ) delete fFirst; | |
88 | if ( fIsOwnerOfSecond ) delete fSecond; | |
89 | } | |
90 | ||
91 | //_____________________________________________________________________________ | |
92 | void | |
93 | AliMUONObjectPair::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 | } |