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 **************************************************************************/
19 // ------------------------------------
20 // Class AliMpStringObjMap
21 // ------------------------------------
22 // Helper class that substitutes map <string, int>
23 // which ALICE does not allow to use
24 // Author: Ivana Hrivnacova, IPN Orsay
26 #include <Riostream.h>
27 #include <TObjString.h>
29 #include "AliMpStringObjMap.h"
32 ClassImp(AliMpStringObjMap)
34 //______________________________________________________________________________
35 AliMpStringObjMap::AliMpStringObjMap()
41 /// Standard constructor
43 fFirstArray.SetOwner(true);
46 //______________________________________________________________________________
47 AliMpStringObjMap::AliMpStringObjMap(const AliMpStringObjMap& rhs)
50 /// Protected copy constructor
52 AliFatal("Copy constructor is not implemented.");
55 //______________________________________________________________________________
56 AliMpStringObjMap::~AliMpStringObjMap()
63 //______________________________________________________________________________
65 AliMpStringObjMap::operator = (const AliMpStringObjMap& rhs)
67 /// Protected assignement operator
69 // check assignement to self
70 if (this == &rhs) return *this;
72 AliFatal("Assignment operator is not implemented.");
82 //______________________________________________________________________________
83 Bool_t AliMpStringObjMap::Add(const TString& first, TObject* second)
85 /// Add map element if first not yet present
87 TObject* second2 = Get(first);
89 AliError(Form("%s is already present in the map", first.Data()));
93 fFirstArray.Add(new TObjString(first));
94 fSecondArray.Add(second);
100 //______________________________________________________________________________
101 TObject* AliMpStringObjMap::Get(const TString& first) const
103 /// Find the element with specified key (first)
105 for (Int_t i=0; i<fNofItems; i++) {
106 if ( ((TObjString*)fFirstArray.At(i))->GetString() == first )
107 return fSecondArray.At(i);
113 //______________________________________________________________________________
114 Int_t AliMpStringObjMap::GetNofItems() const
116 /// Return the number of elements
121 //______________________________________________________________________________
122 void AliMpStringObjMap::Clear(Option_t* /*option*/)
124 /// Delete the elements
127 fFirstArray.Delete();
128 fSecondArray.Delete();
131 //______________________________________________________________________________
132 void AliMpStringObjMap::Print(const char* /*option*/) const
134 /// Print the map elements
136 for (Int_t i=0; i<fNofItems; i++) {
139 << ((TObjString*)fFirstArray.At(i))->GetString()
142 << fSecondArray.At(i)
147 //______________________________________________________________________________
148 void AliMpStringObjMap::Print(const TString& key, ofstream& out) const
150 // Prints the map elements
152 for (Int_t i=0; i<fNofItems; i++) {
154 << ((TObjString*)fFirstArray.At(i))->GetString()
157 << fSecondArray.At(i)