本文整理汇总了C++中ice::ObjectAdapterPtr::findDefaultServant方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectAdapterPtr::findDefaultServant方法的具体用法?C++ ObjectAdapterPtr::findDefaultServant怎么用?C++ ObjectAdapterPtr::findDefaultServant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ObjectAdapterPtr
的用法示例。
在下文中一共展示了ObjectAdapterPtr::findDefaultServant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
void
allTests(const Ice::CommunicatorPtr& communicator)
{
Ice::ObjectAdapterPtr oa = communicator->createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
oa->activate();
Ice::ObjectPtr servant = ICE_MAKE_SHARED(MyObjectI);
//
// Register default servant with category "foo"
//
oa->addDefaultServant(servant, "foo");
//
// Start test
//
cout << "testing single category... " << flush;
Ice::ObjectPtr r = oa->findDefaultServant("foo");
test(r == servant);
r = oa->findDefaultServant("bar");
test(r == 0);
Ice::Identity identity;
identity.category = "foo";
string names[] = { "foo", "bar", "x", "y", "abcdefg" };
int idx;
for(idx = 0; idx < 5; ++idx)
{
identity.name = names[idx];
MyObjectPrxPtr prx = ICE_UNCHECKED_CAST(MyObjectPrx, oa->createProxy(identity));
prx->ice_ping();
test(prx->getName() == names[idx]);
}
identity.name = "ObjectNotExist";
MyObjectPrxPtr prx = ICE_UNCHECKED_CAST(MyObjectPrx, oa->createProxy(identity));
try
{
prx->ice_ping();
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// Expected
}
try
{
prx->getName();
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// Expected
}
identity.name = "FacetNotExist";
prx = ICE_UNCHECKED_CAST(MyObjectPrx, oa->createProxy(identity));
try
{
prx->ice_ping();
test(false);
}
catch(const Ice::FacetNotExistException&)
{
// Expected
}
try
{
prx->getName();
test(false);
}
catch(const Ice::FacetNotExistException&)
{
// Expected
}
identity.category = "bar";
for(idx = 0; idx < 5; idx++)
{
identity.name = names[idx];
prx = ICE_UNCHECKED_CAST(MyObjectPrx, oa->createProxy(identity));
try
{
prx->ice_ping();
test(false);
}
catch(const Ice::ObjectNotExistException&)
{
// Expected
}
try
//.........这里部分代码省略.........