Chris@16: /*-----------------------------------------------------------------------------+ Chris@16: Copyright (c) 2010-2010: Joachim Faulhaber Chris@16: +------------------------------------------------------------------------------+ Chris@16: Distributed under the Boost Software License, Version 1.0. Chris@16: (See accompanying file LICENCE.txt or copy at Chris@16: http://www.boost.org/LICENSE_1_0.txt) Chris@16: +-----------------------------------------------------------------------------*/ Chris@16: #ifndef BOOST_ICL_INTERVAL_BOUNDS_HPP_JOFA_100330 Chris@16: #define BOOST_ICL_INTERVAL_BOUNDS_HPP_JOFA_100330 Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost{namespace icl Chris@16: { Chris@16: Chris@16: typedef unsigned char bound_type; Chris@16: Chris@16: class interval_bounds Chris@16: { Chris@16: public: Chris@16: BOOST_STATIC_CONSTANT(bound_type, static_open = 0); Chris@16: BOOST_STATIC_CONSTANT(bound_type, static_left_open = 1); Chris@16: BOOST_STATIC_CONSTANT(bound_type, static_right_open = 2); Chris@16: BOOST_STATIC_CONSTANT(bound_type, static_closed = 3); Chris@16: BOOST_STATIC_CONSTANT(bound_type, dynamic = 4); Chris@16: BOOST_STATIC_CONSTANT(bound_type, undefined = 5); Chris@16: Chris@16: BOOST_STATIC_CONSTANT(bound_type, _open = 0); Chris@16: BOOST_STATIC_CONSTANT(bound_type, _left_open = 1); Chris@16: BOOST_STATIC_CONSTANT(bound_type, _right_open = 2); Chris@16: BOOST_STATIC_CONSTANT(bound_type, _closed = 3); Chris@16: Chris@16: BOOST_STATIC_CONSTANT(bound_type, _right = 1); Chris@16: BOOST_STATIC_CONSTANT(bound_type, _left = 2); Chris@16: BOOST_STATIC_CONSTANT(bound_type, _all = 3); Chris@16: Chris@16: public: Chris@16: interval_bounds():_bits(){} Chris@16: explicit interval_bounds(bound_type bounds): _bits(bounds){} Chris@16: interval_bounds all ()const { return interval_bounds(_bits & _all ); } Chris@16: interval_bounds left ()const { return interval_bounds(_bits & _left ); } Chris@16: interval_bounds right()const { return interval_bounds(_bits & _right); } Chris@16: interval_bounds reverse_left ()const { return interval_bounds((~_bits>>1) & _right); } Chris@16: interval_bounds reverse_right()const { return interval_bounds((~_bits<<1) & _left ); } Chris@16: Chris@16: bound_type bits()const{ return _bits; } Chris@16: Chris@16: static interval_bounds open() { return interval_bounds(_open); } Chris@16: static interval_bounds left_open() { return interval_bounds(_left_open); } Chris@16: static interval_bounds right_open(){ return interval_bounds(_right_open);} Chris@16: static interval_bounds closed() { return interval_bounds(_closed); } Chris@16: Chris@16: public: Chris@16: bound_type _bits; Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: class bounded_value Chris@16: { Chris@16: public: Chris@16: typedef DomainT domain_type; Chris@16: typedef bounded_value type; Chris@16: public: Chris@16: bounded_value(const domain_type& value, interval_bounds bound) Chris@16: : _value(value), _bound(bound) {} Chris@16: Chris@16: domain_type value()const { return _value; } Chris@16: interval_bounds bound()const { return _bound; } Chris@16: Chris@16: private: Chris@16: domain_type _value; Chris@16: interval_bounds _bound; Chris@16: }; Chris@16: Chris@16: }} // namespace icl boost Chris@16: Chris@16: #endif Chris@16: