MapBase added
authoralpar
Wed, 21 Jul 2004 17:38:02 +0000
changeset 720193d881b23ad
parent 719 cb9efd4cc9db
child 721 1df9b762269b
MapBase added
src/hugo/maps.h
     1.1 --- a/src/hugo/maps.h	Wed Jul 21 13:03:11 2004 +0000
     1.2 +++ b/src/hugo/maps.h	Wed Jul 21 17:38:02 2004 +0000
     1.3 @@ -12,17 +12,27 @@
     1.4  
     1.5  namespace hugo {
     1.6  
     1.7 +  /// Base class of maps.
     1.8 +
     1.9 +  template<typename K, typename T>
    1.10 +  class MapBase
    1.11 +  {
    1.12 +  public:
    1.13 +    ///
    1.14 +    typedef K KeyType;
    1.15 +    ///
    1.16 +    typedef T ValueType;
    1.17 +  };
    1.18 +
    1.19    /// Null map. (aka DoNothingMap)
    1.20  
    1.21    /// If you have to provide a map only for its type definitions,
    1.22    /// or if you have to provide a writable map, but will not use the
    1.23    /// data written to it...
    1.24    template<typename K, typename T>
    1.25 -  class NullMap
    1.26 +  class NullMap : public MapBase<K,T>
    1.27    {
    1.28    public:
    1.29 -    typedef K KeyType;
    1.30 -    typedef T ValueType;
    1.31  
    1.32      T operator[](const K&) const { return T(); }
    1.33      void set(const K&, const T&) {}
    1.34 @@ -37,12 +47,10 @@
    1.35    /// This is a readable map which assignes a specified value to each key.
    1.36    /// In other aspects it is equivalent to the \ref NullMap
    1.37    template<typename K, typename T>
    1.38 -  class ConstMap
    1.39 +  class ConstMap : public MapBase<K,T>
    1.40    {
    1.41      T v;
    1.42    public:
    1.43 -    typedef K KeyType;
    1.44 -    typedef T ValueType;
    1.45  
    1.46      ConstMap() {}
    1.47      ConstMap(const T &_v) : v(_v) {}