00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _ATIVEMQ_UTIL_IDGENERATOR_H_
00019 #define _ATIVEMQ_UTIL_IDGENERATOR_H_
00020
00021 #include <activemq/util/Config.h>
00022
00023 #include <string>
00024
00025 namespace activemq {
00026 namespace library {
00027 class ActiveMQCPP;
00028 }
00029 namespace util {
00030
00031 class IdGeneratorKernel;
00032
00033 class AMQCPP_API IdGenerator {
00034 private:
00035
00036 std::string prefix;
00037 mutable std::string seed;
00038 mutable long long sequence;
00039
00040 static IdGeneratorKernel* kernel;
00041
00042 private:
00043
00044 IdGenerator(const IdGenerator&);
00045 IdGenerator& operator=(const IdGenerator&);
00046
00047 public:
00048
00049 IdGenerator();
00050
00051 IdGenerator(const std::string& prefix);
00052
00053 virtual ~IdGenerator();
00054
00055 public:
00056
00060 std::string generateId() const;
00061
00062 public:
00063
00070 static std::string getHostname();
00071
00077 static std::string getSeedFromId(const std::string& id);
00078
00084 static long long getSequenceFromId(const std::string& id);
00085
00096 static int compare(const std::string& id1, const std::string& id2);
00097
00098 private:
00099
00100 static void initialize();
00101 static void shutdown();
00102
00103 friend class activemq::library::ActiveMQCPP;
00104 };
00105
00106 }}
00107
00108 #endif