// -*- c++ -*- #ifndef HUGO_MAPSKELETON_H #define HUGO_MAPSKELETON_H ///\ingroup skeletons ///\file ///\brief Map concepts checking classes for testing and documenting. namespace hugo { /// The namespace of HUGOlib concepts and concept checking classes namespace skeleton { /// \addtogroup skeletons /// @{ /// Readable map concept template class ReadMap { public: /// Map's key type. typedef K KeyType; /// Map's value type. (The type of objects associated with the keys). typedef T ValueType; /// Returns the value associated with a key. ValueType operator[](const KeyType &k) const {return ValueType();} ///Default constructor ReadMap() {} }; /// Writable map concept template class WriteMap { public: /// Map's key type. typedef K KeyType; /// Map's value type. (The type of objects associated with the keys). typedef T ValueType; /// Sets the value associated with a key. void set(const KeyType &k,const ValueType &t) {} ///Default constructor WriteMap() {} }; ///Read/Writeable map concept template class ReadWriteMap : public ReadMap, public WriteMap { public: /// Map's key type. typedef K KeyType; /// Map's value type. (The type of objects associated with the keys). typedef T ValueType; /// Returns the value associated with a key. ValueType operator[](const KeyType &k) const {return ValueType();} /// Sets the value associated with a key. void set(const KeyType &k,const ValueType &t) {} ///Default constructor ReadWriteMap() {} }; ///Dereferable map concept template class ReferenceMap : public ReadWriteMap { public: /// Map's key type. typedef K KeyType; /// Map's value type. (The type of objects associated with the keys). typedef T ValueType; protected: ValueType tmp; public: typedef ValueType& ReferenceType; /// Map's const reference type. typedef const ValueType& ConstReferenceType; ///Returns a reference to the value associated to a key. ReferenceType operator[](const KeyType &i) { return tmp; } ///Returns a const reference to the value associated to a key. ConstReferenceType operator[](const KeyType &i) const { return tmp; } /// Sets the value associated with a key. void set(const KeyType &k,const ValueType &t) { operator[](k)=t; } ///Default constructor ReferenceMap() {} }; // @} } //namespace skeleton } //namespace hugo #endif // HUGO_MAPSKELETON_H