00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SERVERCONFIGURATION_H_
00009 #define SERVERCONFIGURATION_H_
00010
00011 #include <string>
00012 #include "infinispan/hotrod/defs.h"
00013 #include "infinispan/hotrod/portable.h"
00014 #include "infinispan/hotrod/ImportExport.h"
00015
00016 namespace infinispan {
00017 namespace hotrod {
00018
00024 class HR_EXTERN ServerConfiguration
00025 {
00026 public:
00027 ServerConfiguration(): host(""), port(0) {}
00028 ServerConfiguration(const std::string &_host, int _port): host(_host), port(_port) {}
00029
00030 const std::string &getHost() const
00031 {
00032 if (hostPtr.get() == NULL) {
00033 const_cast<ServerConfiguration *>(this)->hostPtr.set(new std::string(host.c_string()), &deleteString);
00034 }
00035 return *hostPtr.get();
00036 }
00042 const char *getHostCString() const
00043 {
00044 return host.c_string();
00045 }
00046
00052 const int& getPort() const
00053 {
00054 return port;
00055 }
00056
00057 private:
00058 portable::string host;
00059 __pragma(warning(suppress:4251))
00060 portable::local_ptr<std::string> hostPtr;
00061 int port;
00062
00063 static void deleteString(std::string *str) { delete str; }
00064 };
00065
00066 }
00067 }
00068 #endif