00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef GRID_UUID_HPP_INCLUDED
00011 #define GRID_UUID_HPP_INCLUDED
00012
00013 #include <iostream>
00014 #include <string>
00015 #include <functional>
00016
00017 #include <boost/uuid/uuid.hpp>
00018
00019 #include <gridgain/gridhasheableobject.hpp>
00020
00024 class GRIDGAIN_API GridClientUuid: public GridClientHasheableObject {
00025 class Impl {
00026 public:
00028 boost::uuids::uuid uuid_;
00029 };
00030 public:
00034 GridClientUuid();
00035
00041 GridClientUuid(const char* str);
00042
00048 GridClientUuid(const std::string& str);
00049
00055 GridClientUuid(const GridClientUuid& other);
00056
00063 static GridClientUuid fromBytes(const std::string& bytes);
00064
00070 static GridClientUuid randomUuid();
00071
00078 GridClientUuid& operator=(const GridClientUuid& rhs);
00079
00081 virtual ~GridClientUuid();
00082
00089 bool operator <(const GridClientUuid& other) const;
00090
00097 bool operator ==(const GridClientUuid& other) const;
00098
00104 virtual int32_t hashCode() const;
00105
00111 const std::string uuid() const;
00112
00118 int64_t leastSignificantBits() const;
00119
00125 int64_t mostSignificantBits() const;
00126
00135 virtual void convertToBytes(std::vector<int8_t>& bytes) const;
00136
00144 void rawBytes(std::vector<int8_t>& bytes) const;
00145 private:
00146 Impl pimpl;
00147
00154 friend std::ostream& operator<<(std::ostream &out, const GridClientUuid& u);
00155 };
00156
00157 inline std::ostream& operator<<(std::ostream &out, const GridClientUuid& u) {
00158 return out << u.uuid();
00159 }
00160
00161 namespace std {
00162
00164 #ifdef _MSC_VER
00165 template<> inline
00166 size_t hash<GridClientUuid>::operator()(const GridClientUuid& u) const {
00167 return u.hashCode();
00168 }
00169 #else
00170 template<> struct hash<GridClientUuid> {
00171 size_t operator()(GridClientUuid u) const {
00172 return u.hashCode();
00173 }
00174 };
00175 #endif
00176
00177 }
00178
00179 #endif