summaryrefslogtreecommitdiff
path: root/cpp/src/IcePack/AdminI.cpp
blob: 9315d441c706ce33ec45653d21bdb2a5f110421f (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
// **********************************************************************
//
// Copyright (c) 2001
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#include <Ice/Ice.h>
#include <AdminI.h>

using namespace std;
using namespace Ice;
using namespace IcePack;

AdminI::AdminI(const CommunicatorPtr& communicator) :
    _communicator(communicator)
{
}

void
AdminI::add(const ServerDescriptionPtr& p)
{
    JTCSyncT<JTCMutex> sync(*this);

    if (p && p->object)
    {
	_map[p->object] = p;
    }
}

void
AdminI::remove(const ObjectPrx& p)
{
    JTCSyncT<JTCMutex> sync(*this);

    if (p)
    {
	_map.erase(p);
    }
}

ServerDescriptionPtr
AdminI::find(const ObjectPrx& p)
{
    JTCSyncT<JTCMutex> sync(*this);

    if (p)
    {
	map<ObjectPrx, ServerDescriptionPtr>::iterator q = _map.find(p);
	if (q != _map.end())
	{
	    return q->second;
	}
	else
	{
	    return 0;
	}
    }
    else
    {
	return 0;
    }
}

void
AdminI::shutdown()
{
    _communicator->shutdown();
}