type_id_traits.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 
00021 #ifndef BTK_UTILITY_TYPE_ID_TRAITS_HPP
00022 #define BTK_UTILITY_TYPE_ID_TRAITS_HPP
00023 
00024 #include <limits>
00025 
00026 namespace BTK {
00027 namespace UTILITY {
00028 
00029 template <typename ID>
00030 struct TypeIDTraits
00031 {
00032   static const bool dynamic;
00033 
00034   static ID first();
00035   static ID last();
00036   static ID unknown();
00037   static ID next(ID id);
00038 };
00039 
00040 template <>
00041 struct TypeIDTraits<int>
00042 {
00043   static const bool dynamic = true;
00044 
00045   static int first() { return 0; }
00046   static int last() { return std::numeric_limits<int>::max()-1; }
00047   static int unknown() { return std::numeric_limits<int>::max(); }
00048 
00049   static int next(int id) { return ++id; }
00050 };
00051 
00052 template <>
00053 struct TypeIDTraits<unsigned>
00054 { 
00055   static const bool dynamic = true;
00056 
00057   static unsigned first() { return std::numeric_limits<unsigned>::min(); }
00058   static unsigned last() { return std::numeric_limits<unsigned>::max()-1; }
00059   static unsigned unknown() { return std::numeric_limits<unsigned>::max(); }
00060 
00061   static unsigned next(unsigned id) { return ++id; }
00062 };
00063 
00064 } // UTILITY
00065 } // BTK
00066 
00067 #endif

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