[Lemon-commits] [lemon_svn] klao: r396 - in hugo/trunk: doc src/include/skeletons
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:39:13 CET 2006
Author: klao
Date: Sat Apr 3 20:21:25 2004
New Revision: 396
Modified:
hugo/trunk/doc/makefile
hugo/trunk/src/include/skeletons/maps.h
Log:
Bit more elaborated map concepts
Modified: hugo/trunk/doc/makefile
==============================================================================
--- hugo/trunk/doc/makefile (original)
+++ hugo/trunk/doc/makefile Sat Apr 3 20:21:25 2004
@@ -6,4 +6,7 @@
makeinfo etikol.texi&&makeinfo --html etikol.texi&&texi2pdf etikol.texi
texi-html: etikol.texi flf-graph.texi
- makeinfo etikol.texi&&makeinfo --html etikol.texi
\ No newline at end of file
+ makeinfo etikol.texi&&makeinfo --html etikol.texi
+
+clean:
+ rm -rf html latex
Modified: hugo/trunk/src/include/skeletons/maps.h
==============================================================================
--- hugo/trunk/src/include/skeletons/maps.h (original)
+++ hugo/trunk/src/include/skeletons/maps.h Sat Apr 3 20:21:25 2004
@@ -6,79 +6,172 @@
///\brief Map concepts checking classes for testing and documenting.
namespace hugo {
+
+ /// The namespace of HUGOlib concepts and concept checking classes
+ namespace skeleton {
- ///Readable map skeleton
- template<typename K, typename T>
- class ReadMapSkeleton
- {
- public:
- /// Map value type.
- typedef T ValueType;
- /// Map key type.
- typedef K KeyType;
+ /// Null map concept
+ template<typename K, typename T>
+ class NullMap
+ {
+ public:
+ /// Map's key type.
+ typedef K KeyType;
+ /// Map's value type. (The type of objects associated with the keys).
+ typedef T ValueType;
+
+ /// Facility to define a map with an other value type
+ template<typename T1>
+ struct rebind {
+ /// The type of a map with the given value type
+ typedef NullMap<K,T1> other;
+ };
- ///Default constructor.
- ReadMapSkeleton() {}
-
- ///Reads an element of the map.
- ValueType operator[](const KeyType &i) const {return ValueType();}
- };
-
-
- ///Writeable map skeleton
- template<typename K, typename T>
- class WriteMapSkeleton
- {
- public:
- /// Map value type.
- typedef T ValueType;
- /// Map key type.
- typedef K KeyType;
-
- ///Default constructor.
- WriteMapSkeleton() {}
- ///'Fill with' constructor.
- WriteMapSkeleton(const ValueType &t) {}
+ NullMap() {}
+ };
- ///Write an element of a map.
- void set(const KeyType &i,const ValueType &t) {}
- };
-
- ///Read/Write map skeleton.
- template<typename K, typename T>
- class ReadWriteMapSkeleton : public ReadMapSkeleton<K,T>,
- public WriteMapSkeleton<K,T>
- {
- public:
- ///Default constructor.
- ReadWriteMapSkeleton() : ReadMapSkeleton(), WriteMapSkeleton() {}
- ///'Fill with' constructor.
- ReadWriteMap(const ValueType &t) :ReadMapSkeleton(), WriteMapSkeleton(t) {}
- };
+ /// Readable map concept
+ template<typename K, typename T>
+ class ReadableMap : public NullMap<K,T>
+ {
+ 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();}
+
+ /// Copy contsructor. (optional)
+ ReadableMap(const ReadableMap&) {}
+ /// Assignment operator. (optional)
+ ReadableMap& operator=(const ReadableMap&) {return *this;}
+
+ /// Facility to define a map with an other value type (optional)
+ template<typename T1>
+ struct rebind {
+ /// The type of a map with the given value type
+ typedef ReadableMap<K,T1> other;
+ };
+ /// @brief Constructor that copies all keys from the other map and
+ /// assigns to them a default value (optional)
+ template<typename T1>
+ ReadableMap(const ReadableMap<K,T1> &map, const T1 &v) {}
+
+ ReadableMap() {}
+ };
+
+
+ /// Writable map concept
+ template<typename K, typename T>
+ class WritableMap : public NullMap<K,T>
+ {
+ 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) {}
+
+ /// Copy contsructor. (optional)
+ WritableMap(const WritableMap&) {}
+ /// Assignment operator. (optional)
+ WritableMap& operator=(const WritableMap&) {return *this;}
+
+ /// Facility to define a map with an other value type (optional)
+ template<typename T1>
+ struct rebind {
+ /// The type of a map with the given value type
+ typedef WritableMap<K,T1> other;
+ };
+ /// @brief Constructor that copies all keys from the other map and
+ /// assigns to them a default value (optional)
+ template<typename T1>
+ WritableMap(const WritableMap<K,T1> &map, const T1 &v) {}
+
+ WritableMap() {}
+ };
+
+ ///Read/Writeable map concept
+ template<typename K, typename T>
+ class ReadWritableMap : public ReadableMap<K,T>,
+ public WritableMap<K,T>
+ {
+ 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) {}
+
+ /// Copy contsructor. (optional)
+ ReadWritableMap(const ReadWritableMap&) {}
+ /// Assignment operator. (optional)
+ ReadWritableMap& operator=(const ReadWritableMap&) {return *this;}
+
+ /// Facility to define a map with an other value type (optional)
+ template<typename T1>
+ struct rebind {
+ /// The type of a map with the given value type
+ typedef ReadWritableMap<K,T1> other;
+ };
+ /// @brief Constructor that copies all keys from the other map and
+ /// assigns to them a default value (optional)
+ template<typename T1>
+ ReadWritableMap(const ReadWritableMap<K,T1> &map, const T1 &v) {}
+
+ ReadWritableMap() {}
+ };
- ///Dereferable map skeleton
- template<typename K, typename T>
- class MemoryMapSkeleton : public ReadWriteMapSkeleton<K,T>
- {
- public:
- /// Map value type.
- typedef T ValueType;
- /// Map key type.
- typedef K KeyType;
-
- ///Default constructor.
- ReferenceMapSkeleton() : ReadWriteMapSkeleton() {}
- ///'Fill with' constructor.
- ReferenceMapSkeleton(const ValueType &t) : ReadWriteMapSkeleton(t) {}
-
- ///Give a reference to the value belonging to a key.
- ValueType &operator[](const KeyType &i) {return *(ValueType*)0;}
- ///Give a const reference to the value belonging to a key.
- const ValueType &operator[](const KeyType &i) const {return *(T*)0;}
- };
+ ///Dereferable map concept
+ template<typename K, typename T>
+ class DereferableMap : public ReadWritableMap<K,T>
+ {
+ public:
+ /// Map's key type.
+ typedef K KeyType;
+ /// Map's value type. (The type of objects associated with the keys).
+ typedef T ValueType;
+ /// Map's reference type. (Reference to an object associated with a key)
+ 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);
+ ///Returns a const reference to the value associated to a key.
+ ConstReferenceType operator[](const KeyType &i) const;
+ /// Sets the value associated with a key.
+ void set(const KeyType &k,const ValueType &t) { operator[](k)=t; }
+
+ /// Copy contsructor. (optional)
+ DereferableMap(const DereferableMap&) {}
+ /// Assignment operator. (optional)
+ DereferableMap& operator=(const DereferableMap&) {return *this;}
+
+ /// Facility to define a map with an other value type (optional)
+ template<typename T1>
+ struct rebind {
+ /// The type of a map with the given value type
+ typedef DereferableMap<K,T1> other;
+ };
+ /// @brief Constructor that copies all keys from the other map and
+ /// assigns to them a default value (optional)
+ template<typename T1>
+ DereferableMap(const DereferableMap<K,T1> &map, const T1 &v) {}
+ DereferableMap() {}
+ };
+ }
}
#endif // HUGO_MAPSKELETON_H
More information about the Lemon-commits
mailing list