chemically_typed_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) 2006, 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 
00023 
00024 #ifndef BTK_CONCEPTS_CHEMICALLY_TYPED_CONCEPT_HPP
00025 #define BTK_CONCEPTS_CHEMICALLY_TYPED_CONCEPT_HPP
00026 
00147 
00148 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00149 
00150 #include <string>
00151 #include <boost/concept_check.hpp>
00152 #include <btk/core/concepts/type_system_concept.hpp>
00153 #include <btk/core/concepts/type_id_concept.hpp>
00154 
00155 namespace BTK {
00156 namespace CONCEPTS {
00157 
00158 template <typename T>
00159 struct StrictlyChemicallyTypedConcept
00160 {
00161   typedef typename T::chemical_type_system ts_t;
00162   typedef typename T::dictionary dict_t;
00163   typedef typename T::id_type id_t;
00164   
00165   void constraints() {
00166     boost::function_requires<TypeSystemConcept<ts_t> >();
00167     boost::function_requires<TypeIDConcept<id_t> >();
00168 
00169     const_constraints(obj);
00170   }
00171 
00172   void const_constraints(T const & t) {
00173     id = obj.type();
00174     name = obj.name();
00175     ts_t const & ctsr = obj.get_chemical_type_system();
00176     dict_t const & dr = obj.get_dictionary();
00177 
00178     boost::ignore_unused_variable_warning(ctsr);
00179     boost::ignore_unused_variable_warning(dr);
00180   }
00181 
00182   T obj;
00183   id_t id;
00184   std::string name;
00185 };
00186 
00187 } // namespace CONCEPTS
00188 } // namespace BTK
00189 
00190 #endif // DOXYGEN_SHOULD_SKIP_THIS
00191 
00288 
00289 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00290 
00291 namespace BTK {
00292 namespace CONCEPTS {
00293 
00294 template <typename T>
00295 struct ChemicallyTypedConcept
00296 {
00297   typedef typename T::chemical_type_system ts_t;
00298   typedef typename T::dictionary dict_t;
00299   typedef typename T::id_type id_t;
00300 
00301   void constraints() {
00302     boost::function_requires<StrictlyChemicallyTypedConcept<T> >();
00303  
00304     dict_t & d = obj.get_dictionary();
00305     ts_t & t = obj.get_chemical_type_system();
00306 
00307     obj.set_type(id);
00308     obj.set_chemical_type_system(cts);
00309 
00310     boost::ignore_unused_variable_warning(d);
00311     boost::ignore_unused_variable_warning(t);
00312   }
00313 
00314   T obj;
00315   id_t id;
00316   ts_t cts;
00317 };
00318 
00319 } // namespace CONCEPTS
00320 } // namespace BTK
00321 
00322 #endif // DOXYGEN_SHOULD_SKIP_THIS
00323 
00324 #endif // BTK_CONCEPTS_CHEMICALLY_TYPED_CONCEPT_HPP 

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