summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/LocatorInfo.h
blob: 703f1160f5a34ee6896665f80b5312414e870675 (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
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#ifndef ICE_LOCATOR_INFO_H
#define ICE_LOCATOR_INFO_H

#include <IceUtil/Shared.h>
#include <IceUtil/Mutex.h>
#include <Ice/Locator.h>
#include <Ice/LocatorInfoF.h>
#include <Ice/LocatorF.h>
#include <Ice/ProxyF.h>
#include <Ice/EndpointF.h>

namespace IceInternal
{

class LocatorManager : public ::IceUtil::Shared, public ::IceUtil::Mutex
{
public:

    LocatorManager();

    void destroy();

    //
    // Returns locator info for a given locator. Automatically creates
    // the locator info if it doesn't exist yet.
    //
    LocatorInfoPtr get(const ::Ice::LocatorPrx&);

private:

    std::map< ::Ice::LocatorPrx, LocatorInfoPtr> _table;
    std::map< ::Ice::LocatorPrx, LocatorInfoPtr>::iterator _tableHint;

    std::map< ::Ice::Identity, LocatorAdapterTablePtr> _adapterTables;
};

class LocatorAdapterTable : public ::IceUtil::Shared, public ::IceUtil::Mutex
{
public:

    LocatorAdapterTable();

    void clear();
    
    bool get(const std::string&, ::std::vector<EndpointPtr>&) const;
    void add(const std::string&, const ::std::vector<EndpointPtr>&);
    ::std::vector<EndpointPtr> remove(const std::string&);
    
private:

    std::map<std::string, std::vector<EndpointPtr> > _adapterEndpointsMap;
};

class LocatorInfo : public ::IceUtil::Shared, public ::IceUtil::Mutex
{
public:

    LocatorInfo(const ::Ice::LocatorPrx&, const LocatorAdapterTablePtr&);

    void destroy();

    bool operator==(const LocatorInfo&) const;
    bool operator!=(const LocatorInfo&) const;
    bool operator<(const LocatorInfo&) const;

    ::Ice::LocatorPrx getLocator() const;
    ::Ice::LocatorRegistryPrx getLocatorRegistry();

    std::vector<EndpointPtr> getEndpoints(const ReferencePtr&, bool&);
    void clearCache(const ReferencePtr&);

private:

    ::Ice::LocatorPrx _locator; // Immutable.
    ::Ice::LocatorRegistryPrx _locatorRegistry;
    LocatorAdapterTablePtr _adapterTable; // Immutable.
};

}

#endif