1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_EVENT_HANDLER_H
6 #define ICE_EVENT_HANDLER_H
7 
8 #include <IceUtil/Shared.h>
9 #include <Ice/EventHandlerF.h>
10 #include <Ice/InstanceF.h>
11 #include <Ice/ThreadPoolF.h>
12 #include <Ice/Network.h>
13 #include <Ice/VirtualShared.h>
14 
15 namespace IceInternal
16 {
17 
18 class ICE_API EventHandler :
19 #ifdef ICE_CPP11_MAPPING
20         public EnableSharedFromThis<EventHandler>
21 #else
22         public virtual Ice::LocalObject
23 #endif
24 {
25 public:
26 
27 #if defined(ICE_USE_IOCP) || defined(ICE_OS_UWP)
28     //
29     // Called to start a new asynchronous read or write operation.
30     //
31     virtual bool startAsync(SocketOperation) = 0;
32     virtual bool finishAsync(SocketOperation) = 0;
33 #endif
34 
35     //
36     // Called when there's a message ready to be processed.
37     //
38     virtual void message(ThreadPoolCurrent&) = 0;
39 
40     //
41     // Called when the event handler is unregistered.
42     //
43     virtual void finished(ThreadPoolCurrent&, bool) = 0;
44 
45     //
46     // Get a textual representation of the event handler.
47     //
48     virtual std::string toString() const = 0;
49 
50     //
51     // Get the native information of the handler, this is used by the selector.
52     //
53     virtual NativeInfoPtr getNativeInfo() = 0;
54 
55 protected:
56 
57     EventHandler();
58     virtual ~EventHandler();
59 
60 #if defined(ICE_USE_IOCP) || defined(ICE_OS_UWP)
61     SocketOperation _pending;
62     SocketOperation _started;
63     SocketOperation _completed;
64     bool _finish;
65 #else
66     SocketOperation _disabled;
67 #endif
68     SocketOperation _ready;
69     SocketOperation _registered;
70 
71     friend class ThreadPool;
72     friend class ThreadPoolCurrent;
73     friend class Selector;
74 #ifdef ICE_USE_CFSTREAM
75     friend class EventHandlerWrapper;
76 #endif
77 };
78 
79 }
80 
81 #endif
82