Async 1.5.0
AsyncApplication.h
Go to the documentation of this file.
1
30#ifndef ASYNC_APPLICATION_INCLUDED
31#define ASYNC_APPLICATION_INCLUDED
32
33
34/****************************************************************************
35 *
36 * System Includes
37 *
38 ****************************************************************************/
39
40#include <sigc++/sigc++.h>
41
42#include <string>
43
44
45/****************************************************************************
46 *
47 * Project Includes
48 *
49 ****************************************************************************/
50
51
52
53/****************************************************************************
54 *
55 * Local Includes
56 *
57 ****************************************************************************/
58
59
60
61/****************************************************************************
62 *
63 * Forward declarations
64 *
65 ****************************************************************************/
66
67
68
69/****************************************************************************
70 *
71 * Namespace
72 *
73 ****************************************************************************/
74
75namespace Async
76{
77
78/****************************************************************************
79 *
80 * Forward declarations of classes inside of the declared namespace
81 *
82 ****************************************************************************/
83
84class Timer;
85class FdWatch;
86class DnsLookupWorker;
87
88
89/****************************************************************************
90 *
91 * Defines & typedefs
92 *
93 ****************************************************************************/
94
95
96
97/****************************************************************************
98 *
99 * Exported Global Variables
100 *
101 ****************************************************************************/
102
103
104
105/****************************************************************************
106 *
107 * Class definitions
108 *
109 ****************************************************************************/
110
118class Application : public sigc::trackable
119{
120 public:
129 static Application &app(void);
130
135
139 virtual ~Application(void);
140
148 virtual void exec(void) = 0;
149
155 virtual void quit(void) = 0;
156
178 void runTask(sigc::slot<void> task);
179
180 protected:
181 void clearTasks(void);
182
183 private:
184 friend class FdWatch;
185 friend class Timer;
186 friend class DnsLookup;
187
188 typedef std::list<sigc::slot<void> > SlotList;
189
190 static Application *app_ptr;
191
192 SlotList task_list;
193 Timer *task_timer;
194
195 void taskTimerExpired(void);
196 virtual void addFdWatch(FdWatch *fd_watch) = 0;
197 virtual void delFdWatch(FdWatch *fd_watch) = 0;
198 virtual void addTimer(Timer *timer) = 0;
199 virtual void delTimer(Timer *timer) = 0;
200 virtual DnsLookupWorker *newDnsLookupWorker(const std::string& label) = 0;
201
202}; /* class Application */
203
204
205} /* namespace */
206
207#endif /* ASYNC_APPLICATION_INCLUDED */
208
209
210
211/*
212 * This file has not been truncated
213 */
214
The base class for asynchronous applications.
static Application & app(void)
Get the one and only application instance.
void runTask(sigc::slot< void > task)
Run a task from the Async main loop.
virtual ~Application(void)
Destructor.
void clearTasks(void)
Application(void)
Default constructor.
virtual void exec(void)=0
Execute the application main loop.
virtual void quit(void)=0
Exit the application main loop.
A class for performing asynchronous DNS lookups.
A class for watching file descriptors.
Definition: AsyncFdWatch.h:120
A class that produces timer events.
Definition: AsyncTimer.h:117
Namespace for the asynchronous programming classes.