Red Hat Data Grid HotRod C++ Client  7.2.0
Version.h
Go to the documentation of this file.
1 #ifndef ISPN_HOTROD_VERSION_H
2 #define ISPN_HOTROD_VERSION_H
3 
5 #include <string>
6 
7 namespace infinispan {
8 namespace hotrod {
9 
10 // The memory won't be ever released. It's even worse - the pointer is static,
11 // therefore, it will be allocated anew for each compilation unit using this.
12 // However, if we placed the pointers to the library, two differently compiled
13 // modules could access the same data, causing memory corruption.
14 static std::string *__protocolVersionPtr = NULL;
15 static std::string *__versionPtr = NULL;
16 
21 class Version {
22 private:
23  HR_EXTERN static const char *PROTOCOL_VERSION;
24  HR_EXTERN static const char *VERSION;
25 
26 public:
32  static const char *getProtocolVersionCString() {
33  return PROTOCOL_VERSION;
34  }
35 
41  static const char *getVersionCString() {
42  return VERSION;
43  }
44 
48  static const std::string &getProtocolVersion() {
49  if (__protocolVersionPtr == NULL) {
50  __protocolVersionPtr = new std::string(PROTOCOL_VERSION);
51  }
52  return *__protocolVersionPtr;
53  }
54 
58  static const std::string &getVersion() {
59  if (__versionPtr == NULL) {
60  __versionPtr = new std::string(VERSION);
61  }
62  return *__versionPtr;
63  }
64 };
65 
66 }}
67 
68 #endif // ISPN_HOTROD_VERSIONEDVALUE_H
static const char * getProtocolVersionCString()
Definition: Version.h:32
#define HR_EXTERN
Definition: ImportExport.h:35
Definition: AuthenticationConfiguration.h:10
Definition: Version.h:21
static const std::string & getVersion()
Definition: Version.h:58
static const char * getVersionCString()
Definition: Version.h:41
static const std::string & getProtocolVersion()
Definition: Version.h:48