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

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

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

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

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

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

void
IcePack::AdminI::remove(const string& identity)
{
    JTCSyncT<JTCMutex> sync(*this);
    _map.erase(identity);
}

ServerDescriptionPtr
IcePack::AdminI::find(const string& identity)
{
    JTCSyncT<JTCMutex> sync(*this);

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

ServerDescriptions
IcePack::AdminI::getAll()
{
    ServerDescriptions result;
    result.reserve(_map.size());
    for (map<string, ServerDescriptionPtr>::iterator p = _map.begin(); p != _map.end(); ++p)
    {
	result.push_back(p->second);
    }
    return result;
}

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