PollInterface.h
Go to the documentation of this file.
1// -*- C++ -*-
2// Copyright (c) 2005-2010, Isode Limited, London, England.
3// All rights reserved.
4//
5// Acquisition and use of this software and related materials for any
6// purpose requires a written licence agreement from Isode Limited,
7// or a written licence from an organisation licenced by Isode Limited
8// to grant such a licence.
9
10
11//
12//
17//
18// @VERSION@
19
20#ifndef _POLLINTERFACE_H_
21#define _POLLINTERFACE_H_
22
23/* For endpoint_t and possibly poll.h */
24#include <isode/compat/manifest.h>
25
26#include "EventSvc.h"
27#include "Syncmsg.h"
28
29namespace Poll {
30
32 // If poll.h is available, might as well make these match the
33 // values from that file.
35#ifdef POLLIN
36 Event_In = POLLIN,
37#else
38 Event_In = 0x01,
39#endif
40
41#ifdef POLLPRI
42 Event_Pri = POLLPRI,
43#else
44 Event_Pri = 0x02,
45#endif
46
47#ifdef POLLOUT
48 Event_Out = POLLOUT,
49#else
50 Event_Out = 0x04,
51#endif
52
55#ifdef POLLERR
56 Event_Err = POLLERR,
57#else
58 Event_Err = 0x08,
59#endif
60
61#ifdef POLLHUP
62 Event_Hup = POLLHUP,
63#else
64 Event_Hup = 0x10,
65#endif
66
67#ifdef POLLNVAL
68 Event_Nval = POLLNVAL,
69#else
70 Event_Nval = 0x20,
71#endif
72
73 Event_Terminate = 0x20000
74 };
75
78 struct pollmsg {
79 unsigned events;
80
81 pollmsg (unsigned ev = 0) : events(ev) {}
82 };
83
84 // Forward declarations
85 class Provider;
86 class User;
87
90
92 // This needs to be an Event::Receiver so that we can deliver
93 // the user events to it.
94 class User : public Event::Receiver {
95 public:
96 UserEvent _event;
97 endpoint_t _fd;
98 unsigned _pevents;
99 unsigned _uevents;
100
101 public:
103 User () : _fd(INVALID_ENDPOINT), _pevents(0), _uevents(0) {
104 _event.Init (this);
105 }
106
108 virtual ~User () { }
109
111 virtual void Deliver (pollmsg *msg) = 0;
112
114 virtual void actualDeliver (pollmsg *msg) = 0;
115 };
116
118 struct pollAction {
119 bool terminate;
120 };
121
129
130 class Provider {
131 private:
132 static EVENTSVC_DLL Provider *instance;
133
134 public:
137 return instance;
138 }
139
141 virtual ~Provider () {}
142
145 virtual int Register (User *user) = 0;
146
148 virtual void Deregister (User *user) = 0;
149
151 virtual void Control (User *user) = 0;
152
154 virtual void Deliver (pollAction *msg) = 0;
155
157 //
161 static int ProviderFactory (const char *type,
162 MSGstruct *msg);
163 };
164
166 typedef ::Event::AsyncEventAux<Provider,pollAction> ProviderEvent;
167}
168
169#endif /* _POLLINTERFACE_H_ */
PollEventTypes
Masks for the events.
@ Event_Nval
Hung up.
@ Event_Terminate
Invalid request: fd not open.
@ Event_Pri
There is data to read.
@ Event_Hup
Error condition.
@ Event_Err
Writing now will not block.
@ Event_Out
There is urgent data to read.
::Event::AsyncEventAux< Provider, pollAction > ProviderEvent
Type for delivering events to the provider.
Templates for constructing objects to which a sequence of messages are passed, and only one message i...
Poll provider interface.
virtual int Register(User *user)=0
Register an endpoint.
virtual void Deregister(User *user)=0
Deregister endpoint.
virtual void Deliver(pollAction *msg)=0
Interface to itself, via Event Manager.
static int ProviderFactory(const char *type, MSGstruct *msg)
Factory method.for stream provider.
Definition EventSvc.C:112
virtual void Control(User *user)=0
Set the events which are interesting for end point.
virtual ~Provider()
Virtual destructor.
static Provider * GetPollService()
Implement as a singleton.
Poll user object interface.
virtual void actualDeliver(pollmsg *msg)=0
Deliver events to Poll user.
unsigned _pevents
FD for this user.
endpoint_t _fd
Event to User.
unsigned _uevents
Provider's view of events.
virtual ~User()
Destructor is virtual.
User()
User's view of events.
virtual void Deliver(pollmsg *msg)=0
Deliver events to Poll user.
Class used to wrap each event object type for a given receiver.
Definition Syncmsg.h:30
void Init(C *rcvr)
Set the target.
Definition Syncmsg.h:48
Messages from Poll Provider to self, via event manager.
Carries the events on the appropriate FD, or that the end point should terminate.

All rights reserved © 2002 - 2024 Isode Ltd.