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