/* -*- mode: C++; indent-tabs-mode: nil; -*- * * This file is a part of LEMON, a generic C++ optimization library. * * Copyright (C) 2003-2013 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * * Permission to use, modify and distribute this software is granted * provided that this copyright notice appears in all copies. For * precise terms see the accompanying LICENSE file. * * This software is provided "AS IS" with no warranty of any kind, * express or implied, and with no claim as to its suitability for any * purpose. * */ #ifndef LEMON_BITS_TRAITS_H #define LEMON_BITS_TRAITS_H //\file //\brief Traits for graphs and maps // #include namespace lemon { struct InvalidType {}; template class ItemSetTraits {}; template struct NodeNotifierIndicator { typedef InvalidType Type; }; template struct NodeNotifierIndicator< GR, typename enable_if::type > { typedef typename GR::NodeNotifier Type; }; template class ItemSetTraits { public: typedef GR Graph; typedef GR Digraph; typedef typename GR::Node Item; typedef typename GR::NodeIt ItemIt; typedef typename NodeNotifierIndicator::Type ItemNotifier; template class Map : public GR::template NodeMap { typedef typename GR::template NodeMap Parent; public: typedef typename GR::template NodeMap Type; typedef typename Parent::Value Value; Map(const GR& _digraph) : Parent(_digraph) {} Map(const GR& _digraph, const Value& _value) : Parent(_digraph, _value) {} }; }; template struct ArcNotifierIndicator { typedef InvalidType Type; }; template struct ArcNotifierIndicator< GR, typename enable_if::type > { typedef typename GR::ArcNotifier Type; }; template class ItemSetTraits { public: typedef GR Graph; typedef GR Digraph; typedef typename GR::Arc Item; typedef typename GR::ArcIt ItemIt; typedef typename ArcNotifierIndicator::Type ItemNotifier; template class Map : public GR::template ArcMap { typedef typename GR::template ArcMap Parent; public: typedef typename GR::template ArcMap Type; typedef typename Parent::Value Value; Map(const GR& _digraph) : Parent(_digraph) {} Map(const GR& _digraph, const Value& _value) : Parent(_digraph, _value) {} }; }; template struct EdgeNotifierIndicator { typedef InvalidType Type; }; template struct EdgeNotifierIndicator< GR, typename enable_if::type > { typedef typename GR::EdgeNotifier Type; }; template class ItemSetTraits { public: typedef GR Graph; typedef GR Digraph; typedef typename GR::Edge Item; typedef typename GR::EdgeIt ItemIt; typedef typename EdgeNotifierIndicator::Type ItemNotifier; template class Map : public GR::template EdgeMap { typedef typename GR::template EdgeMap Parent; public: typedef typename GR::template EdgeMap Type; typedef typename Parent::Value Value; Map(const GR& _digraph) : Parent(_digraph) {} Map(const GR& _digraph, const Value& _value) : Parent(_digraph, _value) {} }; }; template struct RedNodeNotifierIndicator { typedef InvalidType Type; }; template struct RedNodeNotifierIndicator< GR, typename enable_if::type > { typedef typename GR::RedNodeNotifier Type; }; template class ItemSetTraits { public: typedef GR BpGraph; typedef GR Graph; typedef GR Digraph; typedef typename GR::RedNode Item; typedef typename GR::RedNodeIt ItemIt; typedef typename RedNodeNotifierIndicator::Type ItemNotifier; template class Map : public GR::template RedNodeMap { typedef typename GR::template RedNodeMap Parent; public: typedef typename GR::template RedNodeMap Type; typedef typename Parent::Value Value; Map(const GR& _bpgraph) : Parent(_bpgraph) {} Map(const GR& _bpgraph, const Value& _value) : Parent(_bpgraph, _value) {} }; }; template struct BlueNodeNotifierIndicator { typedef InvalidType Type; }; template struct BlueNodeNotifierIndicator< GR, typename enable_if::type > { typedef typename GR::BlueNodeNotifier Type; }; template class ItemSetTraits { public: typedef GR BpGraph; typedef GR Graph; typedef GR Digraph; typedef typename GR::BlueNode Item; typedef typename GR::BlueNodeIt ItemIt; typedef typename BlueNodeNotifierIndicator::Type ItemNotifier; template class Map : public GR::template BlueNodeMap { typedef typename GR::template BlueNodeMap Parent; public: typedef typename GR::template BlueNodeMap Type; typedef typename Parent::Value Value; Map(const GR& _bpgraph) : Parent(_bpgraph) {} Map(const GR& _bpgraph, const Value& _value) : Parent(_bpgraph, _value) {} }; }; template struct MapTraits { typedef False ReferenceMapTag; typedef typename Map::Key Key; typedef typename Map::Value Value; typedef Value ConstReturnValue; typedef Value ReturnValue; }; template struct MapTraits< Map, typename enable_if::type > { typedef True ReferenceMapTag; typedef typename Map::Key Key; typedef typename Map::Value Value; typedef typename Map::ConstReference ConstReturnValue; typedef typename Map::Reference ReturnValue; typedef typename Map::ConstReference ConstReference; typedef typename Map::Reference Reference; }; template struct MatrixMapTraits { typedef False ReferenceMapTag; typedef typename MatrixMap::FirstKey FirstKey; typedef typename MatrixMap::SecondKey SecondKey; typedef typename MatrixMap::Value Value; typedef Value ConstReturnValue; typedef Value ReturnValue; }; template struct MatrixMapTraits< MatrixMap, typename enable_if::type > { typedef True ReferenceMapTag; typedef typename MatrixMap::FirstKey FirstKey; typedef typename MatrixMap::SecondKey SecondKey; typedef typename MatrixMap::Value Value; typedef typename MatrixMap::ConstReference ConstReturnValue; typedef typename MatrixMap::Reference ReturnValue; typedef typename MatrixMap::ConstReference ConstReference; typedef typename MatrixMap::Reference Reference; }; // Indicators for the tags template struct NodeNumTagIndicator { static const bool value = false; }; template struct NodeNumTagIndicator< GR, typename enable_if::type > { static const bool value = true; }; template struct ArcNumTagIndicator { static const bool value = false; }; template struct ArcNumTagIndicator< GR, typename enable_if::type > { static const bool value = true; }; template struct EdgeNumTagIndicator { static const bool value = false; }; template struct EdgeNumTagIndicator< GR, typename enable_if::type > { static const bool value = true; }; template struct FindArcTagIndicator { static const bool value = false; }; template struct FindArcTagIndicator< GR, typename enable_if::type > { static const bool value = true; }; template struct FindEdgeTagIndicator { static const bool value = false; }; template struct FindEdgeTagIndicator< GR, typename enable_if::type > { static const bool value = true; }; template struct UndirectedTagIndicator { static const bool value = false; }; template struct UndirectedTagIndicator< GR, typename enable_if::type > { static const bool value = true; }; template struct BuildTagIndicator { static const bool value = false; }; template struct BuildTagIndicator< GR, typename enable_if::type > { static const bool value = true; }; } #endif