blob: c997836c2f2d28b5808b02dc15a29b32f4d70c52 (
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
|
// **********************************************************************
//
// Copyright (c) 2001
// ZeroC, Inc.
// Billerica, MA, USA
//
// All Rights Reserved.
//
// Ice is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// **********************************************************************
#include <Yellow/AdminI.h>
using namespace std;
using namespace Ice;
using namespace Yellow;
using namespace Freeze;
Yellow::AdminI::AdminI(const DBPtr& db) :
_dict(db)
{
}
void
Yellow::AdminI::add(const string& intf, const ObjectPrx& offer, const Current&)
{
IceUtil::Mutex::Lock sync(*this);
ObjectProxySeq seq;
StringObjectProxySeqDict::iterator p = _dict.find(intf);
if(p != _dict.end())
{
seq = p->second;
}
seq.push_back(offer);
if(p == _dict.end())
{
_dict.insert(make_pair(intf, seq));
}
else
{
p.set(seq);
}
}
void
Yellow::AdminI::remove(const string& intf, const ObjectPrx& offer, const Current&)
{
IceUtil::Mutex::Lock sync(*this);
ObjectProxySeq seq;
StringObjectProxySeqDict::iterator p = _dict.find(intf);
if(p == _dict.end())
{
throw NoSuchOfferException();
}
seq = p->second;
Ice::Identity ident = offer->ice_getIdentity();
ObjectProxySeq::iterator q;
for(q = seq.begin(); q != seq.end(); ++q)
{
ObjectPrx proxy = *q;
if(proxy->ice_getIdentity() == ident)
{
break;
}
}
if(q == seq.end())
{
throw NoSuchOfferException();
}
seq.erase(q);
if(seq.size() == 0)
{
_dict.erase(p);
}
else
{
p.set(seq);
}
}
|