/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/MdcRecoUtil/MdcRecoUtil-00-01-08/MdcRecoUtil/AstStringMap.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: AstStringMap.h,v 1.4 2010/03/25 09:55:57 zhangy Exp $
00004 //
00005 // Description:
00006 //      This class is meant to be used to store an unowned pointer to
00007 //      and object that you reference with a std::string key.
00008 //
00009 // Environment:
00010 //      This software was developed for the BaBar collaboration.  If you
00011 //      use all or part of it, please give an appropriate acknowledgement.
00012 //
00013 // Author List:
00014 //      Stephen J. Gowdy        Originator
00015 //
00016 // Copyright Information:
00017 //      Copyright (C) 2004      Stanford Linear Accelerator Center
00018 // 
00019 // History:
00020 //      Migration for BESIII MDC
00021 //
00022 //------------------------------------------------------------------------
00023 
00024 #ifndef ASTSTRINGMAP_H
00025 #define ASTSTRINGMAP_H
00026 
00027 //-------------
00028 // C Headers --
00029 //-------------
00030 extern "C" {
00031 }
00032 
00033 //---------------
00034 // C++ Headers --
00035 //---------------
00036 #include <iosfwd>
00037 #include <map>
00038 #include <string>
00039 #include <vector>
00040 
00041 //----------------------
00042 // Base Class Headers --
00043 //----------------------
00044 
00045 //-------------------------------
00046 // Collaborating Class Headers --
00047 //-------------------------------
00048 
00049 //------------------------------------
00050 // Collaborating Class Declarations --
00051 //------------------------------------
00052 
00053 //              ---------------------
00054 //              -- Class Interface --
00055 //              ---------------------
00056 
00057 
00077 template<class T> 
00078 class AstStringMap {
00079 
00080   //--------------------
00081   // Declarations     --
00082   //--------------------
00083 
00084   // Typedefs, consts, and enums
00085 
00086   //--------------------
00087   // Instance Members --
00088   //--------------------
00089 
00090   public:
00091 
00092     // Constructors
00093     AstStringMap();
00094 
00095     // Destructor
00096     virtual ~AstStringMap( );
00097 
00098     // Operators
00099 
00107     virtual T* operator[]( const std::string& key ) const;
00108 
00109     // Selectors (const)
00110     virtual int size() const;
00111 
00112     // Modifiers
00113 
00122     virtual T*& insert( const std::string& key );
00123 
00124     virtual void clear();
00125 
00126   protected:
00127 
00128     // Helper functions
00129     inline int stringToBucket( const std::string& key ) const;
00130     //CHANGE  inline uint64_t stringToInt( const std::string& key ) const;
00131     inline unsigned stringToInt( const std::string& key ) const;
00132 
00133   private:
00134 
00135     // Friends
00136     //friend std::ostream& operator<<<T>( std::ostream& stream,
00137     friend std::ostream& operator<<( std::ostream& stream,
00138         const AstStringMap< T >& map );
00139 
00140     // Data members
00141 
00142     // Here we map strings upto and including eight characters to a 64 bit int
00143     std::map< unsigned, T* > _intMap;
00144     // for output, remember the string
00145     std::map< unsigned, std::string > _intStringMap;
00146 
00147     // Here we have a std::map for each letter for longer strings
00148     std::vector< std::map< std::string, T* > > _stringMap;
00149 
00150     // Note: if your class needs a copy constructor or an assignment operator, 
00151     //  make one of the following public and implement it.
00152     AstStringMap( const AstStringMap<T>& );  // Copy Constructor
00153     AstStringMap<T>& operator= ( const AstStringMap<T>& );
00154 
00155     //------------------
00156     // Static Members --
00157     //------------------
00158 
00159   public:
00160 
00161     // Selectors (const)
00162 
00163     // Modifiers
00164 
00165   private:
00166 
00167     // Data members
00168 
00169 };
00170 
00171 
00181 template < class T >
00182 std::ostream&
00183 operator<<( std::ostream& stream, const AstStringMap< T >& map );
00184 
00185 //SKIP #ifdef    BES_COMP_INST
00186 //SKIP #include  "MdcTrkRecon/Tools/AstStringMap.cxx"
00187 #include  "AstStringMap.icc"
00188 //SKIP #endif  // BES_COMP_INST
00189 
00190 
00191 #endif  // ASTSTRINGMAP_H

Generated on Tue Nov 29 23:13:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7