00001 #ifndef Impala_Persistency_Locator_h
00002 #define Impala_Persistency_Locator_h
00003
00004 #include "Basis/ILog.h"
00005 #include "Basis/CmdOptions.h"
00006
00007 namespace Impala
00008 {
00009 namespace Persistency
00010 {
00011
00012
00024 class Locator
00025 {
00026 public:
00027
00028 Locator()
00029 {
00030 mProtocol = "not_set";
00031 mHost = "not_set";
00032 mDataSet = "not_set";
00033 }
00034
00035 Locator(CString dataSet)
00036 {
00037 mProtocol = "not_set";
00038 mHost = "not_set";
00039 mDataSet = dataSet;
00040 }
00041
00042 Locator(CString protocolAndHost, CString dataSet)
00043 {
00044 mProtocol = StringHead(protocolAndHost, ':', false);
00045 mHost = StringTail(protocolAndHost, ':', false);
00046 mDataSet = dataSet;
00047 }
00048
00049 Locator(CString protocol, CString host, CString dataSet)
00050 {
00051 mProtocol = protocol;
00052 mHost = host;
00053 mDataSet = dataSet;
00054 }
00055
00056 Locator(CString dataSet, CmdOptions& options)
00057 {
00058 mDataSet = dataSet;
00059
00060 String dataServer = options.GetString("dataServer");
00061 String dataServer2 = options.GetString("dataServer::"+mDataSet, "");
00062 if (!dataServer2.empty())
00063 dataServer = dataServer2;
00064 if (!dataServer.empty())
00065 {
00066 mProtocol = "dataServer";
00067 mHost = dataServer;
00068 return;
00069 }
00070
00071 String mapi = options.GetString("mapi");
00072 String mapi2 = options.GetString("mapi::"+mDataSet, "");
00073 if (!mapi2.empty())
00074 mapi = mapi2;
00075 if (!mapi.empty())
00076 {
00077 mProtocol = "mapi";
00078 mHost = mapi;
00079 return;
00080 }
00081
00082 mProtocol = "file";
00083 }
00084
00085 virtual
00086 ~Locator()
00087 {
00088 }
00089
00090 String
00091 GetProtocol() const
00092 {
00093 return mProtocol;
00094 }
00095
00096 void
00097 SetProtocol(CString protocol)
00098 {
00099 mProtocol = protocol;
00100 }
00101
00102 String
00103 GetHost() const
00104 {
00105 return mHost;
00106 }
00107
00108 void
00109 SetHost(CString host)
00110 {
00111 mHost = host;
00112 }
00113
00114 String
00115 GetProtocolAndHost() const
00116 {
00117 return mProtocol + ":" + mHost;
00118 }
00119
00120 String
00121 GetDataSet() const
00122 {
00123 return mDataSet;
00124 }
00125
00126 void
00127 SetDataSet(CString dataSet)
00128 {
00129 mDataSet = dataSet;
00130 }
00131
00132 String
00133 ToString() const
00134 {
00135 return "Locator(" + GetProtocol() + "," + GetHost()
00136 + "," + GetDataSet() + ")";
00137 }
00138
00139 private:
00140
00141 String mProtocol;
00142 String mHost;
00143 String mDataSet;
00144
00145 ILOG_VAR_DEC;
00146 };
00147
00148 ILOG_VAR_INIT(Locator, Impala.Persistency);
00149
00150 std::ostream&
00151 operator<< (std::ostream& os, const Locator& loc)
00152 {
00153 os << loc.ToString();
00154 return os;
00155 }
00156
00157 }
00158 }
00159
00160 #endif