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 { alpar@186: alpar@186: ///Readable map skeleton alpar@186: template alpar@186: class ReadMapSkeleton alpar@186: { alpar@186: public: alpar@186: /// Map value type. alpar@186: typedef T ValueType; alpar@186: /// Map key type. alpar@186: typedef K KeyType; alpar@186: alpar@186: ///Default constructor. alpar@186: ReadMapSkeleton() {} alpar@186: alpar@186: ///Reads an element of the map. alpar@209: ValueType operator[](const KeyType &i) const {return ValueType();} alpar@186: }; alpar@186: alpar@186: alpar@186: ///Writeable map skeleton alpar@186: template alpar@186: class WriteMapSkeleton alpar@186: { alpar@186: public: alpar@186: /// Map value type. alpar@186: typedef T ValueType; alpar@186: /// Map key type. alpar@186: typedef K KeyType; alpar@186: alpar@186: ///Default constructor. alpar@186: WriteMapSkeleton() {} alpar@186: ///'Fill with' constructor. alpar@186: WriteMapSkeleton(const ValueType &t) {} alpar@186: alpar@186: ///Write an element of a map. alpar@186: void set(const KeyType &i,const ValueType &t) {} alpar@186: }; alpar@186: alpar@186: ///Read/Write map skeleton. alpar@186: template alpar@186: class ReadWriteMapSkeleton : public ReadMapSkeleton, alpar@186: public WriteMapSkeleton alpar@186: { alpar@186: public: alpar@186: ///Default constructor. alpar@186: ReadWriteMapSkeleton() : ReadMapSkeleton(), WriteMapSkeleton() {} alpar@186: ///'Fill with' constructor. alpar@186: ReadWriteMap(const ValueType &t) :ReadMapSkeleton(), WriteMapSkeleton(t) {} alpar@186: }; alpar@186: alpar@186: alpar@186: ///Dereferable map skeleton alpar@186: template alpar@186: class MemoryMapSkeleton : public ReadWriteMapSkeleton alpar@186: { alpar@186: public: alpar@186: /// Map value type. alpar@186: typedef T ValueType; alpar@186: /// Map key type. alpar@186: typedef K KeyType; alpar@186: alpar@186: ///Default constructor. alpar@186: ReferenceMapSkeleton() : ReadWriteMapSkeleton() {} alpar@186: ///'Fill with' constructor. alpar@186: ReferenceMapSkeleton(const ValueType &t) : ReadWriteMapSkeleton(t) {} alpar@186: alpar@186: ///Give a reference to the value belonging to a key. alpar@209: ValueType &operator[](const KeyType &i) {return *(ValueType*)0;} alpar@209: ///Give a const reference to the value belonging to a key. alpar@209: const ValueType &operator[](const KeyType &i) const {return *(T*)0;} alpar@186: }; alpar@186: alpar@186: alpar@186: alpar@186: } alpar@186: #endif // HUGO_MAPSKELETON_H