1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONObjectPair.h"
20 /// \class AliMUONObjectPair
22 /// The equivalent of a std::pair<TObject*,TObject*> ;-)
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.
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...
30 /// \author Laurent Aphecetche
33 ClassImp(AliMUONObjectPair)
36 //_____________________________________________________________________________
37 AliMUONObjectPair::AliMUONObjectPair()
41 fIsOwnerOfFirst(kTRUE),
42 fIsOwnerOfSecond(kTRUE)
47 //_____________________________________________________________________________
48 AliMUONObjectPair::AliMUONObjectPair(TObject* first,
50 Bool_t isOwnerOfFirst,
51 Bool_t isOwnerOfSecond)
55 fIsOwnerOfFirst(isOwnerOfFirst),
56 fIsOwnerOfSecond(isOwnerOfSecond)
61 //_____________________________________________________________________________
62 AliMUONObjectPair::AliMUONObjectPair(const AliMUONObjectPair& other)
66 fIsOwnerOfFirst(kTRUE),
67 fIsOwnerOfSecond(kTRUE)
73 //_____________________________________________________________________________
75 AliMUONObjectPair::operator=(const AliMUONObjectPair& other)
77 /// assignement operator
78 AliMUONObjectPair pair(other);
83 //_____________________________________________________________________________
84 AliMUONObjectPair::~AliMUONObjectPair()
87 if ( fIsOwnerOfFirst ) delete fFirst;
88 if ( fIsOwnerOfSecond ) delete fSecond;
91 //_____________________________________________________________________________
93 AliMUONObjectPair::Copy(TObject& other) const
95 /// Copy this to other (used by copy ctor and operator=)
98 AliMUONObjectPair& pair = (AliMUONObjectPair&)(other);
99 pair.fIsOwnerOfFirst = fIsOwnerOfFirst;
100 pair.fIsOwnerOfSecond = fIsOwnerOfSecond;
101 if ( fIsOwnerOfFirst )
103 pair.fFirst = fFirst->Clone();
107 pair.fFirst = fFirst;
109 if ( fIsOwnerOfSecond )
111 pair.fSecond = fSecond->Clone();
115 pair.fSecond = fSecond;