- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# graphcontainer.hh

    00001 // graphcontainer.hh: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 2007, 2008 The Vaucanson Group.
    00006 //
    00007 // This program is free software; you can redistribute it and/or
    00008 // modify it under the terms of the GNU General Public License
    00009 // as published by the Free Software Foundation; either version 2
    00010 // of the License, or (at your option) any later version.
    00011 //
    00012 // The complete GNU General Public Licence Notice can be found as the
    00013 // `COPYING' file in the root directory.
    00014 //
    00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
    00016 //
    00017
    00018 #ifndef VCSN_AUTOMATA_IMPLEMENTATION_BMIG_GRAPHCONTAINER_HH_
    00019 # define VCSN_AUTOMATA_IMPLEMENTATION_BMIG_GRAPHCONTAINER_HH_
    00020
    00021 # include <vaucanson/misc/hash.hh>
    00022 # include <vaucanson/automata/implementation/bmig/edge_value.hh>
    00023 # include <boost/multi_index_container.hpp>
    00024 # include <boost/multi_index/member.hpp>
    00025 # include <boost/multi_index/ordered_index.hpp>
    00026 # include <boost/multi_index/hashed_index.hpp>
    00027 # include <boost/functional/hash/hash.hpp>
    00028 # include <boost/multi_index/sequenced_index.hpp>
    00029 # include <boost/tuple/tuple.hpp>
    00030 # include <boost/multi_index/composite_key.hpp>
    00031
    00032 namespace vcsn
    00033 {
    00034   namespace bmig
    00035   {
    00036     using ::boost::multi_index_container;
    00037     using ::boost::multi_index::hashed_non_unique;
    00038     using ::boost::multi_index::indexed_by;
    00039     using ::boost::multi_index::composite_key;
    00040     using ::boost::multi_index::hashed_non_unique;
    00041     using ::boost::multi_index::tag;
    00042     using ::boost::multi_index::member;
    00043     using ::boost::multi_index::index_iterator;
    00044     using ::boost::multi_index::get;
    00045     using ::boost::multi_index::project;
    00046     using ::boost::multi_index::composite_key_hash;
    00047
    00048     /*---------------------------------------------------------\
    00049       | Declaring the Boost multi_index used to store the graph. |
    00050       `---------------------------------------------------------*/
    00051
    00052     // Empty structure to name the different keys.
    00053     struct succ {};
    00054     struct pred {};
    00055     struct src {};
    00056     struct dst {};
    00057
    00058     // Composite key (source, label)
    00059     template<typename State, typename HLabel, typename EdgeValue>
    00060     struct SuccessorKey : composite_key <
    00061       EdgeValue,
    00062       BOOST_MULTI_INDEX_MEMBER(EdgeValue, State, from_),
    00063       BOOST_MULTI_INDEX_MEMBER(EdgeValue, HLabel, label_)
    00064     > {};
    00065
    00066     // Composite key (target, label)
    00067     template<typename State, typename HLabel, typename EdgeValue>
    00068     struct PredecessorKey : composite_key <
    00069       EdgeValue,
    00070       BOOST_MULTI_INDEX_MEMBER(EdgeValue, State, to_),
    00071       BOOST_MULTI_INDEX_MEMBER(EdgeValue, HLabel, label_)
    00072     > {};
    00073
    00074     // Use composite keys in hash tables.
    00075     template<typename State, typename HLabel, typename EdgeValue>
    00076     struct SourceAndLabel : public hashed_non_unique <
    00077       tag<succ>,
    00078       SuccessorKey<State, HLabel, EdgeValue>,
    00079       composite_key_hash<
    00080         vcsn::misc::hash_state_handler,
    00081         vcsn::misc::hash_label<HLabel>
    00082         //vcsn::misc::hash_handler<HLabel>
    00083       >
    00084     > {};
    00085
    00086     template<typename State, typename HLabel, typename EdgeValue>
    00087     struct DestinationAndLabel : public hashed_non_unique <
    00088       tag<pred>,
    00089       PredecessorKey<State, HLabel, EdgeValue>,
    00090       composite_key_hash<
    00091         vcsn::misc::hash_state_handler,
    00092         vcsn::misc::hash_label<HLabel>
    00093         //vcsn::misc::hash_handler<HLabel>
    00094       >
    00095     > {};
    00096
    00097
    00098     // Single key (source)
    00099     template<typename State, typename EdgeValue>
    00100     struct Source : public hashed_non_unique <
    00101       tag<src>,
    00102       BOOST_MULTI_INDEX_MEMBER(EdgeValue, State, from_),
    00103       vcsn::misc::hash_state_handler
    00104     > {};
    00105
    00106
    00107     // Single key (target)
    00108     template<typename State, typename EdgeValue>
    00109     struct Destination : public hashed_non_unique <
    00110       tag<dst>,
    00111       BOOST_MULTI_INDEX_MEMBER(EdgeValue, State, to_),
    00112       vcsn::misc::hash_state_handler
    00113     > {};
    00114
    00115
    00129     template<typename State, typename HLabel, typename EdgeValue>
    00130     struct GraphContainer
    00131       : public multi_index_container
    00132     <
    00133       EdgeValue,
    00134       indexed_by
    00135       <
    00136         SourceAndLabel<State, HLabel, EdgeValue>,
    00137         DestinationAndLabel<State, HLabel, EdgeValue>,
    00138         Source<State, EdgeValue>,
    00139         Destination<State, EdgeValue>
    00140       >
    00141     > {};
    00142
    00143   } // bmig
    00144 } // vcsn
    00145
    00146 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_BMIG_GRAPHCONTAINER_HH_
    00147