bmig_support.hh

00001 // boost_support.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 #ifndef VCSN_AUTOMATA_IMPLEMENTATION_BMIG_BMIG_SUPPORT_HH
00018 # define VCSN_AUTOMATA_IMPLEMENTATION_BMIG_BMIG_SUPPORT_HH
00019 
00020 # include <vaucanson/misc/support.hh>
00021 # include <vaucanson/automata/implementation/bmig/initial_container.hh>
00022 # include <boost/shared_ptr.hpp>
00023 
00024 namespace vcsn
00025 {
00026   namespace misc
00027   {
00028 
00029     template <>
00030     class SupportIterator<std::vector<boost::shared_ptr<std::size_t> > >
00031     {
00032       public:
00033         typedef boost::shared_ptr<std::size_t>              data_type;
00034         typedef vcsn::handler<state_h, data_type>           handler_t;
00035         typedef std::vector<data_type>                      container_t;
00036         typedef container_t::const_iterator                 vector_iterator;
00037         typedef SupportIterator<container_t>                self_t;
00038 
00039         typedef vector_iterator::iterator_category          iterator_category;
00040         typedef vector_iterator::difference_type            difference_type;
00041         typedef data_type                                   value_type;
00042         typedef data_type*                                  pointer;
00043         typedef data_type&                                  reference;
00044 
00045         SupportIterator () {}
00046         SupportIterator (const container_t* c, int i);
00047 
00048         handler_t operator* () const;
00049         self_t&  operator++ ();
00050         self_t&  operator-- ();
00051         self_t   operator++ (int);
00052         bool     operator!= (const SupportIterator&) const;
00053         bool     operator== (const SupportIterator&) const;
00054 
00055       private:
00056         int                 current_;
00057         std::size_t         container_size_;
00058         const container_t*  container_;
00059     };
00060 
00062     template <>
00063     class Support<std::vector<boost::shared_ptr<std::size_t> > >
00064     {
00065       public:
00066         typedef boost::shared_ptr<std::size_t>           value_type;
00067         typedef vcsn::handler<state_h, value_type>       handler_t;
00068         typedef SupportIterator<std::vector<value_type> > iterator;
00069         typedef iterator                                 const_iterator;
00071 
00072         Support (const std::vector<value_type>&);
00073 
00074         const_iterator begin () const;
00075         const_iterator end () const;
00076         unsigned size () const;
00077 
00078         // Find the element associated to \a k.
00079         iterator find (const handler_t& k) const;
00080 
00082         bool empty () const;
00083 
00084         handler_t back () const;
00085       private:
00086         const std::vector<value_type>&  m_;
00087     };
00088 
00089   }
00090 }
00091 
00093 namespace std
00094 {
00095   template <>
00096     struct iterator_traits<vcsn::misc::SupportIterator<std::vector<boost::shared_ptr<std::size_t> > > >
00097     {
00098       typedef input_iterator_tag  iterator_category;
00099       typedef boost::shared_ptr<size_t>   value_type;
00100       typedef int                 difference_type;
00101       typedef int*                pointer;
00102       typedef int&                reference;
00103     };
00104 } // std
00105 
00106 namespace vcsn
00107 {
00108   namespace misc
00109   {
00110 
00111     template <>
00112     class SupportIterator<std::set<boost::shared_ptr<std::size_t> > >
00113     {
00114       public:
00115         typedef boost::shared_ptr<std::size_t>              data_type;
00116         typedef vcsn::handler<state_h, data_type>           handler_t;
00117         typedef std::set<data_type>                         container_t;
00118         typedef container_t::const_iterator                 set_iterator;
00119         typedef SupportIterator<container_t>                self_t;
00120 
00121         typedef set_iterator::iterator_category     iterator_category;
00122         typedef set_iterator::difference_type       difference_type;
00123         typedef data_type                                   value_type;
00124         typedef data_type*                                  pointer;
00125         typedef data_type&                                  reference;
00126 
00127         SupportIterator () {}
00128         SupportIterator (const container_t* c, set_iterator it);
00129 
00130         handler_t operator* () const;
00131         self_t&  operator++ ();
00132         self_t&  operator-- ();
00133         self_t   operator++ (int);
00134         bool     operator!= (const SupportIterator&) const;
00135         bool     operator== (const SupportIterator&) const;
00136 
00137       private:
00138         set_iterator        current_;
00139         std::size_t         container_size_;
00140         const container_t*  container_;
00141     };
00142 
00144     template <>
00145     class Support<std::set<boost::shared_ptr<std::size_t> > >
00146     {
00147       public:
00148         typedef boost::shared_ptr<std::size_t>           value_type;
00149         typedef vcsn::handler<state_h, value_type>       handler_t;
00150         typedef SupportIterator<std::set<value_type> > iterator;
00151         typedef iterator                                 const_iterator;
00153 
00154         Support (const std::set<value_type>&);
00155 
00156         const_iterator begin () const;
00157         const_iterator end () const;
00158         unsigned size () const;
00159 
00160         // Find the element associated to \a k.
00161         iterator find (const handler_t& k) const;
00162 
00164         bool empty () const;
00165 
00166         handler_t back () const;
00167       private:
00168         const std::set<value_type>&     m_;
00169     };
00170 
00171   }
00172 }
00173 
00175 namespace std
00176 {
00177   template <>
00178     struct iterator_traits<vcsn::misc::SupportIterator<std::set<boost::shared_ptr<std::size_t> > > >
00179     {
00180       typedef input_iterator_tag  iterator_category;
00181       typedef boost::shared_ptr<std::size_t>      value_type;
00182       typedef int                 difference_type;
00183       typedef int*                pointer;
00184       typedef int&                reference;
00185     };
00186 } // std
00187 
00188 namespace vcsn
00189 {
00190   namespace misc
00191   {
00192     template <typename U, typename HState>
00193     class SupportIterator<vcsn::bmig::InitialContainer<U, HState> >
00194     {
00195       public:
00196         typedef typename vcsn::bmig::InitialContainer<U, HState>::Type  container_t;
00197         typedef typename container_t::key_type                  key_type;
00198         typedef typename container_t::const_iterator            container_iterator;
00199         typedef SupportIterator<vcsn::bmig::InitialContainer<U, HState> >       self_t;
00200         typedef vcsn::handler<state_h, HState>                  handler_t;
00201         typedef typename container_iterator::iterator_category  iterator_category;
00202         typedef typename container_iterator::difference_type    difference_type;
00203         typedef key_type                                        value_type;
00204         typedef key_type*                                       pointer;
00205         typedef key_type&                                       reference;
00206 
00207         SupportIterator () {}
00208         SupportIterator (const container_t* c, container_iterator);
00209 
00210         handler_t  operator* () const;
00211         self_t&  operator++ ();
00212         self_t&  operator-- ();
00213         self_t   operator++ (int);
00214         bool     operator!= (const SupportIterator&) const;
00215         bool     operator== (const SupportIterator&) const;
00216 
00217 
00218       private:
00219         container_iterator  i_;
00220         container_iterator  next_;
00221         const container_t*  container_;
00222     };
00223 
00224 
00226     template <typename  U, typename HState>
00227     class Support<vcsn::bmig::InitialContainer<U, HState> >
00228     {
00229       public:
00230         typedef typename vcsn::bmig::InitialContainer<U, HState>::Type container_t;
00231         typedef SupportIterator<vcsn::bmig::InitialContainer<U, HState> > iterator;
00232         typedef SupportIterator<vcsn::bmig::InitialContainer<U, HState> > const_iterator;
00233         typedef vcsn::handler<state_h, HState>                          handler_t;
00234 
00235         Support (const container_t&);
00236         Support (const Support&);
00237 
00238         iterator begin () const;
00239         iterator end () const;
00240         unsigned size () const;
00241 
00242         // Find the element associated to \a k.
00243         iterator find (const HState& k) const;
00244 
00246         bool empty () const;
00247 
00248         handler_t back () const;
00249       private:
00250         const container_t&      m_;
00251     };
00252 
00253   }
00254 }
00255 
00257 namespace std
00258 {
00259   template <class T, class U>
00260   struct iterator_traits<vcsn::misc::SupportIterator<std::vector<vcsn::handler<T, U> > > >
00261   {
00262     typedef input_iterator_tag  iterator_category;
00263     typedef U                   value_type;
00264     typedef int                 difference_type;
00265     typedef int*                pointer;
00266     typedef int&                reference;
00267   };
00268 } // std
00269 
00270 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00271 # include <vaucanson/automata/implementation/bmig/bmig_support.hxx>
00272 # endif // VCSN_USE_INTERFACE_ONLY
00273 
00274 #endif // !VCSN_AUTOMATA_IMPLEMENTATION_BMIG_BMIG_SUPPORT_HH
00275 

Generated on Thu Oct 9 20:22:34 2008 for Vaucanson by  doxygen 1.5.1