monomer_iterable_concept.hpp

Go to the documentation of this file.
00001 // -*- mode: c++; indent-tabs-mode: nil; -*-
00002 //
00003 //The Biomolecule Toolkit (BTK) is a C++ library for use in the
00004 //modeling, analysis, and design of biological macromolecules.
00005 //Copyright (C) 2004, Tim Robertson <kid50@users.sourceforge.net>
00006 //
00007 //This program is free software; you can redistribute it and/or modify
00008 //it under the terms of the GNU Lesser General Public License as published
00009 //by the Free Software Foundation; either version 2.1 of the License, or (at
00010 //your option) any later version.
00011 //
00012 //This program is distributed in the hope that it will be useful,  but
00013 //WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 //Lesser General Public License for more details.
00016 //
00017 //You should have received a copy of the GNU Lesser General Public License
00018 //along with this program; if not, write to the Free Software Foundation,
00019 //Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 #ifndef BTK_CONCEPTS_MONOMER_ITERABLE_CONCEPT_HPP
00022 #define BTK_CONCEPTS_MONOMER_ITERABLE_CONCEPT_HPP
00023 
00024 #include <boost/concept_check.hpp>
00025 
00026 #include <btk/core/concepts/monomer_iterator_concept.hpp>
00027 
00028 namespace BTK {
00029 namespace CONCEPTS {
00030 
00031 template <typename T>
00032 struct MonomerIterableConcept
00033 {
00034   typedef typename T::size_type st;
00035   typedef typename T::const_monomer_iterator const_monomer_it;
00036   typedef typename T::const_reverse_monomer_iterator const_rev_monomer_it;
00037 
00038   void constraints()
00039   {
00040     boost::function_requires<MonomerIteratorConcept<const_monomer_it> >();
00041     boost::function_requires<MonomerIteratorConcept<const_rev_monomer_it> >();
00042 
00043     const_constraints(obj);
00044   }
00045 
00046   void const_constraints(T const & mc)
00047   {
00048     size = mc.num_monomers();
00049     
00050     cmi = mc.polymer_begin();
00051     cmi = mc.polymer_end();
00052 
00053     crmi = mc.polymer_rbegin();
00054     crmi = mc.polymer_rend();
00055   }
00056 
00057   T obj;
00058   st size;
00059   const_monomer_it cmi;
00060   const_rev_monomer_it crmi;
00061 };
00062 
00063 template <typename T>
00064 struct MutableMonomerIterableConcept
00065 {
00066   typedef typename T::monomer_iterator monomer_it;
00067   typedef typename T::reverse_monomer_iterator rev_monomer_it;
00068 
00069   void constraints()
00070   {
00071     boost::function_requires<MonomerIterableConcept<T> >();
00072     boost::function_requires<MutableMonomerIteratorConcept<monomer_it> >();
00073     boost::function_requires<MutableMonomerIteratorConcept<rev_monomer_it> >();
00074 
00075     mi = mc.polymer_begin();
00076     mi = mc.polymer_end();
00077 
00078     rmi = mc.polymer_rbegin();
00079     rmi = mc.polymer_rend();
00080   }
00081 
00082   T mc;
00083   monomer_it mi;
00084   rev_monomer_it rmi;
00085 };
00086 
00087 } // namespace CONCEPTS
00088 } // namespace BTK
00089 
00090 #endif

Generated on Sun Jul 15 20:46:26 2007 for BTK Core by  doxygen 1.5.1