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_TRAIT_VALUE__HH 00027 # define MLN_TRAIT_VALUE__HH 00028 00032 00033 # include <iostream> 00034 # include <string> 00035 00036 # include <mln/metal/int.hh> 00037 # include <mln/metal/math/pow.hh> 00038 # include <mln/metal/if.hh> 00039 00040 # include <mln/trait/value/all.hh> 00041 # include <mln/metal/math/pow.hh> 00042 # include <mln/core/def/low_quant_nbits.hh> 00043 00044 00045 # define mln_trait_value_nature(V) typename mln::trait::value_< V >::nature 00046 # define mln_trait_value_nature_(V) mln::trait::value_< V >::nature 00047 # define mln_trait_value_kind(V) typename mln::trait::value_< V >::kind 00048 # define mln_trait_value_kind_(V) mln::trait::value_< V >::kind 00049 # define mln_trait_value_quant(V) typename mln::trait::value_< V >::quant 00050 # define mln_trait_value_quant_(V) mln::trait::value_< V >::quant 00051 00052 00053 # define mln_card(V) mln::trait::value_< V >::card 00054 # define mln_dim(V) mln::trait::value_< V >::dim 00055 # define mln_epsilon(V) mln::trait::value_< V >::epsilon() 00056 # define mln_max(V) mln::trait::value_< V >::max() 00057 # define mln_min(V) mln::trait::value_< V >::min() 00058 # define mln_nbits(V) mln::trait::value_< V >::nbits 00059 00060 00062 # define mln_trait_value_sum(V) typename mln::trait::value_< V >::sum 00063 # define mln_trait_value_sum_(V) mln::trait::value_< V >::sum 00064 # define mln_sum(V) mln_trait_value_sum(V) 00065 # define mln_sum_(V) mln_trait_value_sum_(V) 00066 00068 # define mln_trait_value_name(V) mln::trait::value_< V >::name() 00069 00071 # define mln_value_quant_from_(C) \ 00072 mlc_if(mln::metal::bool_<( int(C) > int(mlc_pow_int(2, mln::def::low_quant_nbits)) \ 00073 || int(C) == 0 \ 00074 || int(C) == -1)>, \ 00075 mln::trait::value::quant::high, \ 00076 mln::trait::value::quant::low) 00077 00078 00080 // 00081 // Technical note: 00082 // This macro might seem weird, yet it is NOT. We have to change the value 00083 // of N, even when N is less than the low quant threshold, because otherwise 00084 // the call to mlc_pow_int would lead to compilation errors. 00085 # define mln_value_card_from_(N) \ 00086 (int(N) <= int(mln::def::low_quant_nbits) \ 00087 ? mlc_pow_int((N <= 16 ? 2 : 1), \ 00088 (N <= 16 ? N : 1)) \ 00089 : 0) 00090 00091 00092 00093 namespace mln 00094 { 00095 00096 namespace trait 00097 { 00098 00099 00100 struct undefined_value_ 00101 { 00102 typedef undef nature; 00103 typedef undef kind; 00104 typedef undef quant; 00105 00106 /* 00107 * enum { 00108 * dim = ? 00109 * nbits = ?, 00110 * card = ? 00111 * }; 00112 * 00113 * static const E min(); 00114 * static const E max(); 00115 * static const E epsilon(); 00116 */ 00117 00118 typedef undef sum; 00119 // FIXME: signed or not, with zero or not, centered or not, etc. 00120 }; 00121 00122 00123 struct default_value_ : undefined_value_ 00124 { 00125 enum { 00126 dim = 0, 00127 nbits = 0, 00128 card = 0 00129 }; 00130 00131 typedef trait::value::nature::unknown nature; 00132 typedef trait::value::kind::data kind; 00133 typedef trait::value::quant::high quant; 00134 00135 /* 00136 * typedef ? comp_0; 00137 * typedef ? comp_1; 00138 * ... 00139 */ 00140 }; 00141 00142 00143 template <typename V> 00144 struct value_ : default_value_ 00145 { 00146 }; 00147 00148 00149 } // end of namespace mln::trait 00150 00151 } // end of namespace mln 00152 00153 00154 # include <mln/trait/value/print.hh> 00155 00156 00157 #endif // ! MLN_TRAIT_VALUE__HH