bitunion.hh (10289:4593282280e4) bitunion.hh (10640:edbc52a43cd8)
1/*
2 * Copyright (c) 2007-2008 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 86 unchanged lines hidden (view full) ---

95 }
96
97 uint64_t
98 operator=(const uint64_t _data)
99 {
100 this->setBits(first, last, _data);
101 return _data;
102 }
1/*
2 * Copyright (c) 2007-2008 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 86 unchanged lines hidden (view full) ---

95 }
96
97 uint64_t
98 operator=(const uint64_t _data)
99 {
100 this->setBits(first, last, _data);
101 return _data;
102 }
103
104 uint64_t
105 operator=(Bitfield<first, last> const & other)
106 {
107 return *this = (uint64_t)other;
108 }
103 };
104
105 //A class which specializes the above so that it can only be read
106 //from. This is accomplished explicitly making sure the assignment
107 //operator is blocked. The conversion operator is carried through
108 //inheritance. This will unfortunately need to be copied into each
109 //bitfield type due to limitations with how templates work
110 template<int first, int last=first>
111 class BitfieldRO : public Bitfield<first, last>
112 {
113 private:
114 uint64_t
115 operator=(const uint64_t _data);
109 };
110
111 //A class which specializes the above so that it can only be read
112 //from. This is accomplished explicitly making sure the assignment
113 //operator is blocked. The conversion operator is carried through
114 //inheritance. This will unfortunately need to be copied into each
115 //bitfield type due to limitations with how templates work
116 template<int first, int last=first>
117 class BitfieldRO : public Bitfield<first, last>
118 {
119 private:
120 uint64_t
121 operator=(const uint64_t _data);
122
123 uint64_t
124 operator=(const Bitfield<first, last>& other);
116 };
117
118 //Similar to the above, but only allows writing.
119 template<int first, int last=first>
120 class BitfieldWO : public Bitfield<first, last>
121 {
122 private:
123 operator const uint64_t () const;

--- 21 unchanged lines hidden (view full) ---

145 }
146
147 int64_t
148 operator=(const int64_t _data)
149 {
150 this->setBits(first, last, _data);
151 return _data;
152 }
125 };
126
127 //Similar to the above, but only allows writing.
128 template<int first, int last=first>
129 class BitfieldWO : public Bitfield<first, last>
130 {
131 private:
132 operator const uint64_t () const;

--- 21 unchanged lines hidden (view full) ---

154 }
155
156 int64_t
157 operator=(const int64_t _data)
158 {
159 this->setBits(first, last, _data);
160 return _data;
161 }
162
163 int64_t
164 operator=(SignedBitfield<first, last> const & other)
165 {
166 return *this = (int64_t)other;
167 }
153 };
154
155 //A class which specializes the above so that it can only be read
156 //from. This is accomplished explicitly making sure the assignment
157 //operator is blocked. The conversion operator is carried through
158 //inheritance. This will unfortunately need to be copied into each
159 //bitfield type due to limitations with how templates work
160 template<int first, int last=first>
161 class SignedBitfieldRO : public SignedBitfield<first, last>
162 {
163 private:
164 int64_t
165 operator=(const int64_t _data);
168 };
169
170 //A class which specializes the above so that it can only be read
171 //from. This is accomplished explicitly making sure the assignment
172 //operator is blocked. The conversion operator is carried through
173 //inheritance. This will unfortunately need to be copied into each
174 //bitfield type due to limitations with how templates work
175 template<int first, int last=first>
176 class SignedBitfieldRO : public SignedBitfield<first, last>
177 {
178 private:
179 int64_t
180 operator=(const int64_t _data);
181
182 int64_t
183 operator=(const SignedBitfield<first, last>& other);
166 };
167
168 //Similar to the above, but only allows writing.
169 template<int first, int last=first>
170 class SignedBitfieldWO : public SignedBitfield<first, last>
171 {
172 private:
173 operator const int64_t () const;
174
175 public:
184 };
185
186 //Similar to the above, but only allows writing.
187 template<int first, int last=first>
188 class SignedBitfieldWO : public SignedBitfield<first, last>
189 {
190 private:
191 operator const int64_t () const;
192
193 public:
176 int64_t operator=(const int64_t _data)
177 {
178 *((SignedBitfield<first, last> *)this) = _data;
179 return _data;
180 }
194 using SignedBitfield<first, last>::operator=;
181 };
182 };
183
184 template<class Type>
185 class BitfieldTypes : public RegularBitfieldTypes<Type>,
186 public SignedBitfieldTypes<Type>
187 {};
188

--- 21 unchanged lines hidden (view full) ---

210
211 Type
212 operator=(Type const & _data)
213 {
214 Base::__data = _data;
215 return _data;
216 }
217
195 };
196 };
197
198 template<class Type>
199 class BitfieldTypes : public RegularBitfieldTypes<Type>,
200 public SignedBitfieldTypes<Type>
201 {};
202

--- 21 unchanged lines hidden (view full) ---

224
225 Type
226 operator=(Type const & _data)
227 {
228 Base::__data = _data;
229 return _data;
230 }
231
232 Type
233 operator=(BitUnionOperators const & other)
234 {
235 Base::__data = other;
236 return Base::__data;
237 }
238
218 bool
219 operator<(Base const & base) const
220 {
221 return Base::__data < base.__data;
222 }
223
224 bool
225 operator==(Base const & base) const

--- 87 unchanged lines hidden ---
239 bool
240 operator<(Base const & base) const
241 {
242 return Base::__data < base.__data;
243 }
244
245 bool
246 operator==(Base const & base) const

--- 87 unchanged lines hidden ---