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 INT64_H 00011 #define INT64_H 00012 00013 #include "AppConfig.h" 00014 #include "DataVariantValidator.h" 00015 00016 #include <vector> 00017 00018 /** 00019 * A signed 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 Int64 00026 { 00027 public: 00028 /** 00029 * Construct a default signed 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 Int64() {} 00035 00036 /** 00037 * Construct a signed 64-bit object with the given value. 00038 * 00039 * @param value 00040 * The signed 64-bit value that this object should wrap. 00041 */ 00042 explicit Int64(int64_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 Int64& operator=(const Int64& right) 00053 { 00054 if (this != &right) 00055 { 00056 mValue = right.mValue; 00057 } 00058 return *this; 00059 } 00060 00061 /** 00062 * Compares two Int64 objects. 00063 * 00064 * @param right 00065 * The object to compare with. 00066 * 00067 * @return Returns true if both Int64 objects wrap the same signed 64-bit integer value. 00068 */ 00069 bool operator==(const Int64& right) const 00070 { 00071 return mValue == right.mValue; 00072 } 00073 00074 /** 00075 * Access the signed 64-bit integer value. 00076 * This class does not provide a set() function and 00077 * that is by design. You must use the Int64 constructor to set a value into this object. 00078 * 00079 * @returns Returns the wrapped signed 64-bit integer value. 00080 */ 00081 int64_t get() const 00082 { 00083 return mValue; 00084 } 00085 00086 /** 00087 * Access the signed 64-bit integer value. 00088 * 00089 * @returns Returns the wrapped signed 64-bit integer value. 00090 */ 00091 operator int64_t() const 00092 { 00093 return mValue; 00094 } 00095 00096 private: 00097 int64_t mValue; 00098 }; 00099 00100 00101 /** 00102 * \cond INTERNAL 00103 * These template specializations are required to allow these types to be put into a DataVariant. 00104 */ 00105 template <> class VariantTypeValidator<Int64> {}; 00106 template <> class VariantTypeValidator<std::vector<Int64> > {}; 00107 /// \endcond 00108 00109 #endif