diff options
Diffstat (limited to 'cpp/src/Yellow/QueryI.cpp')
-rw-r--r-- | cpp/src/Yellow/QueryI.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cpp/src/Yellow/QueryI.cpp b/cpp/src/Yellow/QueryI.cpp new file mode 100644 index 00000000000..82f1ebfd700 --- /dev/null +++ b/cpp/src/Yellow/QueryI.cpp @@ -0,0 +1,45 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#include <Yellow/QueryI.h> + +using namespace std; +using namespace Ice; +using namespace Yellow; +using namespace Freeze; + +Yellow::QueryI::QueryI(const DBPtr& db) : + _dict(db) +{ +} + +ObjectPrx +Yellow::QueryI::lookup(const string& intf, const Current&) +{ + StringObjectProxySeqDict::const_iterator p = _dict.find(intf); + if(p == _dict.end()) + { + throw NoSuchOfferException(); + } + + int r = rand() % p->second.size(); + return p->second[r]; +} + +ObjectProxySeq +Yellow::QueryI::lookupAll(const string& intf, const Current&) +{ + StringObjectProxySeqDict::const_iterator p = _dict.find(intf); + if(p == _dict.end()) + { + throw NoSuchOfferException(); + } + return p->second; +} |