Async  0.18.0
AsyncQtApplication.h
Go to the documentation of this file.
1 
35 #ifndef ASYNC_QT_APPLICATION_INCLUDED
36 #define ASYNC_QT_APPLICATION_INCLUDED
37 
38 
39 /****************************************************************************
40  *
41  * System Includes
42  *
43  ****************************************************************************/
44 
45 #include <QObject>
46 #include <QApplication>
47 #undef emit
48 
49 #include <utility>
50 #include <map>
51 #include <set>
52 
53 
54 /****************************************************************************
55  *
56  * Project Includes
57  *
58  ****************************************************************************/
59 
60 #include <AsyncApplication.h>
61 
62 
63 /****************************************************************************
64  *
65  * Local Includes
66  *
67  ****************************************************************************/
68 
69 
70 
71 /****************************************************************************
72  *
73  * Forward declarations
74  *
75  ****************************************************************************/
76 
77 class QSocketNotifier;
78 class AsyncQtTimer;
79 
80 
81 /****************************************************************************
82  *
83  * Namespace
84  *
85  ****************************************************************************/
86 
87 namespace Async
88 {
89 
90 /****************************************************************************
91  *
92  * Defines & typedefs
93  *
94  ****************************************************************************/
95 
96 /*
97  *----------------------------------------------------------------------------
98  * Macro:
99  * Purpose:
100  * Input:
101  * Output:
102  * Author:
103  * Created:
104  * Remarks:
105  * Bugs:
106  *----------------------------------------------------------------------------
107  */
108 
109 
110 /*
111  *----------------------------------------------------------------------------
112  * Type:
113  * Purpose:
114  * Members:
115  * Input:
116  * Output:
117  * Author:
118  * Created:
119  * Remarks:
120  *----------------------------------------------------------------------------
121  */
122 
123 
124 /****************************************************************************
125  *
126  * Exported Global Variables
127  *
128  ****************************************************************************/
129 
130 
131 
132 /****************************************************************************
133  *
134  * Class definitions
135  *
136  ****************************************************************************/
137 
153 class QtApplication : public QApplication, public Application
154 {
155  Q_OBJECT
156 
157  public:
166  QtApplication(int &argc, char **argv);
167 
171  virtual ~QtApplication(void);
172 
180  void exec(void);
181 
182  public slots:
188  void quit(void);
189 
190  protected:
191 
192  private:
193  typedef std::pair<Async::FdWatch*, QSocketNotifier*> FdWatchMapItem;
194  typedef std::map<int, FdWatchMapItem> FdWatchMap;
195  typedef std::map<Timer *, AsyncQtTimer *> TimerMap;
196 
197  FdWatchMap rd_watch_map;
198  FdWatchMap wr_watch_map;
199  TimerMap timer_map;
200 
201  void addFdWatch(FdWatch *fd_watch);
202  void delFdWatch(FdWatch *fd_watch);
203  void addTimer(Timer *timer);
204  void delTimer(Timer *timer);
205  DnsLookupWorker *newDnsLookupWorker(const std::string& label);
206 
207  private slots:
208  void rdFdActivity(int socket);
209  void wrFdActivity(int socket);
210 
211 }; /* class QtApplication */
212 
213 
214 } /* namespace */
215 
216 #endif /* ASYNC_QT_APPLICATION_INCLUDED */
217 
218 
219 
220 /*
221  * This file has not been truncated
222  */
223 
The base class for asynchronous applications.
The core class for writing asyncronous applications.
virtual ~QtApplication(void)
Destructor.
An application class for writing GUI applications in Qt.
A class that produces timer events.
Definition: AsyncTimer.h:116
A class for watching file descriptors.
Definition: AsyncFdWatch.h:119
void exec(void)
Execute the application main loop.
void quit(void)
Exit the application main loop.
QtApplication(int &argc, char **argv)
Constructor.