tarjan.hh

00001 // Copyright (C) 2004  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016 // Boston, MA 02110-1301, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
00027 
00028 #ifndef OLENA_TOPO_TARJAN_TARJAN_HH
00029 # define OLENA_TOPO_TARJAN_TARJAN_HH
00030 # include <oln/basics.hh>
00031 # include <vector>
00032 // Macros for extract information on tarjan algorithms.
00033 # define oln_tarjan_input_type(T) typename oln::topo::tarjan::tarjan_traits<T >::input_type
00034 # define oln_tarjan_output_type(T) typename oln::topo::tarjan::tarjan_traits<T >::output_type
00035 # define oln_tarjan_attr_type(T) typename oln::topo::tarjan::tarjan_traits<T >::attr_type
00036 
00037 
00038 // # define oln_tarjan_input_type(T) typename oln::topo::tarjan::tarjan_traits<mlc_exact_type(T)>::input_type
00039 // # define oln_tarjan_output_type(T) typename oln::topo::tarjan::tarjan_traits<mlc_exact_type(T)>::output_type
00040 // # define oln_tarjan_attr_type(T) typename oln::topo::tarjan::tarjan_traits<mlc_exact_type(T)>::attr_type
00041 
00042 
00043 namespace oln {
00044 
00045   namespace topo {
00047     namespace tarjan {
00048 
00050       template <typename Exact>
00051       struct tarjan_traits;
00052 
00054       namespace abstract {
00062         template <typename Exact>
00063         struct tarjan: public mlc_hierarchy::any<Exact>
00064         {
00065           typedef oln_tarjan_input_type(Exact)          input_type; 
00066           typedef oln_tarjan_output_type(Exact)         image_out_type; 
00067           typedef oln_value_type(image_out_type)        comp_type; 
00068           typedef oln_point_type(input_type)            point_type; 
00069 
00077           template<class N>
00078           image_out_type
00079           get_compute(const oln::abstract::neighborhood<N> &Ng)
00080           {
00081             mlc_dispatch(get_compute)(Ng);
00082           }
00083 
00090           comp_type ncomps() const
00091           {
00092             mlc_dispatch(ncomps)();
00093           }
00094 
00095         protected:
00102           std::vector<point_type>
00103           get_processing_order()
00104           {
00105             mlc_dispatch(get_processing_order)();
00106           }
00107 
00114           void
00115           mark_set(const point_type &x)
00116           {
00117             mlc_dispatch(mark_set)(x);
00118           }
00119 
00126           void
00127           uni(const point_type& n, const point_type& p)
00128           {
00129             mlc_dispatch(uni)(n, p);
00130           }
00131 
00139           bool is_proc(const point_type &p) const
00140           {
00141             mlc_dispatch(is_proc)(p);
00142           };
00143 
00147           tarjan() {}
00148         };
00149       } // end of namespace abstract
00150     } // end of namespace tarjan
00151   } // end of namespace topo
00152 } // end of namespace oln
00153 
00154 #endif // ! OLENA_TOPO_TARJAN_TARJAN_HH

Generated on Tue Feb 20 20:20:46 2007 for Olena by  doxygen 1.5.1