deba@1993: /* -*- C++ -*- deba@1993: * deba@1993: * This file is a part of LEMON, a generic C++ optimization library deba@1993: * deba@1993: * Copyright (C) 2003-2006 deba@1993: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport deba@1993: * (Egervary Research Group on Combinatorial Optimization, EGRES). deba@1993: * deba@1993: * Permission to use, modify and distribute this software is granted deba@1993: * provided that this copyright notice appears in all copies. For deba@1993: * precise terms see the accompanying LICENSE file. deba@1993: * deba@1993: * This software is provided "AS IS" with no warranty of any kind, deba@1993: * express or implied, and with no claim as to its suitability for any deba@1993: * purpose. deba@1993: * deba@1993: */ deba@1993: deba@1993: #ifndef LEMON_BITS_TRAITS_H deba@1993: #define LEMON_BITS_TRAITS_H deba@1993: deba@1993: #include deba@1993: deba@1993: ///\file deba@1993: ///\brief Traits for graphs and maps deba@1993: /// deba@1993: deba@1993: namespace lemon { deba@1993: template deba@1993: class ItemSetTraits {}; deba@1993: deba@1993: deba@1993: template deba@1993: struct NodeNotifierIndicator { deba@1993: typedef InvalidType Type; deba@1993: }; deba@1993: template deba@1993: struct NodeNotifierIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: typedef typename Graph::NodeNotifier Type; deba@1993: }; deba@1993: deba@1993: template deba@1993: class ItemSetTraits<_Graph, typename _Graph::Node> { deba@1993: public: deba@1993: deba@1993: typedef _Graph Graph; deba@1993: deba@1993: typedef typename Graph::Node Item; deba@1993: typedef typename Graph::NodeIt ItemIt; deba@1993: deba@1993: typedef typename NodeNotifierIndicator::Type ItemNotifier; deba@1993: deba@1993: template deba@1993: class Map : public Graph::template NodeMap<_Value> { deba@1993: public: deba@1993: typedef typename Graph::template NodeMap<_Value> Parent; deba@1993: typedef typename Parent::Value Value; deba@1993: deba@1993: Map(const Graph& _graph) : Parent(_graph) {} deba@1993: Map(const Graph& _graph, const Value& _value) deba@1993: : Parent(_graph, _value) {} deba@1993: deba@1993: }; deba@1993: deba@1993: }; deba@1993: deba@1993: template deba@1993: struct EdgeNotifierIndicator { deba@1993: typedef InvalidType Type; deba@1993: }; deba@1993: template deba@1993: struct EdgeNotifierIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: typedef typename Graph::EdgeNotifier Type; deba@1993: }; deba@1993: deba@1993: template deba@1993: class ItemSetTraits<_Graph, typename _Graph::Edge> { deba@1993: public: deba@1993: deba@1993: typedef _Graph Graph; deba@1993: deba@1993: typedef typename Graph::Edge Item; deba@1993: typedef typename Graph::EdgeIt ItemIt; deba@1993: deba@1993: typedef typename EdgeNotifierIndicator::Type ItemNotifier; deba@1993: deba@1993: template deba@1993: class Map : public Graph::template EdgeMap<_Value> { deba@1993: public: deba@1993: typedef typename Graph::template EdgeMap<_Value> Parent; deba@1993: typedef typename Parent::Value Value; deba@1993: deba@1993: Map(const Graph& _graph) : Parent(_graph) {} deba@1993: Map(const Graph& _graph, const Value& _value) deba@1993: : Parent(_graph, _value) {} deba@1993: }; deba@1993: deba@1993: }; deba@1993: deba@1993: template deba@1993: struct UEdgeNotifierIndicator { deba@1993: typedef InvalidType Type; deba@1993: }; deba@1993: template deba@1993: struct UEdgeNotifierIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: typedef typename Graph::UEdgeNotifier Type; deba@1993: }; deba@1993: deba@1993: template deba@1993: class ItemSetTraits<_Graph, typename _Graph::UEdge> { deba@1993: public: deba@1993: deba@1993: typedef _Graph Graph; deba@1993: deba@1993: typedef typename Graph::UEdge Item; deba@1993: typedef typename Graph::UEdgeIt ItemIt; deba@1993: deba@1993: typedef typename UEdgeNotifierIndicator::Type ItemNotifier; deba@1993: deba@1993: template deba@1993: class Map : public Graph::template UEdgeMap<_Value> { deba@1993: public: deba@1993: typedef typename Graph::template UEdgeMap<_Value> Parent; deba@1993: typedef typename Parent::Value Value; deba@1993: deba@1993: Map(const Graph& _graph) : Parent(_graph) {} deba@1993: Map(const Graph& _graph, const Value& _value) deba@1993: : Parent(_graph, _value) {} deba@1993: }; deba@1993: deba@1993: }; deba@1993: deba@1993: template deba@1993: struct ANodeNotifierIndicator { deba@1993: typedef InvalidType Type; deba@1993: }; deba@1993: template deba@1993: struct ANodeNotifierIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: typedef typename Graph::ANodeNotifier Type; deba@1993: }; deba@1993: deba@1993: template deba@1993: class ItemSetTraits<_Graph, typename _Graph::ANode> { deba@1993: public: deba@1993: deba@1993: typedef _Graph Graph; deba@1993: deba@1993: typedef typename Graph::ANode Item; deba@1993: typedef typename Graph::ANodeIt ItemIt; deba@1993: deba@1993: typedef typename ANodeNotifierIndicator::Type ItemNotifier; deba@1993: deba@1993: template deba@1993: class Map : public Graph::template ANodeMap<_Value> { deba@1993: public: deba@1993: typedef typename Graph::template ANodeMap<_Value> Parent; deba@1993: typedef typename Parent::Value Value; deba@1993: deba@1993: Map(const Graph& _graph) : Parent(_graph) {} deba@1993: Map(const Graph& _graph, const Value& _value) deba@1993: : Parent(_graph, _value) {} deba@1993: }; deba@1993: deba@1993: }; deba@1993: deba@1993: template deba@1993: struct BNodeNotifierIndicator { deba@1993: typedef InvalidType Type; deba@1993: }; deba@1993: template deba@1993: struct BNodeNotifierIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: typedef typename Graph::BNodeNotifier Type; deba@1993: }; deba@1993: deba@1993: template deba@1993: class ItemSetTraits<_Graph, typename _Graph::BNode> { deba@1993: public: deba@1993: deba@1993: typedef _Graph Graph; deba@1993: deba@1993: typedef typename Graph::BNode Item; deba@1993: typedef typename Graph::BNodeIt ItemIt; deba@1993: deba@1993: typedef typename BNodeNotifierIndicator::Type ItemNotifier; deba@1993: deba@1993: template deba@1993: class Map : public Graph::template BNodeMap<_Value> { deba@1993: public: deba@1993: typedef typename Graph::template BNodeMap<_Value> Parent; deba@1993: typedef typename Parent::Value Value; deba@1993: deba@1993: Map(const Graph& _graph) : Parent(_graph) {} deba@1993: Map(const Graph& _graph, const Value& _value) deba@1993: : Parent(_graph, _value) {} deba@1993: }; deba@1993: deba@1993: }; deba@1993: deba@1993: deba@1993: template deba@1993: struct MapTraits { deba@1993: typedef False ReferenceMapTag; deba@1993: deba@1993: typedef typename Map::Key Key; deba@1993: typedef typename Map::Value Value; deba@1993: deba@1993: typedef const Value ConstReturnValue; deba@1993: typedef const Value ReturnValue; deba@1993: }; deba@1993: deba@1993: template deba@1993: struct MapTraits< deba@1993: Map, typename enable_if::type > deba@1993: { deba@1993: typedef True ReferenceMapTag; deba@1993: deba@1993: typedef typename Map::Key Key; deba@1993: typedef typename Map::Value Value; deba@1993: deba@1993: typedef typename Map::ConstReference ConstReturnValue; deba@1993: typedef typename Map::Reference ReturnValue; deba@1993: deba@1993: typedef typename Map::ConstReference ConstReference; deba@1993: typedef typename Map::Reference Reference; deba@1993: }; deba@1993: deba@2039: template deba@2039: struct MatrixMapTraits { deba@2039: typedef False ReferenceMapTag; deba@2039: deba@2039: typedef typename MatrixMap::FirstKey FirstKey; deba@2039: typedef typename MatrixMap::SecondKey SecondKey; deba@2039: typedef typename MatrixMap::Value Value; deba@2039: deba@2039: typedef const Value ConstReturnValue; deba@2039: typedef const Value ReturnValue; deba@2039: }; deba@2039: deba@2039: template deba@2039: struct MatrixMapTraits< deba@2039: MatrixMap, typename enable_if::type > deba@2039: { deba@2039: typedef True ReferenceMapTag; deba@2039: deba@2039: typedef typename MatrixMap::FirstKey FirstKey; deba@2039: typedef typename MatrixMap::SecondKey SecondKey; deba@2039: typedef typename MatrixMap::Value Value; deba@2039: deba@2039: typedef typename MatrixMap::ConstReference ConstReturnValue; deba@2039: typedef typename MatrixMap::Reference ReturnValue; deba@2039: deba@2039: typedef typename MatrixMap::ConstReference ConstReference; deba@2039: typedef typename MatrixMap::Reference Reference; deba@2039: }; deba@2039: deba@1993: // Indicators for the tags deba@1993: deba@1993: template deba@1993: struct NodeNumTagIndicator { deba@1993: static const bool value = false; deba@1993: }; deba@1993: deba@1993: template deba@1993: struct NodeNumTagIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: static const bool value = true; deba@1993: }; deba@1993: deba@1993: template deba@1993: struct EdgeNumTagIndicator { deba@1993: static const bool value = false; deba@1993: }; deba@1993: deba@1993: template deba@1993: struct EdgeNumTagIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: static const bool value = true; deba@1993: }; deba@1993: deba@1993: template deba@1993: struct FindEdgeTagIndicator { deba@1993: static const bool value = false; deba@1993: }; deba@1993: deba@1993: template deba@1993: struct FindEdgeTagIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: static const bool value = true; deba@1993: }; deba@1993: deba@1993: template deba@1993: struct UndirectedTagIndicator { deba@1993: static const bool value = false; deba@1993: }; deba@1993: deba@1993: template deba@1993: struct UndirectedTagIndicator< deba@1993: Graph, deba@1993: typename enable_if::type deba@1993: > { deba@1993: static const bool value = true; deba@1993: }; deba@1993: deba@2290: template deba@2290: struct CloneableTagIndicator { deba@2290: static const bool value = false; deba@2290: }; deba@1993: deba@2290: template deba@2290: struct CloneableTagIndicator< deba@2290: Graph, deba@2290: typename enable_if::type deba@2290: > { deba@2290: static const bool value = true; deba@2290: }; deba@1993: deba@1993: } deba@1993: deba@1996: #endif