activemq-cpp-3.8.2
IdGenerator.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _ATIVEMQ_UTIL_IDGENERATOR_H_
19 #define _ATIVEMQ_UTIL_IDGENERATOR_H_
20 
21 #include <activemq/util/Config.h>
22 
23 #include <string>
24 
25 namespace activemq {
26 namespace library {
27  class ActiveMQCPP;
28 }
29 namespace util {
30 
31  class IdGeneratorKernel;
32 
34  private:
35 
36  std::string prefix;
37  mutable std::string seed;
38  mutable long long sequence;
39 
40  static IdGeneratorKernel* kernel;
41 
42  private:
43 
44  IdGenerator(const IdGenerator&);
45  IdGenerator& operator=(const IdGenerator&);
46 
47  public:
48 
49  IdGenerator();
50 
51  IdGenerator(const std::string& prefix);
52 
53  virtual ~IdGenerator();
54 
55  public:
56 
60  std::string generateId() const;
61 
62  public:
63 
70  static std::string getHostname();
71 
77  static std::string getSeedFromId(const std::string& id);
78 
84  static long long getSequenceFromId(const std::string& id);
85 
96  static int compare(const std::string& id1, const std::string& id2);
97 
98  private:
99 
100  static void initialize();
101  static void shutdown();
102 
104  };
105 
106 }}
107 
108 #endif /* _ATIVEMQ_UTIL_IDGENERATOR_H_ */
#define AMQCPP_API
Definition: Config.h:30
Definition: IdGenerator.h:33
Definition: ActiveMQCPP.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: CachedConsumer.h:24