From eb9894afe8da3a9ef6a7da0ca27e0a6b32676b0c Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Thu, 26 Nov 2009 14:18:59 -0330 Subject: Added invoke test Cleaned up invoke demo Fixed order of paramaters in end_ice_invoke in C++ --- cpp/test/Ice/invoke/BlobjectI.cpp | 104 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 cpp/test/Ice/invoke/BlobjectI.cpp (limited to 'cpp/test/Ice/invoke/BlobjectI.cpp') diff --git a/cpp/test/Ice/invoke/BlobjectI.cpp b/cpp/test/Ice/invoke/BlobjectI.cpp new file mode 100644 index 00000000000..b1bb6c08b9b --- /dev/null +++ b/cpp/test/Ice/invoke/BlobjectI.cpp @@ -0,0 +1,104 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include +#include +#include + +using namespace std; + +bool +invokeInternal(const Ice::InputStreamPtr& in, vector& outParams, const Ice::Current& current) +{ + Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); + Ice::OutputStreamPtr out = Ice::createOutputStream(communicator); + if(current.operation == "opString") + { + string s; + in->read(s); + out->write(s); + out->write(s); + out->finished(outParams); + return true; + } + else if(current.operation == "opException") + { + Test::MyException ex; + out->writeException(ex); + out->finished(outParams); + return false; + } + else if(current.operation == "shutdown") + { + communicator->shutdown(); + return true; + } + else if(current.operation == "ice_isA") + { + string s; + in->read(s); + if(s == "::Test::MyClass") + { + out->write(true); + } + else + { + out->write(false); + } + out->finished(outParams); + return true; + } + else + { + Ice::OperationNotExistException ex(__FILE__, __LINE__); + ex.id = current.id; + ex.facet = current.facet; + ex.operation = current.operation; + throw ex; + } +} + +bool +BlobjectI::ice_invoke(const vector& inParams, vector& outParams, const Ice::Current& current) +{ + Ice::InputStreamPtr in = Ice::createInputStream(current.adapter->getCommunicator(), inParams); + return invokeInternal(in, outParams, current); +} + +bool +BlobjectArrayI::ice_invoke(const pair& inParams, vector& outParams, + const Ice::Current& current) +{ + Ice::InputStreamPtr in = Ice::createInputStream(current.adapter->getCommunicator(), inParams); + return invokeInternal(in, outParams, current); +} + + +void +BlobjectAsyncI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& cb, const vector& inParams, + const Ice::Current& current) +{ + Ice::InputStreamPtr in = Ice::createInputStream(current.adapter->getCommunicator(), inParams); + vector outParams; + bool ok = invokeInternal(in, outParams, current); + cb->ice_response(ok, outParams); +} + +void +BlobjectArrayAsyncI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& cb, + const pair& inParams, + const Ice::Current& current) +{ + Ice::InputStreamPtr in = Ice::createInputStream(current.adapter->getCommunicator(), inParams); + vector outParams; + bool ok = invokeInternal(in, outParams, current); + pair outPair(&outParams[0], &outParams[0] + outParams.size()); + cb->ice_response(ok, outParams); +} -- cgit v1.2.3