00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __EID_CONNECTION__
00021 #define __EID_CONNECTION__
00022 #include "config.h"
00023
00024 #include <ulxmlrpcpp/ulxmlrpcpp.h>
00025 #include <ulxmlrpcpp/ulxr_tcpip_connection.h>
00026 #include <ulxmlrpcpp/ulxr_ssl_connection.h>
00027 #include <ulxmlrpcpp/ulxr_http_protocol.h>
00028 #include <ulxmlrpcpp/ulxr_requester.h>
00029 #include <ulxmlrpcpp/ulxr_value.h>
00030 #include <ulxmlrpcpp/ulxr_except.h>
00031 #include <ulxmlrpcpp/ulxr_log4j.h>
00032
00033 #include <cstdlib>
00034 #include <iostream>
00035 #include <sstream>
00036 #include <ctime>
00037 #include <memory>
00038 #include <cstring>
00039 #include <string>
00040 #include <ctime>
00041 #include <list>
00042 #include <queue>
00043 #include <map>
00044
00045 #include <pthread.h>
00046 #include <errno.h>
00047
00048 #include "eid_errno.h"
00049 #include "eid_signal.h"
00050
00051
00052
00053
00054
00055 typedef unsigned long long ulonglong;
00056 typedef long long longlong;
00057
00058
00059 namespace eid {
00060
00061 extern const char *seqHost;
00062 extern const int seqPort;
00063
00064 extern const char *EXTERNAL_GET_NEXT_COMMAND;
00065 extern const char *EXTERNAL_FAST_GET_NEXT_COMMAND;
00066 extern const char *EXTERNAL_GET_LOCATION_COMMAND;
00067
00071 struct RespPack {
00075 longlong* tab;
00079 int added;
00083 int id;
00087 int outCode;
00088 };
00089
00093 class ConnectionPack {
00094 public:
00098 int port;
00102 char* host;
00103
00107 ulxr::TcpIpConnection *conn;
00111 ulxr::HttpProtocol *prot;
00115 ulxr::Requester *client;
00116
00117 ConnectionPack();
00118 ConnectionPack(const char * _host, int _port);
00119 ~ConnectionPack();
00120
00121 static int getNextValues(ConnectionPack** pCp, const char *seqName, int numNext, RespPack &out);
00122 static int getNextValues(ConnectionPack** pCp, int seqId, int numNext, RespPack &out);
00123 private:
00124
00125 static ConnectionPack* getConnection(const char* seqName);
00126 static ConnectionPack* getConnection(const char* host, int port);
00127
00128 static int parseResp(ConnectionPack** pCp, ulxr::Value& resp, RespPack &out);
00129 static int getValuesFromArray(ulxr::Array &ar, RespPack &out);
00130 static int getNextValuesCore(ConnectionPack** pCp, const char *seqName, const int id, ulxr::MethodCall& mc, RespPack &out);
00131 };
00132
00133 template<class T, class E>
00134 T toNumber(std::basic_string<E> str) {
00135 std::stringstream ss(str);
00136 T res;
00137 ss >> res;
00138 return res;
00139 };
00140
00144 static ConnectionPack *masterPack;
00148 static std::list<ConnectionPack*> connectionPacks;
00149 }
00150 #endif