Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #ifndef MLN_VALUE_BUILTIN_INTEGERS_HH 00027 # define MLN_VALUE_BUILTIN_INTEGERS_HH 00028 00032 00033 # include <mln/value/internal/limits.hh> 00034 00035 # include <mln/value/concept/built_in.hh> 00036 # include <mln/value/concept/integer.hh> 00037 # include <mln/trait/value_.hh> 00038 00039 # include <mln/metal/int.hh> 00040 # include <mln/metal/if.hh> 00041 # include <mln/metal/bool.hh> 00042 00043 00044 namespace mln 00045 { 00046 00047 template <> struct category< unsigned char > { typedef value::Built_In< value::Integer<void> > ret; }; 00048 template <> struct category< signed char > { typedef value::Built_In< value::Integer<void> > ret; }; 00049 template <> struct category< unsigned short > { typedef value::Built_In< value::Integer<void> > ret; }; 00050 template <> struct category< signed short > { typedef value::Built_In< value::Integer<void> > ret; }; 00051 template <> struct category< unsigned int > { typedef value::Built_In< value::Integer<void> > ret; }; 00052 template <> struct category< signed int > { typedef value::Built_In< value::Integer<void> > ret; }; 00053 template <> struct category< unsigned long > { typedef value::Built_In< value::Integer<void> > ret; }; 00054 template <> struct category< signed long > { typedef value::Built_In< value::Integer<void> > ret; }; 00055 00056 00057 namespace trait 00058 { 00059 00060 // FIXME: Move the definitions below elsewhere. 00061 00062 namespace internal 00063 { 00064 00065 template <typename E> 00066 struct value_integer_ 00067 { 00068 private: 00069 enum { n = 8 * sizeof(E) }; 00070 public: 00071 00072 enum { 00073 dim = 1, 00074 nbits = n, 00075 card = mln_value_card_from_(n) 00076 }; 00077 00078 typedef trait::value::nature::integer nature; 00079 typedef trait::value::kind::data kind; 00080 typedef mln_value_quant_from_(card) quant; 00081 00082 static const E min() { return mln::value::internal::limits<E>::min(); } 00083 static const E max() { return mln::value::internal::limits<E>::max(); } 00084 00085 typedef float sum; 00086 }; 00087 00088 } // end of namespace mln::trait::internal 00089 00090 00091 template <> struct value_< unsigned char > 00092 : internal::value_integer_< unsigned char > 00093 { 00094 static const char* name() 00095 { return "unsigned char"; } 00096 }; 00097 00098 template <> struct value_< signed char > 00099 : internal::value_integer_< signed char > 00100 { 00101 static const char* name() 00102 { return "signed char"; } 00103 }; 00104 00105 template <> struct value_< char > 00106 : internal::value_integer_< signed char > 00107 { 00108 static const char* name() 00109 { return "char"; } 00110 }; 00111 00112 template <> struct value_< unsigned short > 00113 : internal::value_integer_< unsigned short > 00114 { 00115 static const char* name() 00116 { return "unsigned short"; } 00117 }; 00118 00119 template <> struct value_< signed short > 00120 : internal::value_integer_< signed short > 00121 { 00122 static const char* name() 00123 { return "signed short"; } 00124 }; 00125 00126 template <> struct value_< unsigned int > 00127 : internal::value_integer_< unsigned int > 00128 { 00129 static const char* name() 00130 { return "unsigned int"; } 00131 }; 00132 00133 template <> struct value_< signed int > 00134 : internal::value_integer_< signed int > 00135 { 00136 static const char* name() 00137 { return "signed int"; } 00138 }; 00139 00140 template <> struct value_< unsigned long > 00141 : internal::value_integer_< unsigned long > 00142 { 00143 static const char* name() 00144 { return "unsigned long"; } 00145 }; 00146 00147 template <> struct value_< signed long > 00148 : internal::value_integer_< signed long > 00149 { 00150 static const char* name() 00151 { return "signed long"; } 00152 }; 00153 00154 } // end of namespace mln::trait 00155 00156 } // end of namespace mln 00157 00158 00159 #endif // ! MLN_VALUE_BUILTIN_INTEGERS_HH