4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief RestrictedInt public header */
31 #ifndef HH_SENF_senf_Utils_RestrictedInt_
32 #define HH_SENF_senf_Utils_RestrictedInt_ 1
36 #include <boost/operators.hpp>
37 #include <senf/Utils/safe_bool.hh>
39 //#include "RestrictedInt.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 // Really ... the correct spelling is 'euclidean' as in the current boost
45 // Versions but older versions only have this spelling so we can' t use
46 // the correct class name ...
48 template <class Base, class Tag>
50 : public boost::ordered_euclidian_ring_operators< RestrictedInt<Base,Tag>,
51 boost::unit_steppable< RestrictedInt<Base,Tag>,
52 boost::shiftable< RestrictedInt<Base,Tag>,
53 boost::bitwise1< RestrictedInt<Base,Tag>,
54 senf::comparable_safe_bool< RestrictedInt<Base,Tag> > > > > >
57 typedef Base base_type;
60 explicit RestrictedInt(Base value) : value_ (value) {}
61 RestrictedInt() : value_ () {}
63 # define BinaryOp(op) \
64 RestrictedInt & operator op ## = (RestrictedInt other) \
65 { value_ op ## = other.value_; return *this; }
66 # define IncDecOp(op) \
67 RestrictedInt & operator op () \
68 { op value_; return *this; }
69 # define PrefixOp(op) \
70 RestrictedInt const operator op () const \
71 { return RestrictedInt(op value_); }
72 # define CompareOp(op) \
73 bool operator op (RestrictedInt other) const \
74 { return value_ op other.value_; }
104 bool boolean_test() const
111 template <class Base, class Tag>
112 std::ostream & operator<<(std::ostream & os, RestrictedInt<Base, Tag> value)
113 { os << value.value(); return os; }
115 template <class Base, class Tag>
116 std::istream & operator>>(std::istream & is, RestrictedInt<Base, Tag> & value)
117 { Base v; is >> v; value = RestrictedInt<Base,Tag>(v); return is; }
121 //-/////////////////////////////////////////////////////////////////////////////////////////////////
122 //#include "RestrictedInt.cci"
123 //#include "RestrictedInt.ct"
124 //#include "RestrictedInt.cti"
131 // comment-column: 40
132 // c-file-style: "senf"
133 // indent-tabs-mode: nil
134 // ispell-local-dictionary: "american"
135 // compile-command: "scons -u test"