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 // Class AliMpStringObjMap
19 // ------------------------------------
20 // Helper class that substitutes map <string, int>
21 // which ALICE does not allow to use
23 // Author: Ivana Hrivnacova, IPN Orsay
25 #include <Riostream.h>
26 #include <TObjString.h>
28 #include "AliMpStringObjMap.h"
31 ClassImp(AliMpStringObjMap)
33 //______________________________________________________________________________
34 AliMpStringObjMap::AliMpStringObjMap()
40 /// Standard constructor
42 fFirstArray.SetOwner(true);
45 //______________________________________________________________________________
46 AliMpStringObjMap::AliMpStringObjMap(const AliMpStringObjMap& rhs)
49 /// Protected copy constructor
51 AliFatal("Copy constructor is not implemented.");
54 //______________________________________________________________________________
55 AliMpStringObjMap::~AliMpStringObjMap()
62 //______________________________________________________________________________
64 AliMpStringObjMap::operator = (const AliMpStringObjMap& rhs)
66 /// Protected assignement operator
68 // check assignement to self
69 if (this == &rhs) return *this;
71 AliFatal("Assignment operator is not implemented.");
81 //______________________________________________________________________________
82 Bool_t AliMpStringObjMap::Add(const TString& first, TObject* second)
84 /// Add map element if first not yet present
86 TObject* second2 = Get(first);
88 AliError(Form("%s is already present in the map", first.Data()));
92 fFirstArray.Add(new TObjString(first));
93 fSecondArray.Add(second);
99 //______________________________________________________________________________
100 TObject* AliMpStringObjMap::Get(const TString& first) const
102 /// Find the element with specified key (first)
104 for (Int_t i=0; i<fNofItems; i++) {
105 if ( ((TObjString*)fFirstArray.At(i))->GetString() == first )
106 return fSecondArray.At(i);
112 //______________________________________________________________________________
113 Int_t AliMpStringObjMap::GetNofItems() const
115 /// Return the number of elements
120 //______________________________________________________________________________
121 void AliMpStringObjMap::Clear(Option_t* /*option*/)
123 /// Delete the elements
126 fFirstArray.Delete();
127 fSecondArray.Delete();
130 //______________________________________________________________________________
131 void AliMpStringObjMap::Print(const char* /*option*/) const
133 /// Print the map elements
135 for (Int_t i=0; i<fNofItems; i++) {
138 << ((TObjString*)fFirstArray.At(i))->GetString()
141 << fSecondArray.At(i)
146 //______________________________________________________________________________
147 void AliMpStringObjMap::Print(const TString& key, ofstream& out) const
149 // Prints the map elements
151 for (Int_t i=0; i<fNofItems; i++) {
153 << ((TObjString*)fFirstArray.At(i))->GetString()
156 << fSecondArray.At(i)