00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef UINT64_H 00011 #define UINT64_H 00012 00013 #include "AppConfig.h" 00014 #include "DataVariantValidator.h" 00015 00016 #include <vector> 00017 00018 /** 00019 * A unsigned 64-bit value. This class exists because there is no 00020 * single primitive 64-bit type available in all of the C++ compilers 00021 * that can effectively be serialized/deserialized across 00022 * multiple platforms. This class does not provide a set() function and 00023 * that is by design. 00024 */ 00025 class UInt64 00026 { 00027 public: 00028 /** 00029 * Construct a default unsigned 64-bit value. The value returned from get() will be undefined. 00030 * This constructor shouldn't normally be used, you should use the constructor that 00031 * takes an initial value. This constructor is provided because in order to allow 00032 * this type inside a DataVariant, a default constructor is required. 00033 */ 00034 UInt64() {} 00035 00036 /** 00037 * Construct a unsigned 64-bit object with the given value. 00038 * 00039 * @param value 00040 * The unsigned 64-bit value that this object should wrap. 00041 */ 00042 explicit UInt64(uint64_t value) : mValue(value) {} 00043 00044 /** 00045 * Assignment operator. 00046 * 00047 * @param right 00048 * The right hand of the assignment. 00049 * 00050 * @return A reference to *this, which has been changed to have a copy of the contents of right 00051 */ 00052 BROKEN_INLINE_HINT UInt64& operator=(const UInt64& right) 00053 { 00054 if (this != &right) 00055 { 00056 mValue = right.mValue; 00057 } 00058 return *this; 00059 } 00060 00061 /** 00062 * Compares two UInt64 objects. 00063 * 00064 * @param right 00065 * The object to compare with. 00066 * 00067 * @return Returns true if both UInt64 objects wrap the same unsigned 64-bit integer value. 00068 */ 00069 bool operator==(const UInt64& right) const 00070 { 00071 return mValue == right.mValue; 00072 } 00073 00074 /** 00075 * Access the unsigned 64-bit integer value. 00076 * This class does not provide a set() function and 00077 * that is by design. You must use the UInt64 constructor to set a value into this object. 00078 * 00079 * @returns Returns the wrapped unsigned 64-bit integer value. 00080 */ 00081 uint64_t get() const 00082 { 00083 return mValue; 00084 } 00085 00086 /** 00087 * Access the unsigned 64-bit integer value. 00088 * 00089 * @return Returns the wrapped unsigned 64-bit integer value. 00090 */ 00091 operator uint64_t() const 00092 { 00093 return mValue; 00094 } 00095 00096 private: 00097 uint64_t mValue; 00098 }; 00099 00100 /** 00101 * \cond INTERNAL 00102 * These template specializations are required to allow these types to be put into a DataVariant. 00103 */ 00104 template <> class VariantTypeValidator<UInt64> {}; 00105 template <> class VariantTypeValidator<std::vector<UInt64> > {}; 00106 /// \endcond 00107 00108 #endif