00001 00031 #ifndef ASYNC_CPP_APPLICATION_INCLUDED 00032 #define ASYNC_CPP_APPLICATION_INCLUDED 00033 00034 00035 /**************************************************************************** 00036 * 00037 * System Includes 00038 * 00039 ****************************************************************************/ 00040 00041 #include <sys/types.h> 00042 #include <sys/select.h> 00043 #include <sys/time.h> 00044 #include <sigc++/signal_system.h> 00045 00046 #include <map> 00047 #include <pair.h> 00048 00049 /**************************************************************************** 00050 * 00051 * Project Includes 00052 * 00053 ****************************************************************************/ 00054 00055 #include <AsyncApplication.h> 00056 00057 00058 /**************************************************************************** 00059 * 00060 * Local Includes 00061 * 00062 ****************************************************************************/ 00063 00064 00065 00066 /**************************************************************************** 00067 * 00068 * Forward declarations 00069 * 00070 ****************************************************************************/ 00071 00072 00073 00074 /**************************************************************************** 00075 * 00076 * Namespace 00077 * 00078 ****************************************************************************/ 00079 00080 namespace Async 00081 { 00082 00083 /**************************************************************************** 00084 * 00085 * Defines & typedefs 00086 * 00087 ****************************************************************************/ 00088 00089 /* 00090 *---------------------------------------------------------------------------- 00091 * Macro: 00092 * Purpose: 00093 * Input: 00094 * Output: 00095 * Author: 00096 * Created: 00097 * Remarks: 00098 * Bugs: 00099 *---------------------------------------------------------------------------- 00100 */ 00101 00102 00103 /* 00104 *---------------------------------------------------------------------------- 00105 * Type: 00106 * Purpose: 00107 * Members: 00108 * Input: 00109 * Output: 00110 * Author: 00111 * Created: 00112 * Remarks: 00113 *---------------------------------------------------------------------------- 00114 */ 00115 00116 00117 /**************************************************************************** 00118 * 00119 * Exported Global Variables 00120 * 00121 ****************************************************************************/ 00122 00123 00124 00125 /**************************************************************************** 00126 * 00127 * Class definitions 00128 * 00129 ****************************************************************************/ 00130 00134 class CppApplication : public Application 00135 { 00136 public: 00140 CppApplication(void); 00141 00145 ~CppApplication(void); 00146 00154 void exec(void); 00155 00161 void quit(void); 00162 00163 protected: 00164 00165 private: 00166 struct lttimeval 00167 { 00168 bool operator()(const struct timeval& t1, const struct timeval& t2) const 00169 { 00170 return timercmp(&t1, &t2, <); 00171 } 00172 }; 00173 typedef std::map<int, FdWatch*> WatchMap; 00174 typedef std::multimap<struct timeval, Timer *, lttimeval> TimerMap; 00175 00176 bool do_quit; 00177 int max_desc; 00178 fd_set rd_set; 00179 fd_set wr_set; 00180 WatchMap rd_watch_map; 00181 WatchMap wr_watch_map; 00182 TimerMap timer_map; 00183 00184 void addFdWatch(FdWatch *fd_watch); 00185 void delFdWatch(FdWatch *fd_watch); 00186 void addTimer(Timer *timer); 00187 void addTimerP(Timer *timer, const struct timeval& current); 00188 void delTimer(Timer *timer); 00189 DnsLookupWorker *newDnsLookupWorker(const std::string& label); 00190 00191 }; /* class CppApplication */ 00192 00193 00194 } /* namespace */ 00195 00196 #endif /* ASYNC_CPP_APPLICATION_INCLUDED */ 00197 00198 00199 00200 /* 00201 * This file has not been truncated 00202 */ 00203
1.4.4