**************************************************************************/
// $Id$
-// $MpId: $
+// $MpId: AliMpStringObjMap.cxx,v 1.4 2006/05/24 13:58:29 ivana Exp $
-// ------------------------------------
+//-----------------------------------------------------------------------------
// Class AliMpStringObjMap
// ------------------------------------
// Helper class that substitutes map <string, int>
// which ALICE does not allow to use
// Author: Ivana Hrivnacova, IPN Orsay
-
-#include <Riostream.h>
-#include <TObjString.h>
+//-----------------------------------------------------------------------------
#include "AliMpStringObjMap.h"
+
#include "AliLog.h"
+#include <TObjString.h>
+#include <Riostream.h>
+
+/// \cond CLASSIMP
ClassImp(AliMpStringObjMap)
+/// \endcond
+
+const TString AliMpStringObjMap::fgkUndefinedKey = "Undefined";
//______________________________________________________________________________
-AliMpStringObjMap::AliMpStringObjMap()
+AliMpStringObjMap::AliMpStringObjMap(Bool_t isOwner)
: TObject(),
fNofItems(0),
fFirstArray(),
- fSecondArray()
+ fSecondArray(),
+ fCurrentIndex(0)
{
/// Standard constructor
fFirstArray.SetOwner(true);
-}
-
-//______________________________________________________________________________
-AliMpStringObjMap::AliMpStringObjMap(const AliMpStringObjMap& rhs)
- : TObject(rhs)
-{
-/// Protected copy constructor
-
- AliFatal("Copy constructor is not implemented.");
+ fSecondArray.SetOwner(isOwner);
}
//______________________________________________________________________________
fFirstArray.Delete();
}
-//______________________________________________________________________________
-AliMpStringObjMap&
-AliMpStringObjMap::operator = (const AliMpStringObjMap& rhs)
-{
-/// Protected assignement operator
-
- // check assignement to self
- if (this == &rhs) return *this;
-
- AliFatal("Assignment operator is not implemented.");
-
- return *this;
-}
-
-
//
// public methods
//
//______________________________________________________________________________
void AliMpStringObjMap::Print(const TString& key, ofstream& out) const
{
-// Prints the map elements
+/// Special printing
for (Int_t i=0; i<fNofItems; i++) {
out << key << " "
<< endl;
}
}
+
+//______________________________________________________________________________
+void AliMpStringObjMap::First()
+{
+/// Set iterator to the first item and return its object
+
+ fCurrentIndex = 0;
+}
+
+
+//______________________________________________________________________________
+void AliMpStringObjMap::Next()
+{
+/// Set iterator to the next item and return its object
+/// Return 0 if there are no more items
+
+ ++fCurrentIndex;
+}
+
+
+//______________________________________________________________________________
+TObject* AliMpStringObjMap::CurrentItem()
+{
+/// Set iterator to the first item and return its object
+
+ if ( fCurrentIndex >= fNofItems ) return 0;
+
+ return fSecondArray.At(fCurrentIndex);
+}
+
+
+//______________________________________________________________________________
+TString AliMpStringObjMap::CurrentKey()
+{
+/// Set iterator to the first item and return its object
+
+ if ( fCurrentIndex >= fNofItems ) return fgkUndefinedKey;
+
+ return ((TObjString*)fFirstArray.At(fCurrentIndex))->GetString();
+}
+
+
+//______________________________________________________________________________
+Bool_t AliMpStringObjMap::IsDone() const
+{
+/// Return true if the iterator reached the end of map
+
+ return fCurrentIndex >= fNofItems;
+}
+