4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief RestrictedInt public header */
26 #ifndef HH_SENF_senf_Utils_RestrictedInt_
27 #define HH_SENF_senf_Utils_RestrictedInt_ 1
31 #include <boost/operators.hpp>
32 #include <senf/Utils/safe_bool.hh>
34 //#include "RestrictedInt.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
39 // Really ... the correct spelling is 'euclidean' as in the current boost
40 // Versions but older versions only have this spelling so we can' t use
41 // the correct class name ...
43 template <class Base, class Tag>
45 : public boost::ordered_euclidian_ring_operators< RestrictedInt<Base,Tag>,
46 boost::unit_steppable< RestrictedInt<Base,Tag>,
47 boost::shiftable< RestrictedInt<Base,Tag>,
48 boost::bitwise1< RestrictedInt<Base,Tag>,
49 senf::comparable_safe_bool< RestrictedInt<Base,Tag> > > > > >
52 explicit RestrictedInt(Base value) : value_ (value) {}
53 RestrictedInt() : value_ () {}
55 # define BinaryOp(op) \
56 RestrictedInt & operator op ## = (RestrictedInt other) \
57 { value_ op ## = other.value_; return *this; }
58 # define IncDecOp(op) \
59 RestrictedInt & operator op () \
60 { op value_; return *this; }
61 # define PrefixOp(op) \
62 RestrictedInt const operator op () const \
63 { return RestrictedInt(op value_); }
64 # define CompareOp(op) \
65 bool operator op (RestrictedInt other) const \
66 { return value_ op other.value_; }
96 bool boolean_test() const
103 template <class Base, class Tag>
104 std::ostream & operator<<(std::ostream & os, RestrictedInt<Base, Tag> value)
105 { os << value.value(); return os; }
107 template <class Base, class Tag>
108 std::istream & operator>>(std::istream & is, RestrictedInt<Base, Tag> & value)
109 { Base v; is >> v; value = RestrictedInt<Base,Tag>(v); return is; }
113 ///////////////////////////////hh.e////////////////////////////////////////
114 //#include "RestrictedInt.cci"
115 //#include "RestrictedInt.ct"
116 //#include "RestrictedInt.cti"
123 // comment-column: 40
124 // c-file-style: "senf"
125 // indent-tabs-mode: nil
126 // ispell-local-dictionary: "american"
127 // compile-command: "scons -u test"