2 #ifndef HUGO_MAPSKELETON_H
3 #define HUGO_MAPSKELETON_H
6 ///\brief Map concepts checking classes for testing and documenting.
10 /// The namespace of HUGOlib concepts and concept checking classes
14 template<typename K, typename T>
20 /// Map's value type. (The type of objects associated with the keys).
23 /// Facility to define a map with an other value type
26 /// The type of a map with the given value type
27 typedef NullMap<K,T1> other;
33 /// Readable map concept
34 template<typename K, typename T>
35 class ReadableMap : public NullMap<K,T>
40 /// Map's value type. (The type of objects associated with the keys).
43 /// Returns the value associated with a key.
44 ValueType operator[](const KeyType &k) const {return ValueType();}
46 /// Copy contsructor. (optional)
47 ReadableMap(const ReadableMap&) {}
48 /// Assignment operator. (optional)
49 ReadableMap& operator=(const ReadableMap&) {return *this;}
51 /// Facility to define a map with an other value type (optional)
54 /// The type of a map with the given value type
55 typedef ReadableMap<K,T1> other;
57 /// @brief Constructor that copies all keys from the other map and
58 /// assigns to them a default value (optional)
60 ReadableMap(const ReadableMap<K,T1> &map, const T1 &v) {}
66 /// Writable map concept
67 template<typename K, typename T>
68 class WritableMap : public NullMap<K,T>
73 /// Map's value type. (The type of objects associated with the keys).
76 /// Sets the value associated with a key.
77 void set(const KeyType &k,const ValueType &t) {}
79 /// Copy contsructor. (optional)
80 WritableMap(const WritableMap&) {}
81 /// Assignment operator. (optional)
82 WritableMap& operator=(const WritableMap&) {return *this;}
84 /// Facility to define a map with an other value type (optional)
87 /// The type of a map with the given value type
88 typedef WritableMap<K,T1> other;
90 /// @brief Constructor that copies all keys from the other map and
91 /// assigns to them a default value (optional)
93 WritableMap(const WritableMap<K,T1> &map, const T1 &v) {}
98 ///Read/Writeable map concept
99 template<typename K, typename T>
100 class ReadWritableMap : public ReadableMap<K,T>,
101 public WritableMap<K,T>
106 /// Map's value type. (The type of objects associated with the keys).
109 /// Returns the value associated with a key.
110 ValueType operator[](const KeyType &k) const {return ValueType();}
111 /// Sets the value associated with a key.
112 void set(const KeyType &k,const ValueType &t) {}
114 /// Copy contsructor. (optional)
115 ReadWritableMap(const ReadWritableMap&) {}
116 /// Assignment operator. (optional)
117 ReadWritableMap& operator=(const ReadWritableMap&) {return *this;}
119 /// Facility to define a map with an other value type (optional)
120 template<typename T1>
122 /// The type of a map with the given value type
123 typedef ReadWritableMap<K,T1> other;
125 /// @brief Constructor that copies all keys from the other map and
126 /// assigns to them a default value (optional)
127 template<typename T1>
128 ReadWritableMap(const ReadWritableMap<K,T1> &map, const T1 &v) {}
134 ///Dereferable map concept
135 template<typename K, typename T>
136 class DereferableMap : public ReadWritableMap<K,T>
141 /// Map's value type. (The type of objects associated with the keys).
143 /// Map's reference type. (Reference to an object associated with a key)
144 typedef ValueType& ReferenceType;
145 /// Map's const reference type.
146 typedef const ValueType& ConstReferenceType;
148 ///Returns a reference to the value associated to a key.
149 ReferenceType operator[](const KeyType &i);
150 ///Returns a const reference to the value associated to a key.
151 ConstReferenceType operator[](const KeyType &i) const;
152 /// Sets the value associated with a key.
153 void set(const KeyType &k,const ValueType &t) { operator[](k)=t; }
155 /// Copy contsructor. (optional)
156 DereferableMap(const DereferableMap&) {}
157 /// Assignment operator. (optional)
158 DereferableMap& operator=(const DereferableMap&) {return *this;}
160 /// Facility to define a map with an other value type (optional)
161 template<typename T1>
163 /// The type of a map with the given value type
164 typedef DereferableMap<K,T1> other;
166 /// @brief Constructor that copies all keys from the other map and
167 /// assigns to them a default value (optional)
168 template<typename T1>
169 DereferableMap(const DereferableMap<K,T1> &map, const T1 &v) {}
177 #endif // HUGO_MAPSKELETON_H