JBoss Data Grid HotRod C++ Client  7.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ServerConfiguration.h
Go to the documentation of this file.
1 /*
2  * ServerConfiguration.h
3  *
4  * Created on: Jul 10, 2013
5  * Author: samuele
6  */
7 
8 #ifndef SERVERCONFIGURATION_H_
9 #define SERVERCONFIGURATION_H_
10 
11 #include <string>
12 #include "infinispan/hotrod/defs.h"
15 
16 namespace infinispan {
17 namespace hotrod {
18 
25 {
26 public:
27  ServerConfiguration(): host(""), port(0) {} // for use just in collections
28  ServerConfiguration(const std::string &_host, int _port): host(_host), port(_port) {}
29 
30  const std::string &getHost() const
31  {
32  if (hostPtr.get() == NULL) {
33  const_cast<ServerConfiguration *>(this)->hostPtr.set(new std::string(host.c_string()), &deleteString);
34  }
35  return *hostPtr.get();
36  }
42  const char *getHostCString() const
43  {
44  return host.c_string();
45  }
46 
52  const int& getPort() const
53  {
54  return port;
55  }
56 
57 private:
58  portable::string host;
59  __pragma(warning(suppress:4251))
60  portable::local_ptr<std::string> hostPtr;
61  int port;
62 
63  static void deleteString(std::string *str) { delete str; }
64 };
65 
66 }
67 }
68 #endif /* SERVERCONFIGURATION_H_ */
const std::string & getHost() const
Definition: ServerConfiguration.h:30
ServerConfiguration(const std::string &_host, int _port)
Definition: ServerConfiguration.h:28
#define HR_EXTERN
Definition: ImportExport.h:35
const int & getPort() const
Definition: ServerConfiguration.h:52
const char * getHostCString() const
Definition: ServerConfiguration.h:42
#define __pragma(...)
Definition: defs.h:106
Definition: ServerConfiguration.h:24
ServerConfiguration()
Definition: ServerConfiguration.h:27
Definition: portable.h:47