lemon/traits.h
changeset 1993 2115143eceea
parent 1992 6e1b62d42d94
child 1994 9430de370570
     1.1 --- a/lemon/traits.h	Wed Mar 01 12:46:52 2006 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,300 +0,0 @@
     1.4 -/* -*- C++ -*-
     1.5 - *
     1.6 - * This file is a part of LEMON, a generic C++ optimization library
     1.7 - *
     1.8 - * Copyright (C) 2003-2006
     1.9 - * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 - *
    1.12 - * Permission to use, modify and distribute this software is granted
    1.13 - * provided that this copyright notice appears in all copies. For
    1.14 - * precise terms see the accompanying LICENSE file.
    1.15 - *
    1.16 - * This software is provided "AS IS" with no warranty of any kind,
    1.17 - * express or implied, and with no claim as to its suitability for any
    1.18 - * purpose.
    1.19 - *
    1.20 - */
    1.21 -
    1.22 -#ifndef LEMON_TRAITS_H
    1.23 -#define LEMON_TRAITS_H
    1.24 -
    1.25 -#include <lemon/utility.h>
    1.26 -
    1.27 -///\file
    1.28 -///\brief Traits for graphs and maps
    1.29 -///
    1.30 -
    1.31 -namespace lemon {
    1.32 -  template <typename _Graph, typename _Item>
    1.33 -  class ItemSetTraits {};
    1.34 -  
    1.35 -
    1.36 -  template <typename Graph, typename Enable = void>
    1.37 -  struct NodeNotifierIndicator {
    1.38 -    typedef InvalidType Type;
    1.39 -  };
    1.40 -  template <typename Graph>
    1.41 -  struct NodeNotifierIndicator<
    1.42 -    Graph, 
    1.43 -    typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
    1.44 -  > { 
    1.45 -    typedef typename Graph::NodeNotifier Type;
    1.46 -  };
    1.47 -
    1.48 -  template <typename _Graph>
    1.49 -  class ItemSetTraits<_Graph, typename _Graph::Node> {
    1.50 -  public:
    1.51 -    
    1.52 -    typedef _Graph Graph;
    1.53 -
    1.54 -    typedef typename Graph::Node Item;
    1.55 -    typedef typename Graph::NodeIt ItemIt;
    1.56 -
    1.57 -    typedef typename NodeNotifierIndicator<Graph>::Type ItemNotifier;
    1.58 -
    1.59 -    template <typename _Value>
    1.60 -    class Map : public Graph::template NodeMap<_Value> {
    1.61 -    public:
    1.62 -      typedef typename Graph::template NodeMap<_Value> Parent; 
    1.63 -      typedef typename Parent::Value Value;
    1.64 -
    1.65 -      Map(const Graph& _graph) : Parent(_graph) {}
    1.66 -      Map(const Graph& _graph, const Value& _value) 
    1.67 -	: Parent(_graph, _value) {}
    1.68 -
    1.69 -     };
    1.70 -
    1.71 -  };
    1.72 -
    1.73 -  template <typename Graph, typename Enable = void>
    1.74 -  struct EdgeNotifierIndicator {
    1.75 -    typedef InvalidType Type;
    1.76 -  };
    1.77 -  template <typename Graph>
    1.78 -  struct EdgeNotifierIndicator<
    1.79 -    Graph, 
    1.80 -    typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
    1.81 -  > { 
    1.82 -    typedef typename Graph::EdgeNotifier Type;
    1.83 -  };
    1.84 -
    1.85 -  template <typename _Graph>
    1.86 -  class ItemSetTraits<_Graph, typename _Graph::Edge> {
    1.87 -  public:
    1.88 -    
    1.89 -    typedef _Graph Graph;
    1.90 -
    1.91 -    typedef typename Graph::Edge Item;
    1.92 -    typedef typename Graph::EdgeIt ItemIt;
    1.93 -
    1.94 -    typedef typename EdgeNotifierIndicator<Graph>::Type ItemNotifier;
    1.95 -
    1.96 -    template <typename _Value>
    1.97 -    class Map : public Graph::template EdgeMap<_Value> {
    1.98 -    public:
    1.99 -      typedef typename Graph::template EdgeMap<_Value> Parent; 
   1.100 -      typedef typename Parent::Value Value;
   1.101 -
   1.102 -      Map(const Graph& _graph) : Parent(_graph) {}
   1.103 -      Map(const Graph& _graph, const Value& _value) 
   1.104 -	: Parent(_graph, _value) {}
   1.105 -    };
   1.106 -
   1.107 -  };
   1.108 -
   1.109 -  template <typename Graph, typename Enable = void>
   1.110 -  struct UEdgeNotifierIndicator {
   1.111 -    typedef InvalidType Type;
   1.112 -  };
   1.113 -  template <typename Graph>
   1.114 -  struct UEdgeNotifierIndicator<
   1.115 -    Graph, 
   1.116 -    typename enable_if<typename Graph::UEdgeNotifier::Notifier, void>::type
   1.117 -  > { 
   1.118 -    typedef typename Graph::UEdgeNotifier Type;
   1.119 -  };
   1.120 -
   1.121 -  template <typename _Graph>
   1.122 -  class ItemSetTraits<_Graph, typename _Graph::UEdge> {
   1.123 -  public:
   1.124 -    
   1.125 -    typedef _Graph Graph;
   1.126 -
   1.127 -    typedef typename Graph::UEdge Item;
   1.128 -    typedef typename Graph::UEdgeIt ItemIt;
   1.129 -
   1.130 -    typedef typename UEdgeNotifierIndicator<Graph>::Type ItemNotifier;
   1.131 -
   1.132 -    template <typename _Value>
   1.133 -    class Map : public Graph::template UEdgeMap<_Value> {
   1.134 -    public:
   1.135 -      typedef typename Graph::template UEdgeMap<_Value> Parent; 
   1.136 -      typedef typename Parent::Value Value;
   1.137 -
   1.138 -      Map(const Graph& _graph) : Parent(_graph) {}
   1.139 -      Map(const Graph& _graph, const Value& _value) 
   1.140 -	: Parent(_graph, _value) {}
   1.141 -    };
   1.142 -
   1.143 -  };
   1.144 -
   1.145 -  template <typename Graph, typename Enable = void>
   1.146 -  struct ANodeNotifierIndicator {
   1.147 -    typedef InvalidType Type;
   1.148 -  };
   1.149 -  template <typename Graph>
   1.150 -  struct ANodeNotifierIndicator<
   1.151 -    Graph, 
   1.152 -    typename enable_if<typename Graph::ANodeNotifier::Notifier, void>::type
   1.153 -  > { 
   1.154 -    typedef typename Graph::ANodeNotifier Type;
   1.155 -  };
   1.156 -
   1.157 -  template <typename _Graph>
   1.158 -  class ItemSetTraits<_Graph, typename _Graph::ANode> {
   1.159 -  public:
   1.160 -    
   1.161 -    typedef _Graph Graph;
   1.162 -
   1.163 -    typedef typename Graph::ANode Item;
   1.164 -    typedef typename Graph::ANodeIt ItemIt;
   1.165 -
   1.166 -    typedef typename ANodeNotifierIndicator<Graph>::Type ItemNotifier;
   1.167 -
   1.168 -    template <typename _Value>
   1.169 -    class Map : public Graph::template ANodeMap<_Value> {
   1.170 -    public:
   1.171 -      typedef typename Graph::template ANodeMap<_Value> Parent; 
   1.172 -      typedef typename Parent::Value Value;
   1.173 -
   1.174 -      Map(const Graph& _graph) : Parent(_graph) {}
   1.175 -      Map(const Graph& _graph, const Value& _value) 
   1.176 -	: Parent(_graph, _value) {}
   1.177 -    };
   1.178 -
   1.179 -  };
   1.180 -
   1.181 -  template <typename Graph, typename Enable = void>
   1.182 -  struct BNodeNotifierIndicator {
   1.183 -    typedef InvalidType Type;
   1.184 -  };
   1.185 -  template <typename Graph>
   1.186 -  struct BNodeNotifierIndicator<
   1.187 -    Graph, 
   1.188 -    typename enable_if<typename Graph::BNodeNotifier::Notifier, void>::type
   1.189 -  > { 
   1.190 -    typedef typename Graph::BNodeNotifier Type;
   1.191 -  };
   1.192 -
   1.193 -  template <typename _Graph>
   1.194 -  class ItemSetTraits<_Graph, typename _Graph::BNode> {
   1.195 -  public:
   1.196 -    
   1.197 -    typedef _Graph Graph;
   1.198 -
   1.199 -    typedef typename Graph::BNode Item;
   1.200 -    typedef typename Graph::BNodeIt ItemIt;
   1.201 -
   1.202 -    typedef typename BNodeNotifierIndicator<Graph>::Type ItemNotifier;
   1.203 -
   1.204 -    template <typename _Value>
   1.205 -    class Map : public Graph::template BNodeMap<_Value> {
   1.206 -    public:
   1.207 -      typedef typename Graph::template BNodeMap<_Value> Parent; 
   1.208 -      typedef typename Parent::Value Value;
   1.209 -
   1.210 -      Map(const Graph& _graph) : Parent(_graph) {}
   1.211 -      Map(const Graph& _graph, const Value& _value) 
   1.212 -	: Parent(_graph, _value) {}
   1.213 -    };
   1.214 -
   1.215 -  };
   1.216 -
   1.217 -
   1.218 -  template <typename Map, typename Enable = void>
   1.219 -  struct MapTraits {
   1.220 -    typedef False ReferenceMapTag;
   1.221 -
   1.222 -    typedef typename Map::Key Key;
   1.223 -    typedef typename Map::Value Value;
   1.224 -
   1.225 -    typedef const Value ConstReturnValue;
   1.226 -    typedef const Value ReturnValue;
   1.227 -  };
   1.228 -
   1.229 -  template <typename Map>
   1.230 -  struct MapTraits<
   1.231 -    Map, typename enable_if<typename Map::ReferenceMapTag, void>::type > 
   1.232 -  {
   1.233 -    typedef True ReferenceMapTag;
   1.234 -    
   1.235 -    typedef typename Map::Key Key;
   1.236 -    typedef typename Map::Value Value;
   1.237 -
   1.238 -    typedef typename Map::ConstReference ConstReturnValue;
   1.239 -    typedef typename Map::Reference ReturnValue;
   1.240 -
   1.241 -    typedef typename Map::ConstReference ConstReference; 
   1.242 -    typedef typename Map::Reference Reference;
   1.243 - };
   1.244 -
   1.245 -  // Indicators for the tags
   1.246 -
   1.247 -  template <typename Graph, typename Enable = void>
   1.248 -  struct NodeNumTagIndicator {
   1.249 -    static const bool value = false;
   1.250 -  };
   1.251 -
   1.252 -  template <typename Graph>
   1.253 -  struct NodeNumTagIndicator<
   1.254 -    Graph, 
   1.255 -    typename enable_if<typename Graph::NodeNumTag, void>::type
   1.256 -  > {
   1.257 -    static const bool value = true;
   1.258 -  };
   1.259 -
   1.260 -  template <typename Graph, typename Enable = void>
   1.261 -  struct EdgeNumTagIndicator {
   1.262 -    static const bool value = false;
   1.263 -  };
   1.264 -
   1.265 -  template <typename Graph>
   1.266 -  struct EdgeNumTagIndicator<
   1.267 -    Graph, 
   1.268 -    typename enable_if<typename Graph::EdgeNumTag, void>::type
   1.269 -  > {
   1.270 -    static const bool value = true;
   1.271 -  };
   1.272 -
   1.273 -  template <typename Graph, typename Enable = void>
   1.274 -  struct FindEdgeTagIndicator {
   1.275 -    static const bool value = false;
   1.276 -  };
   1.277 -
   1.278 -  template <typename Graph>
   1.279 -  struct FindEdgeTagIndicator<
   1.280 -    Graph, 
   1.281 -    typename enable_if<typename Graph::FindEdgeTag, void>::type
   1.282 -  > {
   1.283 -    static const bool value = true;
   1.284 -  };
   1.285 -
   1.286 -  template <typename Graph, typename Enable = void>
   1.287 -  struct UndirectedTagIndicator {
   1.288 -    static const bool value = false;
   1.289 -  };
   1.290 -
   1.291 -  template <typename Graph>
   1.292 -  struct UndirectedTagIndicator<
   1.293 -    Graph, 
   1.294 -    typename enable_if<typename Graph::UndirectedTag, void>::type
   1.295 -  > {
   1.296 -    static const bool value = true;
   1.297 -  };
   1.298 -
   1.299 -
   1.300 -
   1.301 -}
   1.302 -
   1.303 -#endif // LEMON_MAPS_H