Chris@16
|
1 /*-----------------------------------------------------------------------------+
|
Chris@16
|
2 Copyright (c) 2010-2010: Joachim Faulhaber
|
Chris@16
|
3 +------------------------------------------------------------------------------+
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
5 (See accompanying file LICENCE.txt or copy at
|
Chris@16
|
6 http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 +-----------------------------------------------------------------------------*/
|
Chris@16
|
8 #ifndef BOOST_ICL_INTERVAL_BOUNDS_HPP_JOFA_100330
|
Chris@16
|
9 #define BOOST_ICL_INTERVAL_BOUNDS_HPP_JOFA_100330
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
12 #include <boost/icl/detail/design_config.hpp>
|
Chris@16
|
13
|
Chris@16
|
14 namespace boost{namespace icl
|
Chris@16
|
15 {
|
Chris@16
|
16
|
Chris@16
|
17 typedef unsigned char bound_type;
|
Chris@16
|
18
|
Chris@16
|
19 class interval_bounds
|
Chris@16
|
20 {
|
Chris@16
|
21 public:
|
Chris@16
|
22 BOOST_STATIC_CONSTANT(bound_type, static_open = 0);
|
Chris@16
|
23 BOOST_STATIC_CONSTANT(bound_type, static_left_open = 1);
|
Chris@16
|
24 BOOST_STATIC_CONSTANT(bound_type, static_right_open = 2);
|
Chris@16
|
25 BOOST_STATIC_CONSTANT(bound_type, static_closed = 3);
|
Chris@16
|
26 BOOST_STATIC_CONSTANT(bound_type, dynamic = 4);
|
Chris@16
|
27 BOOST_STATIC_CONSTANT(bound_type, undefined = 5);
|
Chris@16
|
28
|
Chris@16
|
29 BOOST_STATIC_CONSTANT(bound_type, _open = 0);
|
Chris@16
|
30 BOOST_STATIC_CONSTANT(bound_type, _left_open = 1);
|
Chris@16
|
31 BOOST_STATIC_CONSTANT(bound_type, _right_open = 2);
|
Chris@16
|
32 BOOST_STATIC_CONSTANT(bound_type, _closed = 3);
|
Chris@16
|
33
|
Chris@16
|
34 BOOST_STATIC_CONSTANT(bound_type, _right = 1);
|
Chris@16
|
35 BOOST_STATIC_CONSTANT(bound_type, _left = 2);
|
Chris@16
|
36 BOOST_STATIC_CONSTANT(bound_type, _all = 3);
|
Chris@16
|
37
|
Chris@16
|
38 public:
|
Chris@16
|
39 interval_bounds():_bits(){}
|
Chris@16
|
40 explicit interval_bounds(bound_type bounds): _bits(bounds){}
|
Chris@16
|
41 interval_bounds all ()const { return interval_bounds(_bits & _all ); }
|
Chris@16
|
42 interval_bounds left ()const { return interval_bounds(_bits & _left ); }
|
Chris@16
|
43 interval_bounds right()const { return interval_bounds(_bits & _right); }
|
Chris@16
|
44 interval_bounds reverse_left ()const { return interval_bounds((~_bits>>1) & _right); }
|
Chris@16
|
45 interval_bounds reverse_right()const { return interval_bounds((~_bits<<1) & _left ); }
|
Chris@16
|
46
|
Chris@16
|
47 bound_type bits()const{ return _bits; }
|
Chris@16
|
48
|
Chris@16
|
49 static interval_bounds open() { return interval_bounds(_open); }
|
Chris@16
|
50 static interval_bounds left_open() { return interval_bounds(_left_open); }
|
Chris@16
|
51 static interval_bounds right_open(){ return interval_bounds(_right_open);}
|
Chris@16
|
52 static interval_bounds closed() { return interval_bounds(_closed); }
|
Chris@16
|
53
|
Chris@16
|
54 public:
|
Chris@16
|
55 bound_type _bits;
|
Chris@16
|
56 };
|
Chris@16
|
57
|
Chris@16
|
58
|
Chris@16
|
59 template<class DomainT>
|
Chris@16
|
60 class bounded_value
|
Chris@16
|
61 {
|
Chris@16
|
62 public:
|
Chris@16
|
63 typedef DomainT domain_type;
|
Chris@16
|
64 typedef bounded_value<DomainT> type;
|
Chris@16
|
65 public:
|
Chris@16
|
66 bounded_value(const domain_type& value, interval_bounds bound)
|
Chris@16
|
67 : _value(value), _bound(bound) {}
|
Chris@16
|
68
|
Chris@16
|
69 domain_type value()const { return _value; }
|
Chris@16
|
70 interval_bounds bound()const { return _bound; }
|
Chris@16
|
71
|
Chris@16
|
72 private:
|
Chris@16
|
73 domain_type _value;
|
Chris@16
|
74 interval_bounds _bound;
|
Chris@16
|
75 };
|
Chris@16
|
76
|
Chris@16
|
77 }} // namespace icl boost
|
Chris@16
|
78
|
Chris@16
|
79 #endif
|
Chris@16
|
80
|