ROOT logo
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

// $Id$
// $MpId: AliMpExMap.h,v 1.4 2006/05/24 13:58:07 ivana Exp $

/// \ingroup core
/// \class AliMpExMap
/// \brief Helper class making Root persistent TExMap
///
/// The objects and keys from TExMap are store in additional
/// arrays which are Root persistent.
///
/// \author Ivana Hrivnacova; IPN Orsay

#ifndef ALI_MP_EX_MAP_H
#define ALI_MP_EX_MAP_H

#include <TObject.h>
#include <TObjArray.h>
#include <TArrayL.h>
#include <TExMap.h>

class AliMpExMapIterator;

class TString;

class AliMpExMap : public TObject
{
  friend class AliMpExMapIterator;
  
  public:
    AliMpExMap();
    AliMpExMap(TRootIOCtor* /*ioCtor*/);
    AliMpExMap(const AliMpExMap& rhs);
    AliMpExMap& operator=(const AliMpExMap& rhs);
    virtual ~AliMpExMap();
    
    
    // static methods
    // conversion between String and Long_t
    static Long_t  GetIndex(const TString& s);
    static TString GetString(Long_t index);

    // methods from base class
    virtual void Clear(Option_t* opt="");
    virtual void Print(Option_t* opt="") const;

    // set methods
    void Add(Int_t keyFirst, Int_t keySecond, TObject* object);
    void Add(const TString& key, TObject* object);
    void Add(Int_t key, TObject* object);

    void SetSize(Int_t size);
    void SetOwner(Bool_t owner);
    
    // get methods
    Int_t GetSize() const;
    Int_t GetCapacity() const;
    
    TObject*    GetValue(Int_t keyFirst, Int_t keySecond) const;
    TObject*    GetValue(const TString& key) const;
    TObject*    GetValue(Int_t key) const;

    AliMpExMapIterator* CreateIterator() const;
    
  private:  
    // static methods
    static const TString&  GetCharacterMap();

    // methods

    // conversion between Int_t pair key and Long_t
    static Long_t  GetIndex(Int_t first, Int_t second);
    static Int_t   GetPairFirst(Long_t index);
    static Int_t   GetPairSecond(Long_t index);

    void FillMap();
    void AddKey(Long_t key);
    void Copy(TObject& dest) const;
    
    // static data members
    static const Int_t    fgkDefaultSize;      ///< Default initial size
    static const Bool_t   fgkDefaultOwnership; ///< Default ownership

    static const Int_t    fgkSeparator1; ///< \brief the separator used for conversion
                                         ///  of Int_t pair to Int_t
    static const Int_t    fgkSeparator2; ///< \brief the separator used for conversion
                                         ///  of TString to Int_t
    
    // data members
    mutable TExMap  fMap;     //!<  Transient map class
    TObjArray       fObjects; ///<  Array of objects 
    TArrayL         fKeys;    ///<  Array of keys 

  ClassDef(AliMpExMap,1)  // Root persistent TExMap
};

#endif //ALI_MP_EX_MAP_H

 AliMpExMap.h:1
 AliMpExMap.h:2
 AliMpExMap.h:3
 AliMpExMap.h:4
 AliMpExMap.h:5
 AliMpExMap.h:6
 AliMpExMap.h:7
 AliMpExMap.h:8
 AliMpExMap.h:9
 AliMpExMap.h:10
 AliMpExMap.h:11
 AliMpExMap.h:12
 AliMpExMap.h:13
 AliMpExMap.h:14
 AliMpExMap.h:15
 AliMpExMap.h:16
 AliMpExMap.h:17
 AliMpExMap.h:18
 AliMpExMap.h:19
 AliMpExMap.h:20
 AliMpExMap.h:21
 AliMpExMap.h:22
 AliMpExMap.h:23
 AliMpExMap.h:24
 AliMpExMap.h:25
 AliMpExMap.h:26
 AliMpExMap.h:27
 AliMpExMap.h:28
 AliMpExMap.h:29
 AliMpExMap.h:30
 AliMpExMap.h:31
 AliMpExMap.h:32
 AliMpExMap.h:33
 AliMpExMap.h:34
 AliMpExMap.h:35
 AliMpExMap.h:36
 AliMpExMap.h:37
 AliMpExMap.h:38
 AliMpExMap.h:39
 AliMpExMap.h:40
 AliMpExMap.h:41
 AliMpExMap.h:42
 AliMpExMap.h:43
 AliMpExMap.h:44
 AliMpExMap.h:45
 AliMpExMap.h:46
 AliMpExMap.h:47
 AliMpExMap.h:48
 AliMpExMap.h:49
 AliMpExMap.h:50
 AliMpExMap.h:51
 AliMpExMap.h:52
 AliMpExMap.h:53
 AliMpExMap.h:54
 AliMpExMap.h:55
 AliMpExMap.h:56
 AliMpExMap.h:57
 AliMpExMap.h:58
 AliMpExMap.h:59
 AliMpExMap.h:60
 AliMpExMap.h:61
 AliMpExMap.h:62
 AliMpExMap.h:63
 AliMpExMap.h:64
 AliMpExMap.h:65
 AliMpExMap.h:66
 AliMpExMap.h:67
 AliMpExMap.h:68
 AliMpExMap.h:69
 AliMpExMap.h:70
 AliMpExMap.h:71
 AliMpExMap.h:72
 AliMpExMap.h:73
 AliMpExMap.h:74
 AliMpExMap.h:75
 AliMpExMap.h:76
 AliMpExMap.h:77
 AliMpExMap.h:78
 AliMpExMap.h:79
 AliMpExMap.h:80
 AliMpExMap.h:81
 AliMpExMap.h:82
 AliMpExMap.h:83
 AliMpExMap.h:84
 AliMpExMap.h:85
 AliMpExMap.h:86
 AliMpExMap.h:87
 AliMpExMap.h:88
 AliMpExMap.h:89
 AliMpExMap.h:90
 AliMpExMap.h:91
 AliMpExMap.h:92
 AliMpExMap.h:93
 AliMpExMap.h:94
 AliMpExMap.h:95
 AliMpExMap.h:96
 AliMpExMap.h:97
 AliMpExMap.h:98
 AliMpExMap.h:99
 AliMpExMap.h:100