alpar@186: // -*- c++ -*-
alpar@186: #ifndef HUGO_MAPSKELETON_H
alpar@186: #define HUGO_MAPSKELETON_H
alpar@186: 
alpar@242: ///\file
alpar@242: ///\brief Map concepts checking classes for testing and documenting.
alpar@242: 
alpar@186: namespace hugo {
klao@282: 
klao@282:   /// The namespace of HUGOlib concepts and concept checking classes
klao@282:   namespace skeleton {
alpar@186:   
klao@282:     /// Readable map concept
klao@282:     template<typename K, typename T>
klao@284:     class ReadableMap
klao@282:     {
klao@282:     public:
klao@282:       /// Map's key type.
klao@282:       typedef K KeyType;    
klao@282:       /// Map's value type. (The type of objects associated with the keys).
klao@282:       typedef T ValueType;
alpar@186: 
klao@282:       /// Returns the value associated with a key.
klao@282:       ValueType operator[](const KeyType &k) const {return ValueType();}
alpar@186: 
klao@282:       /// Copy contsructor. (optional)
klao@282:       ReadableMap(const ReadableMap&) {}
klao@282:       /// Assignment operator. (optional)
klao@282:       ReadableMap& operator=(const ReadableMap&) {return *this;}
alpar@186: 
klao@282:       ReadableMap() {}
klao@282:     };
klao@282: 
klao@282: 
klao@282:     /// Writable map concept
klao@282:     template<typename K, typename T>
klao@284:     class WritableMap
klao@282:     {
klao@282:     public:
klao@282:       /// Map's key type.
klao@282:       typedef K KeyType;    
klao@282:       /// Map's value type. (The type of objects associated with the keys).
klao@282:       typedef T ValueType;
klao@282: 
klao@282:       /// Sets the value associated with a key.
klao@282:       void set(const KeyType &k,const ValueType &t) {}
klao@282: 
klao@282:       WritableMap() {}
klao@282:     };
klao@282: 
klao@282:     ///Read/Writeable map concept
klao@282:     template<typename K, typename T>
klao@282:     class ReadWritableMap : public ReadableMap<K,T>,
klao@282: 			    public WritableMap<K,T>
klao@282:     {
klao@282:     public:
klao@282:       /// Map's key type.
klao@282:       typedef K KeyType;    
klao@282:       /// Map's value type. (The type of objects associated with the keys).
klao@282:       typedef T ValueType;
klao@282: 
klao@282:       /// Returns the value associated with a key.
klao@282:       ValueType operator[](const KeyType &k) const {return ValueType();}
klao@282:       /// Sets the value associated with a key.
klao@282:       void set(const KeyType &k,const ValueType &t) {}
klao@282: 
klao@282:       /// Copy contsructor. (optional)
klao@282:       ReadWritableMap(const ReadWritableMap&) {}
klao@282:       /// Assignment operator. (optional)
klao@282:       ReadWritableMap& operator=(const ReadWritableMap&) {return *this;}
klao@282: 
klao@282:       /// Facility to define a map with an other value type (optional)
klao@282:       template<typename T1>
klao@282:       struct rebind {
klao@282: 	/// The type of a map with the given value type
klao@282: 	typedef ReadWritableMap<K,T1> other;
klao@282:       };
klao@282:       /// @brief Constructor that copies all keys from the other map and
klao@282:       /// assigns to them a default value (optional)
klao@282:       template<typename T1>
klao@286:       ReadWritableMap(const ReadWritableMap<K,T1> &map, const ValueType &v) {}
klao@282: 
klao@282:       ReadWritableMap() {}
klao@282:     };
alpar@186:   
alpar@186:   
klao@282:     ///Dereferable map concept
klao@282:     template<typename K, typename T>
klao@282:     class DereferableMap : public ReadWritableMap<K,T>
klao@282:     {
klao@282:     public:
klao@282:       /// Map's key type.
klao@282:       typedef K KeyType;    
klao@282:       /// Map's value type. (The type of objects associated with the keys).
klao@282:       typedef T ValueType;
klao@282:       /// Map's reference type. (Reference to an object associated with a key)
klao@282:       typedef ValueType& ReferenceType;
klao@282:       /// Map's const reference type.
klao@282:       typedef const ValueType& ConstReferenceType;
alpar@186: 
klao@282:       ///Returns a reference to the value associated to a key.
klao@282:       ReferenceType operator[](const KeyType &i);
klao@282:       ///Returns a const reference to the value associated to a key.
klao@282:       ConstReferenceType operator[](const KeyType &i) const;
klao@282:       /// Sets the value associated with a key.
klao@282:       void set(const KeyType &k,const ValueType &t) { operator[](k)=t; }
alpar@186: 
klao@282:       /// Copy contsructor. (optional)
klao@282:       DereferableMap(const DereferableMap&) {}
klao@282:       /// Assignment operator. (optional)
klao@282:       DereferableMap& operator=(const DereferableMap&) {return *this;}
alpar@186: 
klao@282:       /// Facility to define a map with an other value type (optional)
klao@282:       template<typename T1>
klao@282:       struct rebind {
klao@282: 	/// The type of a map with the given value type
klao@282: 	typedef DereferableMap<K,T1> other;
klao@282:       };
klao@282:       /// @brief Constructor that copies all keys from the other map and
klao@282:       /// assigns to them a default value (optional)
klao@282:       template<typename T1>
klao@286:       DereferableMap(const DereferableMap<K,T1> &map, const ValueType &v) {}
alpar@186: 
klao@282:       DereferableMap() {}
klao@282:     };
alpar@186: 
klao@282: 
klao@282:   }
alpar@186: }
alpar@186: #endif // HUGO_MAPSKELETON_H