bitfield.hh (4260:cb8a68017b41) | bitfield.hh (4261:0a667162b5fa) |
---|---|
1/* 2 * Copyright (c) 2003-2005 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; --- 157 unchanged lines hidden (view full) --- 166 setBits(int first, int last, uint64_t val) 167 { 168 replaceBits(__data, first, last, val); 169 } 170 }; 171 172 //A class which specializes a given base so that it can only be read 173 //from. This is accomplished by only passing through the conversion | 1/* 2 * Copyright (c) 2003-2005 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; --- 157 unchanged lines hidden (view full) --- 166 setBits(int first, int last, uint64_t val) 167 { 168 replaceBits(__data, first, last, val); 169 } 170 }; 171 172 //A class which specializes a given base so that it can only be read 173 //from. This is accomplished by only passing through the conversion |
174 //operator. | 174 //operator and explicitly making sure the assignment operator is blocked. |
175 template<class Type, class Base> 176 class _BitfieldRO : public Base 177 { | 175 template<class Type, class Base> 176 class _BitfieldRO : public Base 177 { |
178 private: 179 const Type 180 operator=(const Type & _data); 181 |
|
178 public: 179 operator const Type () 180 { 181 return *((Base *)this); 182 } 183 }; 184 185 //Similar to the above, but only allows writing. 186 template<class Type, class Base> 187 class _BitfieldWO : public Base 188 { | 182 public: 183 operator const Type () 184 { 185 return *((Base *)this); 186 } 187 }; 188 189 //Similar to the above, but only allows writing. 190 template<class Type, class Base> 191 class _BitfieldWO : public Base 192 { |
193 private: 194 operator const Type (); 195 |
|
189 public: 190 const Type operator=(const Type & _data) 191 { 192 *((Base *)this) = _data; 193 return _data; 194 } 195 }; 196 --- 158 unchanged lines hidden --- | 196 public: 197 const Type operator=(const Type & _data) 198 { 199 *((Base *)this) = _data; 200 return _data; 201 } 202 }; 203 --- 158 unchanged lines hidden --- |