Mir
dispatchable.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17  */
18 
19 #ifndef MIR_DISPATCH_DISPATCHABLE_H_
20 #define MIR_DISPATCH_DISPATCHABLE_H_
21 
22 #include "mir/fd.h"
23 
24 namespace mir
25 {
26 namespace dispatch
27 {
28 
29 enum FdEvent : uint32_t {
30  readable = 1<<0,
31  writable = 1<<1,
32  remote_closed = 1<<2,
33  error = 1<<3
34 };
35 
36 using FdEvents = uint32_t;
37 
39 {
40 public:
41  Dispatchable() = default;
42  virtual ~Dispatchable() = default;
43 
44  Dispatchable& operator=(Dispatchable const&) = delete;
45  Dispatchable(Dispatchable const&) = delete;
46 
52  virtual Fd watch_fd() const = 0;
53 
68  virtual bool dispatch(FdEvents events) = 0;
69 
73  virtual FdEvents relevant_events() const = 0;
74 };
75 }
76 }
77 
78 #endif // MIR_DISPATCH_DISPATCHABLE_H_
Definition: as_render_target.h:27
virtual ~Dispatchable()=default
virtual bool dispatch(FdEvents events)=0
Dispatch one pending event.
Definition: dispatchable.h:32
Definition: fd.h:33
Definition: dispatchable.h:31
virtual Fd watch_fd() const =0
Get a poll()able file descriptor.
virtual FdEvents relevant_events() const =0
The set of file-descriptor events this Dispatchable handles.
Definition: dispatchable.h:38
uint32_t FdEvents
Definition: dispatchable.h:36
Definition: dispatchable.h:33
Definition: dispatchable.h:30
Dispatchable & operator=(Dispatchable const &)=delete
FdEvent
Definition: dispatchable.h:29

Copyright © 2012-2016 Canonical Ltd.
Generated on Mon Jun 5 13:49:26 UTC 2017