weighted_atom_iterator.h
Go to the documentation of this file.
00001 // Copyright (c) 2009-2010  INRIA Sophia-Antipolis (France).
00002 // All rights reserved.
00003 //
00004 //This file is part of ESBTL.
00005 //
00006 //ESBTL is free software: you can redistribute it and/or modify
00007 //it under the terms of the GNU General Public License as published by
00008 //the Free Software Foundation, either version 3 of the License, or
00009 //(at your option) any later version.
00010 //
00011 //ESBTL is distributed in the hope that it will be useful,
00012 //but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //GNU General Public License for more details.
00015 //
00016 //You should have received a copy of the GNU General Public License
00017 //along with ESBTL.  If not, see <http://www.gnu.org/licenses/>.
00018 //
00019 //
00020 //Additional permission under GNU GPL version 3 section 7
00021 //
00022 //If you modify this Library, or any covered work, by linking or
00023 //combining it with CGAL (or a modified version of that library), the
00024 //licensors of this Library grant you additional permission to convey
00025 //the resulting work. Corresponding Source for a non-source form of
00026 //such a combination shall include the source code for the parts of CGAL
00027 //used as well as that of the covered work. 
00028 //
00029 //
00030 //
00031 // Author(s)     :  Sébastien Loriot
00032 
00033 
00034 
00035 #ifndef WEIGHTED_ATOM_ITERATOR_H
00036 #define WEIGHTED_ATOM_ITERATOR_H
00037 
00038 #include <ESBTL/iterators.h>
00039 
00040 //this may be redundant with boost::transform_iterator. Again the default constructor of the 
00041 //functor is not sufficient for use
00042 
00043 namespace ESBTL{
00044   
00045 //iterator over all atoms of the model and create weighted atoms
00057 template <class Model,class Weighted_atom,class Weight_functor>
00058 class Weighted_atom_iterator:
00059 public boost::iterator_facade<
00060     Weighted_atom_iterator<Model,Weighted_atom,Weight_functor>,
00061     Weighted_atom,
00062     boost::forward_traversal_tag,
00063     Weighted_atom >
00064 {
00065 private:
00066   typedef typename Model::System::Atom   Atom;
00067 
00068 public:
00069 
00075   template<class Functor_parameters>
00076   Weighted_atom_iterator(typename Model::Atoms_const_iterator it,Functor_parameters params):atom_iterator(it),weight(params){}
00077 
00078 private:
00079   friend class boost::iterator_core_access;
00080 
00081   void increment(){
00082     ++atom_iterator;
00083   }
00084     
00085   bool equal(Weighted_atom_iterator const& other) const{
00086     return atom_iterator==other.atom_iterator;
00087   }
00088   
00089   Weighted_atom dereference() const {
00090     return Weighted_atom(*atom_iterator,weight(*atom_iterator));
00091   }
00092     
00093 //data members
00094   typename Model::Atoms_const_iterator atom_iterator;
00095   Weight_functor weight;
00096 };  
00097   
00098 }//namespace ESBTL
00099 
00100 #endif //WEIGHTED_ATOM_ITERATOR_H