1/* 2 * Copyright (c) 2008 The Hewlett-Packard Development Company 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; --- 30 unchanged lines hidden (view full) --- 39 40 public: 41 typedef T Type; 42 Flags() : _flags(0) {} 43 Flags(Type flags) : _flags(flags) {} 44 45 operator const Type() const { return _flags; } 46 |
47 template |
48 const Flags<T> & 49 operator=(const Flags<U> &flags) 50 { 51 _flags = flags._flags; 52 return *this; 53 } 54 55 const Flags<T> & 56 operator=(T flags) 57 { 58 _flags = flags; 59 return *this; 60 } |
61 |
62 bool isSet() const { return _flags; } 63 bool isSet(Type flags) const { return (_flags & flags); } 64 bool allSet() const { return !(~_flags); } 65 bool allSet(Type flags) const { return (_flags & flags) == flags; } 66 bool noneSet() const { return _flags == 0; } 67 bool noneSet(Type flags) const { return (_flags & flags) == 0; } 68 void clear() { _flags = 0; } 69 void clear(Type flags) { _flags &= ~flags; } 70 void set(Type flags) { _flags |= flags; } 71 void set(Type f, bool val) { _flags = (_flags & ~f) | (val ? f : 0); } 72 void 73 update(Type flags, Type mask) 74 { 75 _flags = (_flags & ~mask) | (flags & mask); 76 } 77}; 78 79#endif // __BASE_FLAGS_HH__ |