summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/EndpointFactory.h
blob: b775cd1c91ad2ea84db6e46abde47f25f860dc7d (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// **********************************************************************
//
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#ifndef ICE_ENDPOINT_FACTORY_H
#define ICE_ENDPOINT_FACTORY_H

#include <IceUtil/Shared.h>
#include <Ice/EndpointIF.h>
#include <Ice/EndpointFactoryF.h>
#include <Ice/ProtocolInstanceF.h>
#include <Ice/CommunicatorF.h>
#include <Ice/Plugin.h>

namespace Ice
{

class InputStream;

}

namespace IceInternal
{

class ICE_API EndpointFactory : public ::IceUtil::Shared
{
public:

    virtual ~EndpointFactory();

    virtual void initialize();
    virtual Ice::Short type() const = 0;
    virtual std::string protocol() const = 0;
    virtual EndpointIPtr create(std::vector<std::string>&, bool) const = 0;
    virtual EndpointIPtr read(Ice::InputStream*) const = 0;
    virtual void destroy() = 0;

    virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const = 0;

protected:

    EndpointFactory();
};

//
// The endpoint factory with underlying create endpoints that delegate to an underlying
// endpoint (e.g.: the SSL/WS endpoints are endpoints with underlying endpoints).
//
class ICE_API EndpointFactoryWithUnderlying : public EndpointFactory
{
public:

    EndpointFactoryWithUnderlying(const ProtocolInstancePtr&, Ice::Short);

    virtual void initialize();
    virtual Ice::Short type() const;
    virtual std::string protocol() const;
    virtual EndpointIPtr create(std::vector<std::string>&, bool) const;
    virtual EndpointIPtr read(Ice::InputStream*) const;
    virtual void destroy();

    virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const;

    virtual EndpointFactoryPtr cloneWithUnderlying(const ProtocolInstancePtr&, Ice::Short) const = 0;

protected:

    virtual EndpointIPtr createWithUnderlying(const EndpointIPtr&, std::vector<std::string>&, bool) const = 0;
    virtual EndpointIPtr readWithUnderlying(const EndpointIPtr&, Ice::InputStream*) const = 0;

    ProtocolInstancePtr _instance;
    const Ice::Short _type;
    EndpointFactoryPtr _underlying;
};

//
// The underlying endpoint factory creates endpoints with a factory of the given
// type. If this factory is of the EndpointFactoryWithUnderlying type, it will
// delegate to the given underlying factory (this is used by IceIAP/IceBT plugins
// for the BTS/iAPS endpoint factories).
//
class ICE_API UnderlyingEndpointFactory : public EndpointFactory
{
public:

    UnderlyingEndpointFactory(const ProtocolInstancePtr&, Ice::Short, Ice::Short);

    virtual void initialize();
    virtual Ice::Short type() const;
    virtual std::string protocol() const;
    virtual EndpointIPtr create(std::vector<std::string>&, bool) const;
    virtual EndpointIPtr read(Ice::InputStream*) const;
    virtual void destroy();

    virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const;

private:

    ProtocolInstancePtr _instance;
    const Ice::Short _type;
    const Ice::Short _underlying;
    EndpointFactoryPtr _factory;
};

class ICE_API EndpointFactoryPlugin : public Ice::Plugin
{
public:

    EndpointFactoryPlugin(const Ice::CommunicatorPtr&, const EndpointFactoryPtr&);

    virtual void initialize();
    virtual void destroy();
};

}

#endif