deba@1719: /* -*- C++ -*- deba@1719: * lemon/traits.h - Part of LEMON, a generic C++ optimization library deba@1719: * alpar@1875: * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport deba@1719: * (Egervary Research Group on Combinatorial Optimization, EGRES). deba@1719: * deba@1719: * Permission to use, modify and distribute this software is granted deba@1719: * provided that this copyright notice appears in all copies. For deba@1719: * precise terms see the accompanying LICENSE file. deba@1719: * deba@1719: * This software is provided "AS IS" with no warranty of any kind, deba@1719: * express or implied, and with no claim as to its suitability for any deba@1719: * purpose. deba@1719: * deba@1719: */ deba@1719: deba@1719: #ifndef LEMON_TRAITS_H deba@1719: #define LEMON_TRAITS_H deba@1719: deba@1719: #include deba@1719: deba@1719: ///\file deba@1719: ///\brief Traits for graphs and maps deba@1719: /// deba@1719: deba@1719: namespace lemon { deba@1719: template deba@1719: class ItemSetTraits {}; deba@1719: deba@1719: template deba@1719: class ItemSetTraits<_Graph, typename _Graph::Node> { deba@1719: public: deba@1719: deba@1719: typedef _Graph Graph; deba@1719: deba@1719: typedef typename Graph::Node Item; deba@1719: typedef typename Graph::NodeIt ItemIt; deba@1719: deba@1719: template deba@1719: class Map : public Graph::template NodeMap<_Value> { deba@1719: public: deba@1719: typedef typename Graph::template NodeMap<_Value> Parent; deba@1719: typedef typename Parent::Value Value; deba@1719: deba@1719: Map(const Graph& _graph) : Parent(_graph) {} deba@1719: Map(const Graph& _graph, const Value& _value) deba@1719: : Parent(_graph, _value) {} deba@1719: }; deba@1719: deba@1719: }; deba@1719: deba@1719: template deba@1719: class ItemSetTraits<_Graph, typename _Graph::Edge> { deba@1719: public: deba@1719: deba@1719: typedef _Graph Graph; deba@1719: deba@1719: typedef typename Graph::Edge Item; deba@1719: typedef typename Graph::EdgeIt ItemIt; deba@1719: deba@1719: template deba@1719: class Map : public Graph::template EdgeMap<_Value> { deba@1719: public: deba@1719: typedef typename Graph::template EdgeMap<_Value> Parent; deba@1719: typedef typename Parent::Value Value; deba@1719: deba@1719: Map(const Graph& _graph) : Parent(_graph) {} deba@1719: Map(const Graph& _graph, const Value& _value) deba@1719: : Parent(_graph, _value) {} deba@1719: }; deba@1719: deba@1719: }; deba@1719: deba@1719: template klao@1909: class ItemSetTraits<_Graph, typename _Graph::UEdge> { deba@1719: public: deba@1719: deba@1719: typedef _Graph Graph; deba@1719: klao@1909: typedef typename Graph::UEdge Item; klao@1909: typedef typename Graph::UEdgeIt ItemIt; deba@1719: deba@1719: template klao@1909: class Map : public Graph::template UEdgeMap<_Value> { deba@1719: public: klao@1909: typedef typename Graph::template UEdgeMap<_Value> Parent; deba@1719: typedef typename Parent::Value Value; deba@1719: deba@1719: Map(const Graph& _graph) : Parent(_graph) {} deba@1719: Map(const Graph& _graph, const Value& _value) deba@1719: : Parent(_graph, _value) {} deba@1719: }; deba@1719: deba@1719: }; deba@1719: deba@1719: template deba@1719: struct MapTraits { deba@1719: typedef False ReferenceMapTag; deba@1719: deba@1719: typedef typename Map::Key Key; deba@1719: typedef typename Map::Value Value; deba@1719: deba@1790: typedef const Value ConstReturnValue; deba@1790: typedef const Value ReturnValue; deba@1719: }; deba@1719: deba@1719: template deba@1719: struct MapTraits< deba@1719: Map, typename enable_if::type > deba@1719: { deba@1719: typedef True ReferenceMapTag; deba@1719: deba@1719: typedef typename Map::Key Key; deba@1719: typedef typename Map::Value Value; deba@1719: deba@1719: typedef typename Map::ConstReference ConstReturnValue; deba@1719: typedef typename Map::Reference ReturnValue; deba@1719: deba@1719: typedef typename Map::ConstReference ConstReference; deba@1719: typedef typename Map::Reference Reference; deba@1719: }; deba@1719: deba@1719: // Indicators for the tags deba@1719: deba@1719: template deba@1719: struct NodeNumTagIndicator { deba@1719: static const bool value = false; deba@1719: }; deba@1719: deba@1719: template deba@1719: struct NodeNumTagIndicator< deba@1719: Graph, deba@1719: typename enable_if::type deba@1719: > { deba@1719: static const bool value = true; deba@1719: }; deba@1719: deba@1719: template deba@1719: struct EdgeNumTagIndicator { deba@1719: static const bool value = false; deba@1719: }; deba@1719: deba@1719: template deba@1719: struct EdgeNumTagIndicator< deba@1719: Graph, deba@1719: typename enable_if::type deba@1719: > { deba@1719: static const bool value = true; deba@1719: }; deba@1719: deba@1719: template deba@1719: struct FindEdgeTagIndicator { deba@1719: static const bool value = false; deba@1719: }; deba@1719: deba@1719: template deba@1719: struct FindEdgeTagIndicator< deba@1719: Graph, deba@1719: typename enable_if::type deba@1719: > { deba@1719: static const bool value = true; deba@1719: }; deba@1719: deba@1719: deba@1719: deba@1719: } deba@1719: deba@1719: #endif // LEMON_MAPS_H