$extrastylesheet
Olena
User documentation 2.1
An Image Processing Platform
Milena
Getting started
API Reference Manual
All Classes
Examples
Demos
Publications
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
value_.hh
1
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2
//
3
// This file is part of Olena.
4
//
5
// Olena is free software: you can redistribute it and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, version 2 of the License.
8
//
9
// Olena is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
16
//
17
// As a special exception, you may use this file as part of a free
18
// software project without restriction. Specifically, if other files
19
// instantiate templates or use macros or inline functions from this
20
// file, or you compile this file and link it with other files to produce
21
// an executable, this file does not by itself cause the resulting
22
// executable to be covered by the GNU General Public License. This
23
// exception does not however invalidate any other reasons why the
24
// executable file might be covered by the GNU General Public License.
25
26
#ifndef MLN_TRAIT_VALUE__HH
27
# define MLN_TRAIT_VALUE__HH
28
32
33
# include <iostream>
34
# include <string>
35
36
# include <mln/metal/int.hh>
37
# include <mln/metal/math/pow.hh>
38
# include <mln/metal/if.hh>
39
40
# include <mln/trait/value/all.hh>
41
# include <mln/metal/math/pow.hh>
42
# include <mln/core/def/low_quant_nbits.hh>
43
44
45
# define mln_trait_value_nature(V) typename mln::trait::value_< V >::nature
46
# define mln_trait_value_nature_(V) mln::trait::value_< V >::nature
47
# define mln_trait_value_kind(V) typename mln::trait::value_< V >::kind
48
# define mln_trait_value_kind_(V) mln::trait::value_< V >::kind
49
# define mln_trait_value_quant(V) typename mln::trait::value_< V >::quant
50
# define mln_trait_value_quant_(V) mln::trait::value_< V >::quant
51
52
53
# define mln_card(V) mln::trait::value_< V >::card
54
# define mln_dim(V) mln::trait::value_< V >::dim
55
# define mln_epsilon(V) mln::trait::value_< V >::epsilon()
56
# define mln_max(V) mln::trait::value_< V >::max()
57
# define mln_min(V) mln::trait::value_< V >::min()
58
# define mln_nbits(V) mln::trait::value_< V >::nbits
59
60
62
# define mln_trait_value_sum(V) typename mln::trait::value_< V >::sum
63
# define mln_trait_value_sum_(V) mln::trait::value_< V >::sum
64
# define mln_sum(V) mln_trait_value_sum(V)
65
# define mln_sum_(V) mln_trait_value_sum_(V)
66
68
# define mln_trait_value_name(V) mln::trait::value_< V >::name()
69
71
# define mln_value_quant_from_(C) \
72
mlc_if(mln::metal::bool_<( int(C) > int(mlc_pow_int(2, mln::def::low_quant_nbits)) \
73
|| int(C) == 0 \
74
|| int(C) == -1)>, \
75
mln::trait::value::quant::high, \
76
mln::trait::value::quant::low)
77
78
80
//
81
// Technical note:
82
// This macro might seem weird, yet it is NOT. We have to change the value
83
// of N, even when N is less than the low quant threshold, because otherwise
84
// the call to mlc_pow_int would lead to compilation errors.
85
# define mln_value_card_from_(N) \
86
(int(N) <= int(mln::def::low_quant_nbits) \
87
? mlc_pow_int((N <= 16 ? 2 : 1), \
88
(N <= 16 ? N : 1)) \
89
: 0)
90
91
92
93
namespace
mln
94
{
95
96
namespace
trait
97
{
98
99
100
struct
undefined_value_
101
{
102
typedef
undef
nature
;
103
typedef
undef
kind
;
104
typedef
undef
quant
;
105
106
/*
107
* enum {
108
* dim = ?
109
* nbits = ?,
110
* card = ?
111
* };
112
*
113
* static const E min();
114
* static const E max();
115
* static const E epsilon();
116
*/
117
118
typedef
undef
sum
;
119
// FIXME: signed or not, with zero or not, centered or not, etc.
120
};
121
122
123
struct
default_value_
:
undefined_value_
124
{
125
enum
{
126
dim
= 0,
127
nbits
= 0,
128
card
= 0
129
};
130
131
typedef
trait::value::nature::unknown
nature
;
132
typedef
trait::value::kind::data
kind
;
133
typedef
trait::value::quant::high
quant
;
134
135
/*
136
* typedef ? comp_0;
137
* typedef ? comp_1;
138
* ...
139
*/
140
};
141
142
143
template
<
typename
V>
144
struct
value_ :
default_value_
145
{
146
};
147
148
149
}
// end of namespace mln::trait
150
151
}
// end of namespace mln
152
153
154
# include <mln/trait/value/print.hh>
155
156
157
#endif // ! MLN_TRAIT_VALUE__HH
mln
trait
value_.hh
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)