summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2016-07-19 12:16:43 -0400
committerBernard Normier <bernard@zeroc.com>2016-07-19 12:16:43 -0400
commite16efc6d8f2abe2036a601c2695fd65bd9134246 (patch)
tree2af5e70e8b24e3596f14edec12cd249e8f056720 /cpp/test
parentICE-7240 - Python Ice/servantLocator cross test (diff)
downloadice-e16efc6d8f2abe2036a601c2695fd65bd9134246.tar.bz2
ice-e16efc6d8f2abe2036a601c2695fd65bd9134246.tar.xz
ice-e16efc6d8f2abe2036a601c2695fd65bd9134246.zip
C++11 support in test/Ice/echo
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/Ice/echo/BlobjectI.cpp55
-rw-r--r--cpp/test/Ice/echo/BlobjectI.h14
-rw-r--r--cpp/test/Ice/echo/Server.cpp4
3 files changed, 69 insertions, 4 deletions
diff --git a/cpp/test/Ice/echo/BlobjectI.cpp b/cpp/test/Ice/echo/BlobjectI.cpp
index 2d86e66f276..984236d0f15 100644
--- a/cpp/test/Ice/echo/BlobjectI.cpp
+++ b/cpp/test/Ice/echo/BlobjectI.cpp
@@ -12,6 +12,7 @@
using namespace std;
+#ifndef ICE_CPP11_MAPPING
class Callback : public IceUtil::Shared
{
public:
@@ -45,6 +46,7 @@ private:
bool _twoway;
};
typedef IceUtil::Handle<Callback> CallbackPtr;
+#endif
BlobjectI::BlobjectI() :
_startBatch(false)
@@ -66,6 +68,58 @@ BlobjectI::flushBatch()
_batchProxy = 0;
}
+#ifdef ICE_CPP11_MAPPING
+void
+BlobjectI::ice_invokeAsync(std::vector<Ice::Byte> inEncaps,
+ std::function<void(bool, std::vector<Ice::Byte>)> response,
+ std::function<void(std::exception_ptr)> ex,
+ const Ice::Current& current)
+{
+ const bool twoway = current.requestId > 0;
+ auto obj = current.con->createProxy(current.id);
+ if(!twoway)
+ {
+ if(_startBatch)
+ {
+ _startBatch = false;
+ _batchProxy = obj->ice_batchOneway();
+ }
+ if(_batchProxy)
+ {
+ obj = _batchProxy;
+ }
+
+ if(!current.facet.empty())
+ {
+ obj = obj->ice_facet(current.facet);
+ }
+
+ if(_batchProxy)
+ {
+ vector<Ice::Byte> out;
+ obj->ice_invoke(current.operation, current.mode, inEncaps, out, current.ctx);
+ response(true, vector<Ice::Byte>());
+ }
+ else
+ {
+ obj->ice_oneway()->ice_invokeAsync(current.operation, current.mode, inEncaps,
+ [](bool, std::vector<Ice::Byte>) { assert(0); },
+ ex,
+ [&](bool) { response(true, vector<Ice::Byte>()); },
+ current.ctx);
+ }
+ }
+ else
+ {
+ if(!current.facet.empty())
+ {
+ obj = obj->ice_facet(current.facet);
+ }
+
+ obj->ice_invokeAsync(current.operation, current.mode, inEncaps, response, ex, nullptr, current.ctx);
+ }
+}
+#else
void
BlobjectI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCb, const vector<Ice::Byte>& inEncaps,
const Ice::Current& current)
@@ -116,3 +170,4 @@ BlobjectI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCb, const ve
obj->begin_ice_invoke(current.operation, current.mode, inEncaps, current.ctx, del);
}
}
+#endif
diff --git a/cpp/test/Ice/echo/BlobjectI.h b/cpp/test/Ice/echo/BlobjectI.h
index 27a48791380..6f1956adf09 100644
--- a/cpp/test/Ice/echo/BlobjectI.h
+++ b/cpp/test/Ice/echo/BlobjectI.h
@@ -21,14 +21,24 @@ public:
void startBatch();
void flushBatch();
+#ifdef ICE_CPP11_MAPPING
+
+ virtual void ice_invokeAsync(std::vector<Ice::Byte>,
+ std::function<void(bool, std::vector<Ice::Byte>)>,
+ std::function<void(std::exception_ptr)>,
+ const Ice::Current&) override;
+
+#else
virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&, const std::vector<Ice::Byte>&,
const Ice::Current&);
+#endif
private:
bool _startBatch;
- Ice::ObjectPrx _batchProxy;
+ Ice::ObjectPrxPtr _batchProxy;
};
-typedef IceUtil::Handle<BlobjectI> BlobjectIPtr;
+
+ICE_DEFINE_PTR(BlobjectIPtr, BlobjectI);
#endif
diff --git a/cpp/test/Ice/echo/Server.cpp b/cpp/test/Ice/echo/Server.cpp
index 09ccc437c0d..e1d56838839 100644
--- a/cpp/test/Ice/echo/Server.cpp
+++ b/cpp/test/Ice/echo/Server.cpp
@@ -50,9 +50,9 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
- BlobjectIPtr blob = new BlobjectI;
+ BlobjectIPtr blob = ICE_MAKE_SHARED(BlobjectI);
adapter->addDefaultServant(blob, "");
- adapter->add(new EchoI(blob), communicator->stringToIdentity("__echo"));
+ adapter->add(ICE_MAKE_SHARED(EchoI, blob), communicator->stringToIdentity("__echo"));
adapter->activate();
TEST_READY