FFL
1.0
Finfly Foundation Library
|
00001 /* $Id: client.h 2706 2011-12-24 12:02:29Z roma $ */ 00002 #ifndef _CSSC_CLIENT_H_ 00003 #define _CSSC_CLIENT_H_ 00004 00005 #include "../ipc/socket.h" 00006 #include "logbook.h" 00007 #include "request.h" 00008 #include <co.h> 00009 00010 namespace ffl 00011 { 00012 00013 namespace cssc 00014 { 00015 00023 class client:public ffl::ipc::socket::environment 00024 { 00025 public: 00026 00028 class configuration 00029 { 00030 public: 00031 00033 std::string TracePath; 00034 00040 configuration() throw(); 00041 00048 static std::string path() throw(); 00049 00057 void save() const throw(...); 00058 00059 } Configuration; //<! Конфигурация клиента (изменения в конфигурации вступают в силу только после сохранения конфигурации (#save) для новых объектов клиента). 00060 00061 client() throw(); 00062 00063 class request; 00064 00066 class connection 00067 { 00068 public: 00069 00071 class configuration 00072 { 00073 public: 00074 00075 std::string Id; 00076 std::string Info; 00077 std::string Host; 00078 std::string Service; 00079 std::string User; 00080 std::string Password; 00081 long IOTimeout; 00082 long RqTimeout; 00083 bool Trace; 00084 std::string TracePath; 00085 00093 void save() const throw(...); 00094 00101 configuration() throw(); 00102 00109 configuration(const configuration& _c) throw(); 00110 00118 configuration(const char* _id) throw(); 00119 00128 static void read(std::map<std::string, configuration>& _l) throw(); 00129 00134 void remove() const throw(...); 00135 00136 }; 00137 00141 connection(client& _c) throw():Client(_c), Socket(0){} 00142 00164 void connect(const char* _a, const char* _s, const char* _u, const char* _p, long _iot = -1, long _rqt = -1, bool _trace = false) throw(...); 00165 00179 void connect(const configuration& _c, const char* _u = 0, const char* _p = 0) throw(...); 00180 00194 void connect(const char* _c, const char* _u = 0, const char* _p = 0) throw(...); 00195 00196 private: 00197 00198 friend class request; 00199 00200 client& Client; 00201 00202 std::auto_ptr<ipc::socket> Socket; 00203 00204 long IOTimeout; 00205 00206 long RqTimeout; 00207 00208 std::auto_ptr<logbook> Log; 00209 00210 }; 00211 00222 class request:public cssc::request 00223 { 00224 public: 00225 00234 request(const std::string& _name):cssc::request(_name){} 00235 00249 void execute(connection& _c) throw(...) 00250 { 00251 cssc::request::execute(*(_c.Socket), *_c.Log, _c.IOTimeout, _c.RqTimeout); 00252 } 00253 00254 }; 00255 00256 }; 00257 00258 } 00259 00260 } 00261 00262 #endif