include/wipal/tool/valued_iterator.hh

00001 /*
00002  * WiPal - A library and a set of tools to manipulate wireless traces.
00003  * Copyright (C) 2007  Universite Pierre et Marie Curie - Paris 6
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00018  * MA  02110-1301  USA
00019  *
00020  * Author: Thomas Claveirole <thomas.claveirole@lip6.fr>
00021  */
00022 #ifndef TOOL_VALUED_ITERATOR_HH_
00023 # define TOOL_VALUED_ITERATOR_HH_
00024 
00025 # include <boost/optional.hpp>
00026 
00027 # include <wipal/tool/iterator.hh>
00028 
00029 namespace tool
00030 {
00031 
00032   /*---------------------.
00033   | Forward declarations |
00034   `---------------------*/
00035 
00036   template <class B>
00037   struct valued_iterator;
00038 
00039 
00040   /*--------------.
00041   | Virtual types |
00042   `--------------*/
00043 
00045   template <class B>
00046   struct types< valued_iterator<B> >
00047   {
00049     typedef undefined_type      value_type;
00050 
00052     typedef undefined_type      iterable_type;
00053   };
00054 
00055   /*-------------.
00056   | Declarations |
00057   `-------------*/
00058 
00077   template <class Bottom>
00078   struct valued_iterator: wp_inherit(public iterator, valued_iterator<Bottom>)
00079   {
00080 
00082 
00083     typedef wp_get_exact(Bottom, valued_iterator<Bottom>)       exact_type;
00084     typedef iterator<exact_type>                                super_type;
00085     typedef wp_type(value_type, exact_type)                     value_type;
00087 
00089 
00090     const value_type&           get() const;
00091     value_type&                 get();
00093 
00095 
00096     const value_type*           get_ptr() const;
00097     value_type*                 get_ptr();
00099 
00100   protected:
00101 
00103     ~valued_iterator();
00104 
00106     typedef typename boost::optional<value_type>        optional_value;
00107 
00109 
00110     const optional_value&       value() const;
00111     optional_value&             value();
00113 
00114   private:
00115 
00117     optional_value              v_;
00118 
00119   };
00120 
00121 } // End of namespace tool.
00122 
00123 # include "valued_iterator.hxx"
00124 
00125 #endif // ! TOOL_VALUED_ITERATOR_HH_

Generated on Wed Jan 16 16:15:14 2008 for wipal by  doxygen 1.5.4