**************************************************************************/
// $Id$
-// $MpId: AliMpExMap.cxx,v 1.2 2006/03/02 16:28:23 ivana Exp $
+// $MpId: AliMpExMap.cxx,v 1.5 2006/05/24 13:58:29 ivana Exp $
// Category: basic
// ------------------------
// Class AliMpExMap
// Author:Ivana Hrivnacova; IPN Orsay
#include "AliMpExMap.h"
+#include "AliMpIntPair.h"
-#include <stdlib.h>
+#include "AliLog.h"
#include <TClass.h>
-#include <Riostream.h>
#include <TString.h>
-#include <TError.h>
+#include <Riostream.h>
-//#include "AliMpConstants.h"
-#include "AliMpIntPair.h"
-#include "AliLog.h"
+#include <stdlib.h>
+
+/// \cond CLASSIMP
+ClassImp(AliMpExMap)
+/// \endcond
//
// static members
const TString AliMpExMap::fgkCharacterMap
= " 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.";
-ClassImp(AliMpExMap)
-
//
// static methods
//
/// Convert the pair of integers to integer.
if (pair.GetFirst() >= fgkSeparator1 || pair.GetSecond() >= fgkSeparator1) {
- // to do - use AliLog, is it possible for static function
- // AliFatal("Index out of limit.");
- cerr << "AliMpExMap::GetIndex(const AliMpIntPair&): Index out of limit." << endl;
+ AliFatalClass("Index out of limit.");
exit(1);
}
/// Convert the TString to integer.
if (s.Length() > 5) {
- // to do - use AliLog, is it possible for static function
- // AliFatal("String too long.");
- cerr << "AliMpExMap::GetIndex(const TString&): String too long." << endl;
+ AliFatalClass("String too long.");
return 0;
}
/// Default constructor
}
+
+//_____________________________________________________________________________
+AliMpExMap::AliMpExMap(const AliMpExMap& rhs)
+ : TObject(),
+ fMap(),
+ fObjects(),
+ fKeys()
+
+{
+ /// Copy ctor
+ rhs.Copy(*this);
+}
+
+//_____________________________________________________________________________
+AliMpExMap&
+AliMpExMap::operator=(const AliMpExMap& rhs)
+{
+ /// Assignment operator
+ AliMpExMap tmp(rhs);
+ tmp.Copy(*this);
+ return *this;
+}
+
+//_____________________________________________________________________________
+void
+AliMpExMap::Copy(TObject& dest) const
+{
+ /// Copy this to dest
+ /// Copy implies that dest will become owner of its objects, whatever
+ /// the ownership of (*this) is.
+
+ AliDebug(1,"");
+
+ TObject::Copy(dest);
+ AliMpExMap& m = static_cast<AliMpExMap&>(dest);
+ m.fKeys = fKeys;
+ m.fMap.Delete();
+ m.fObjects.Delete();
+
+ for ( Int_t i = 0; i <= fObjects.GetLast(); ++i )
+ {
+ TObject* o = fObjects.At(i)->Clone();
+ if (!o)
+ {
+ AliError("Object was not cloned properly ! Please investigate...");
+ }
+ m.fObjects.AddLast(o);
+ }
+ m.FillMap();
+ m.fObjects.SetOwner(kTRUE);
+}
+
//_____________________________________________________________________________
AliMpExMap::~AliMpExMap()
{
// Resize array if needed
if (fObjects.GetEntriesFast() == fKeys.GetSize()) {
fKeys.Set(2*fKeys.GetSize());
- cout << "AliMpExMap::AddKey: resized Key array " << endl;
+ AliWarningStream() << "AliMpExMap::AddKey: resized Key array " << endl;
}
fKeys.AddAt(key, fObjects.GetEntriesFast());
//_____________________________________________________________________________
Int_t AliMpExMap::GetSize() const
{
-/// Return TExMap iterator set to the beginning of the map
+/// Return the map size
return fObjects.GetEntriesFast();
}
return TExMapIter(&fMap);
}
+//_____________________________________________________________________________
+TObject* AliMpExMap::GetObject(Int_t index) const
+{
+/// Return the object via its index in the array
+/// (This function makes possible looping over map as over an array)
+
+ if ( index < 0 || index >= fObjects.GetEntriesFast() ) {
+ AliErrorStream() << "Index outside limits" << endl;
+ return 0;
+ }
+
+ return fObjects.At(index);
+}
+
//_____________________________________________________________________________
TObject* AliMpExMap::GetValue(const AliMpIntPair& key) const
{
//_____________________________________________________________________________
void AliMpExMap::Streamer(TBuffer &R__b)
{
-/// Customized streamer \n
-/// After the arrays are read, fill the transient map
+// Customized streamer \n
+// After the arrays are read, fill the transient map
if (R__b.IsReading()) {
AliMpExMap::Class()->ReadBuffer(R__b, this);