Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ShBitSet.hpp

00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00027 #ifndef SHBITSET_HPP 00028 #define SHBITSET_HPP 00029 00030 #include <cstddef> 00031 #include <iosfwd> 00032 #include "ShDllExport.hpp" 00033 00034 namespace SH { 00035 00036 /* A reference to a single bit in a set. 00037 * @see ShBitSet 00038 */ 00039 class 00040 SH_DLLEXPORT ShBitRef { 00041 public: 00042 operator bool() const; 00043 ShBitRef& operator=(bool b); 00044 00045 private: 00046 friend class ShBitSet; 00047 00048 ShBitRef(unsigned int* byte, unsigned int mask); 00049 00050 unsigned int* m_byte; 00051 unsigned int m_mask; 00052 00053 ShBitRef(const ShBitRef& other); 00054 ShBitRef& operator=(const ShBitRef& other); 00055 }; 00056 00062 class 00063 SH_DLLEXPORT ShBitSet { 00064 public: 00069 ShBitSet(); 00070 explicit ShBitSet(std::size_t size); 00071 ShBitSet(const ShBitSet& other); 00072 00073 ~ShBitSet(); 00074 00075 ShBitSet& operator=(const ShBitSet& other); 00076 ShBitSet& operator&=(const ShBitSet& other); 00077 ShBitSet& operator|=(const ShBitSet& other); 00078 ShBitSet& operator^=(const ShBitSet& other); 00079 00080 ShBitSet operator&(const ShBitSet& other) const; 00081 ShBitSet operator|(const ShBitSet& other) const; 00082 ShBitSet operator^(const ShBitSet& other) const; 00083 00084 ShBitSet operator~() const; 00085 00086 bool operator==(const ShBitSet& other) const; 00087 bool operator!=(const ShBitSet& other) const; 00088 00089 // Return true iff all entries are 1 00090 bool full() const; 00091 // Return true iff all entries are 0 00092 bool empty() const; 00093 00094 std::size_t size() const; 00095 00096 bool operator[](std::size_t i) const; 00097 ShBitRef operator[](std::size_t i); 00098 00099 private: 00100 std::size_t m_size; 00101 unsigned int* m_data; 00102 }; 00103 00104 SH_DLLEXPORT 00105 std::ostream& operator<<(std::ostream& out, const ShBitSet& bitset); 00106 00107 } 00108 00109 #endif

Generated on Mon Oct 18 14:17:38 2004 for Sh by doxygen 1.3.7