4 * This file is a part of LEMON, a generic C++ optimization library
6 * Copyright (C) 2003-2008
7 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
8 * (Egervary Research Group on Combinatorial Optimization, EGRES).
10 * Permission to use, modify and distribute this software is granted
11 * provided that this copyright notice appears in all copies. For
12 * precise terms see the accompanying LICENSE file.
14 * This software is provided "AS IS" with no warranty of any kind,
15 * express or implied, and with no claim as to its suitability for any
20 #ifndef LEMON_BITS_TRAITS_H
21 #define LEMON_BITS_TRAITS_H
23 #include <lemon/bits/utility.h>
26 ///\brief Traits for graphs and maps
30 template <typename _Graph, typename _Item>
31 class ItemSetTraits {};
34 template <typename Graph, typename Enable = void>
35 struct NodeNotifierIndicator {
36 typedef InvalidType Type;
38 template <typename Graph>
39 struct NodeNotifierIndicator<
41 typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
43 typedef typename Graph::NodeNotifier Type;
46 template <typename _Graph>
47 class ItemSetTraits<_Graph, typename _Graph::Node> {
52 typedef typename Graph::Node Item;
53 typedef typename Graph::NodeIt ItemIt;
55 typedef typename NodeNotifierIndicator<Graph>::Type ItemNotifier;
57 template <typename _Value>
58 class Map : public Graph::template NodeMap<_Value> {
60 typedef typename Graph::template NodeMap<_Value> Parent;
61 typedef typename Graph::template NodeMap<_Value> Type;
62 typedef typename Parent::Value Value;
64 Map(const Graph& _digraph) : Parent(_digraph) {}
65 Map(const Graph& _digraph, const Value& _value)
66 : Parent(_digraph, _value) {}
72 template <typename Graph, typename Enable = void>
73 struct ArcNotifierIndicator {
74 typedef InvalidType Type;
76 template <typename Graph>
77 struct ArcNotifierIndicator<
79 typename enable_if<typename Graph::ArcNotifier::Notifier, void>::type
81 typedef typename Graph::ArcNotifier Type;
84 template <typename _Graph>
85 class ItemSetTraits<_Graph, typename _Graph::Arc> {
90 typedef typename Graph::Arc Item;
91 typedef typename Graph::ArcIt ItemIt;
93 typedef typename ArcNotifierIndicator<Graph>::Type ItemNotifier;
95 template <typename _Value>
96 class Map : public Graph::template ArcMap<_Value> {
98 typedef typename Graph::template ArcMap<_Value> Parent;
99 typedef typename Graph::template ArcMap<_Value> Type;
100 typedef typename Parent::Value Value;
102 Map(const Graph& _digraph) : Parent(_digraph) {}
103 Map(const Graph& _digraph, const Value& _value)
104 : Parent(_digraph, _value) {}
109 template <typename Graph, typename Enable = void>
110 struct EdgeNotifierIndicator {
111 typedef InvalidType Type;
113 template <typename Graph>
114 struct EdgeNotifierIndicator<
116 typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
118 typedef typename Graph::EdgeNotifier Type;
121 template <typename _Graph>
122 class ItemSetTraits<_Graph, typename _Graph::Edge> {
125 typedef _Graph Graph;
127 typedef typename Graph::Edge Item;
128 typedef typename Graph::EdgeIt ItemIt;
130 typedef typename EdgeNotifierIndicator<Graph>::Type ItemNotifier;
132 template <typename _Value>
133 class Map : public Graph::template EdgeMap<_Value> {
135 typedef typename Graph::template EdgeMap<_Value> Parent;
136 typedef typename Graph::template EdgeMap<_Value> Type;
137 typedef typename Parent::Value Value;
139 Map(const Graph& _digraph) : Parent(_digraph) {}
140 Map(const Graph& _digraph, const Value& _value)
141 : Parent(_digraph, _value) {}
146 template <typename Map, typename Enable = void>
148 typedef False ReferenceMapTag;
150 typedef typename Map::Key Key;
151 typedef typename Map::Value Value;
153 typedef Value ConstReturnValue;
154 typedef Value ReturnValue;
157 template <typename Map>
159 Map, typename enable_if<typename Map::ReferenceMapTag, void>::type >
161 typedef True ReferenceMapTag;
163 typedef typename Map::Key Key;
164 typedef typename Map::Value Value;
166 typedef typename Map::ConstReference ConstReturnValue;
167 typedef typename Map::Reference ReturnValue;
169 typedef typename Map::ConstReference ConstReference;
170 typedef typename Map::Reference Reference;
173 template <typename MatrixMap, typename Enable = void>
174 struct MatrixMapTraits {
175 typedef False ReferenceMapTag;
177 typedef typename MatrixMap::FirstKey FirstKey;
178 typedef typename MatrixMap::SecondKey SecondKey;
179 typedef typename MatrixMap::Value Value;
181 typedef Value ConstReturnValue;
182 typedef Value ReturnValue;
185 template <typename MatrixMap>
186 struct MatrixMapTraits<
187 MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag,
190 typedef True ReferenceMapTag;
192 typedef typename MatrixMap::FirstKey FirstKey;
193 typedef typename MatrixMap::SecondKey SecondKey;
194 typedef typename MatrixMap::Value Value;
196 typedef typename MatrixMap::ConstReference ConstReturnValue;
197 typedef typename MatrixMap::Reference ReturnValue;
199 typedef typename MatrixMap::ConstReference ConstReference;
200 typedef typename MatrixMap::Reference Reference;
203 // Indicators for the tags
205 template <typename Graph, typename Enable = void>
206 struct NodeNumTagIndicator {
207 static const bool value = false;
210 template <typename Graph>
211 struct NodeNumTagIndicator<
213 typename enable_if<typename Graph::NodeNumTag, void>::type
215 static const bool value = true;
218 template <typename Graph, typename Enable = void>
219 struct EdgeNumTagIndicator {
220 static const bool value = false;
223 template <typename Graph>
224 struct EdgeNumTagIndicator<
226 typename enable_if<typename Graph::EdgeNumTag, void>::type
228 static const bool value = true;
231 template <typename Graph, typename Enable = void>
232 struct FindEdgeTagIndicator {
233 static const bool value = false;
236 template <typename Graph>
237 struct FindEdgeTagIndicator<
239 typename enable_if<typename Graph::FindEdgeTag, void>::type
241 static const bool value = true;
244 template <typename Graph, typename Enable = void>
245 struct UndirectedTagIndicator {
246 static const bool value = false;
249 template <typename Graph>
250 struct UndirectedTagIndicator<
252 typename enable_if<typename Graph::UndirectedTag, void>::type
254 static const bool value = true;
257 template <typename Graph, typename Enable = void>
258 struct BuildTagIndicator {
259 static const bool value = false;
262 template <typename Graph>
263 struct BuildTagIndicator<
265 typename enable_if<typename Graph::BuildTag, void>::type
267 static const bool value = true;