activemq-cpp-3.3.0

src/main/decaf/util/UUID.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _DECAF_UTIL_UUID_H_
00019 #define _DECAF_UTIL_UUID_H_
00020 
00021 #include <decaf/util/Config.h>
00022 #include <decaf/lang/Comparable.h>
00023 #include <decaf/lang/exceptions/UnsupportedOperationException.h>
00024 #include <decaf/lang/exceptions/IllegalArgumentException.h>
00025 #include <apr_uuid.h>
00026 #include <string>
00027 
00028 namespace decaf{
00029 namespace util{
00030 
00066     class DECAF_API UUID : public lang::Comparable<UUID> {
00067     private:
00068 
00069         // APR Uuid Type
00070         apr_uuid_t apr_uuid;
00071 
00072         // Copy of the High part of the data
00073         unsigned long long mostSigBits;
00074 
00075         // Copy of the Low part of the data
00076         unsigned long long leastSigBits;
00077 
00078         // Version indicator, set when a UUID is generated
00079         int uuidVersion;
00080 
00081     public:
00082 
00090         static UUID randomUUID();
00091 
00101         static UUID nameUUIDFromBytes( const std::vector<char>& name );
00102 
00114         static UUID nameUUIDFromBytes( const char* name, std::size_t size );
00115 
00127         static UUID fromString( const std::string& name );
00128 
00129     public:
00130 
00139         UUID( long long mostSigBits, long long leastSigBits );
00140 
00141         virtual ~UUID();
00142 
00147         virtual int compareTo( const UUID& value ) const;
00148 
00157         virtual bool equals( const UUID& value ) const;
00158 
00164         virtual bool operator==( const UUID& value ) const;
00165 
00172         virtual bool operator<( const UUID& value ) const;
00173 
00179         virtual std::string toString() const;
00180 
00184         virtual long long getLeastSignificantBits() const;
00185 
00189         virtual long long getMostSignificantBits() const;
00190 
00206         virtual long long node();
00207 
00221         virtual long long timestamp();
00222 
00236         virtual int clockSequence();
00237 
00251         virtual int variant();
00252 
00266         virtual int version();
00267 
00268     };
00269 
00270 }}
00271 
00272 #endif /*_DECAF_UTIL_UUID_H_*/