summaryrefslogtreecommitdiff
path: root/cpp/src/Yellow/AdminI.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2002-07-17 20:10:41 +0000
committerMatthew Newhook <matthew@zeroc.com>2002-07-17 20:10:41 +0000
commitf7965adf013cb576a3d2cd0f05e2731ab10b4f8d (patch)
treee820b257dbb0d7fb653961124d1a27da86751b96 /cpp/src/Yellow/AdminI.cpp
parentHave added new capabilities to Glacier to adjust the issued time to allow (diff)
downloadice-f7965adf013cb576a3d2cd0f05e2731ab10b4f8d.tar.bz2
ice-f7965adf013cb576a3d2cd0f05e2731ab10b4f8d.tar.xz
ice-f7965adf013cb576a3d2cd0f05e2731ab10b4f8d.zip
Added Yellow implementation.
Diffstat (limited to 'cpp/src/Yellow/AdminI.cpp')
-rw-r--r--cpp/src/Yellow/AdminI.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/cpp/src/Yellow/AdminI.cpp b/cpp/src/Yellow/AdminI.cpp
new file mode 100644
index 00000000000..3cf4e90b3c1
--- /dev/null
+++ b/cpp/src/Yellow/AdminI.cpp
@@ -0,0 +1,85 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#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);
+ }
+}
+