summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/EventHandler.h
blob: b3d3a833f37134f22030fcc145e0076f96b20bce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// **********************************************************************
//
// Copyright (c) 2002
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#ifndef ICE_EVENT_HANDLER_H
#define ICE_EVENT_HANDLER_H

#include <IceUtil/Shared.h>
#include <Ice/EventHandlerF.h>
#include <Ice/InstanceF.h>
#include <Ice/ThreadPoolF.h>
#include <Ice/Stream.h>

namespace Ice
{

class LocalException;

}

namespace IceInternal
{

class EventHandler : public ::IceUtil::Shared
{
public:
    
    //
    // Returns true if the event handler belongs to the server-side of
    // an application. Client-side otherwise.
    //
    virtual bool server() const = 0;

    //
    // Return true if read() must be called before calling message().
    //
    virtual bool readable() const = 0;

    //
    // Read data via the event handler. May only be called if
    // readable() returns true.
    //
    virtual void read(Stream&) = 0;

    //
    // A complete message has been received.
    //
    virtual void message(Stream&) = 0;

    //
    // Signal exception during reading or unmarshaling.
    //
    virtual void exception(const ::Ice::LocalException&) = 0;

    //
    // Will be called if the event handler is finally
    // unregistered. (Calling unregister() does not unregister
    // immediately.)
    //
    virtual void finished() = 0;

protected:
    
    EventHandler(const InstancePtr&);
    virtual ~EventHandler();

    InstancePtr _instance;

private:

    //
    // The _stream data member is for use by ThreadPool only
    //
    Stream _stream;
    friend ThreadPool;
};

}

#endif