//****************************************************************************** // RCF - Remote Call Framework // Copyright (c) 2005 - 2007. All rights reserved. // Consult your license for conditions of use. // Developed by Jarl Lindrud. // Contact: jlindrud@hotmail.com . //****************************************************************************** #ifndef INCLUDE_RCF_MARSHAL_HPP #define INCLUDE_RCF_MARSHAL_HPP #include #include #include #include #include #include #include #include #include // FOR_EACH_PRIMITIVE_TYPE #include #include #include #include #include #include #ifdef RCF_USE_BOOST_SERIALIZATION #include #endif // TODO: move code into Marshal.inl namespace RCF { // Boost.Serialization treats pointers of primitive types differently than other types, // hence the following hack, which unfortunately overrides all the serialization protocols, // not just Boost.Serialization. #define RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION(type) \ inline void serializeImpl( \ SerializationProtocolOut &out, \ const type *pt, \ long int) \ { \ serialize(out, *pt); \ } \ \ inline void serializeImpl( \ SerializationProtocolOut &out, \ type *const pt, \ long int) \ { \ serialize(out, *pt); \ } \ \ inline void deserializeImpl( \ SerializationProtocolIn &in, \ type *&pt, \ long int) \ { \ RCF_ASSERT(pt==NULL); \ pt = new type(); \ deserialize(in, *pt); \ } SF_FOR_EACH_FUNDAMENTAL_TYPE( RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION ) #define RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION_T3(type) \ template \ inline void serializeImpl( \ SerializationProtocolOut &out, \ const type *pt, \ int) \ { \ serialize(out, *pt); \ } \ \ template \ inline void serializeImpl( \ SerializationProtocolOut &out, \ type *const pt, \ int) \ { \ serialize(out, *pt); \ } \ \ template \ inline void deserializeImpl( \ SerializationProtocolIn &in, \ type *&pt, \ int) \ { \ RCF_ASSERT(pt==NULL); \ pt = new type(); \ deserialize(in, *pt); \ } #if defined(__MWERKS__) || (defined(_MSC_VER) && _MSC_VER < 1310) // ambiguity issues with CW RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION(std::string) RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION(std::wstring) #else RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION_T3(std::basic_string) #endif #undef RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION #undef RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION_T3 // Boost.Serialization handles smart pointers very clumsily, so we do those ourselves //#define RCF_SERIALIZE_REFCOUNTSMARTPTR(RefCountSmartPtr) #define RefCountSmartPtr boost::shared_ptr template inline void serializeImpl( SerializationProtocolOut &out, const RefCountSmartPtr *spt, int) { serialize(out, *spt); } template inline void serializeImpl( SerializationProtocolOut &out, RefCountSmartPtr *const spt, int) { serialize(out, *spt); } template inline void deserializeImpl( SerializationProtocolIn &in, RefCountSmartPtr *&spt, int) { spt = new RefCountSmartPtr(); deserialize(in, *spt); } template inline void serializeImpl( SerializationProtocolOut &out, const RefCountSmartPtr &spt, int) { serialize(out, spt.get()); } template inline void deserializeImpl( SerializationProtocolIn &in, RefCountSmartPtr &spt, int) { T *pt = NULL; deserialize(in, pt); RefCountSmartPtr *pspt = in.mPointerContext.get( (RefCountSmartPtr **) NULL, pt); if (pspt == NULL) { spt = RefCountSmartPtr(pt); in.mPointerContext.set( &spt, pt); } else { spt = *pspt; } } #undef RefCountSmartPtr inline void serializeImpl( SerializationProtocolOut &out, const ByteBuffer &byteBuffer, long int) { int len = static_cast(byteBuffer.getLength()); serialize(out, len); out.insert(byteBuffer); } inline void deserializeImpl( SerializationProtocolIn &in, ByteBuffer &byteBuffer, long int) { int len = 0; deserialize(in, len); in.extractSlice(byteBuffer, len); } #ifdef RCF_USE_SF_SERIALIZATION inline void serialize(SF::Archive &ar, ByteBuffer &byteBuffer, unsigned int) { // TODO: some subtle issues here, determining which marshalling buffer to access SerializationProtocolIn *pIn = NULL; SerializationProtocolOut *pOut = NULL; ClientStubPtr clientStubPtr = RCF::getCurrentClientStubPtr(); RcfSessionPtr rcfSessionPtr = RCF::getCurrentRcfSessionPtr(); if (clientStubPtr) { pIn = &clientStubPtr->mIn; pOut = &clientStubPtr->mOut; } else if (rcfSessionPtr) { pIn = &rcfSessionPtr->mIn; pOut = &rcfSessionPtr->mOut; } if (ar.isRead()) { boost::uint32_t len = 0; ar & len; byteBuffer.clear(); SerializationProtocolIn *pIn = getCurrentSerializationProtocolIn(); if (pIn && len) { pIn->extractSlice(byteBuffer, len); } else if (len) { byteBuffer = ByteBuffer(len); SF::IStream &is = dynamic_cast(*ar.getStream()); boost::uint32_t bytesToRead = len; boost::uint32_t bytesRead = is.read( (SF::Byte8 *) byteBuffer.getPtr(), bytesToRead); RCF_VERIFY( bytesRead == bytesToRead, RCF::Exception(RCF::RcfError_Deserialization)) (bytesToRead)(bytesRead); } } else if (ar.isWrite()) { boost::uint32_t len = static_cast(byteBuffer.getLength()); ar & len; SerializationProtocolOut *pOut = getCurrentSerializationProtocolOut(); if (pOut && len) { pOut->insert(byteBuffer); } else if (len) { boost::uint32_t bytesToWrite = len; dynamic_cast(ar.getStream())->writeRaw( (SF::Byte8 *) byteBuffer.getPtr(), bytesToWrite); } } } #endif // RCF_USE_SF_SERIALIZATION #ifdef RCF_USE_BOOST_SERIALIZATION } // namespace RCF namespace boost { namespace serialization { template void save(Archive & ar, const RCF::ByteBuffer &byteBuffer, unsigned int) { RCF::SerializationProtocolIn *pIn = NULL; RCF::SerializationProtocolOut *pOut = NULL; RCF::ClientStubPtr clientStubPtr = RCF::getCurrentClientStubPtr(); RCF::RcfSessionPtr rcfSessionPtr = RCF::getCurrentRcfSessionPtr(); if (clientStubPtr) { pIn = &clientStubPtr->mIn; pOut = &clientStubPtr->mOut; } else if (rcfSessionPtr) { pIn = &rcfSessionPtr->mIn; pOut = &rcfSessionPtr->mOut; } //if (archive.isRead()) //{ // boost::uint32_t len = 0; // archive & len; // pIn->extractSlice(byteBuffer, len); //} //else if (archive.isWrite()) { boost::uint32_t len = byteBuffer.getLength(); ar & len; pOut->insert(byteBuffer); } } template void load(Archive &ar, RCF::ByteBuffer &byteBuffer, unsigned int) { RCF::SerializationProtocolIn *pIn = NULL; RCF::SerializationProtocolOut *pOut = NULL; RCF::ClientStubPtr clientStubPtr = RCF::getCurrentClientStubPtr(); RCF::RcfSessionPtr rcfSessionPtr = RCF::getCurrentRcfSessionPtr(); if (clientStubPtr) { pIn = &clientStubPtr->mIn; pOut = &clientStubPtr->mOut; } else if (rcfSessionPtr) { pIn = &rcfSessionPtr->mIn; pOut = &rcfSessionPtr->mOut; } //if (archive.isRead()) { boost::uint32_t len = 0; ar & len; pIn->extractSlice(byteBuffer, len); } //else if (archive.isWrite()) //{ // boost::uint32_t len = byteBuffer.getLength(); // archive & len; // pOut->insert(byteBuffer); //} } }} // namespace boost namespace serialization BOOST_SERIALIZATION_SPLIT_FREE(RCF::ByteBuffer); namespace RCF { #endif // RCF_USE_BOOST_SERIALIZATION struct Void {}; namespace IDL { class InHeader { public: InHeader( ClientStub &clientStub, bool oneway, const std::string subInterface, int fnId) { RCF4_TRACE("encoding request") (clientStub.getTargetToken()) (clientStub.getTargetName()) (subInterface) (fnId); clientStub.setTries(0); clientStub.mRequest.init( clientStub.getTargetToken(), clientStub.getTargetName(), subInterface, fnId, clientStub.getSerializationProtocol(), oneway, false, clientStub.getRcfRuntimeVersion(), false); clientStub.mOut.reset( clientStub.getSerializationProtocol(), 32, clientStub.mRequest.encodeRequestHeader()); } }; // TODO: with vc6, mT may be uninitialized if primitive. Probably harmless. template class InParameter_Value { public: BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference > )); InParameter_Value(const T &t, SerializationProtocolOut &out) : mT() { serialize(out, t); } InParameter_Value(SerializationProtocolIn &in) : mT() { deserialize(in, mT); } const T &get() { return mT; } private: T mT; }; template class InParameter_Enum { public: BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference > )); // initializer list oddity, due to vc71 breakage on enums InParameter_Enum(const T &t, SerializationProtocolOut &out) : mT( T()) { serialize(out, t); } // initializer list oddity, due to vc71 breakage on enums InParameter_Enum(SerializationProtocolIn &in) : mT( T()) { deserialize(in, mT); } const T &get() { return mT; } private: T mT; }; template class InParameter_Ptr { public: typedef typename RemovePointer::type T; typedef typename RemoveCv::type U; BOOST_MPL_ASSERT(( IsPointer )); BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); InParameter_Ptr(T *pt, SerializationProtocolOut &out) { serialize(out, pt); } InParameter_Ptr(SerializationProtocolIn &in) { U *pu = NULL; deserialize(in, pu); boost::shared_ptr *ppu = in.mPointerContext.get( (boost::shared_ptr **) NULL, pu); if (ppu == NULL) { mUPtr = boost::shared_ptr(pu); in.mPointerContext.set( &mUPtr, pu); } else { mUPtr = *ppu; } } T *get() { return mUPtr.get(); } private: boost::shared_ptr mUPtr; }; template class InParameter_Ref { public: typedef typename RemoveReference::type T; typedef typename RemoveCv::type U; BOOST_MPL_ASSERT(( IsReference )); BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); InParameter_Ref(const U &u, SerializationProtocolOut &out) { serialize(out, &u); } InParameter_Ref(SerializationProtocolIn &in) { U *pu = NULL; deserialize(in, pu); boost::shared_ptr *ppu = in.mPointerContext.get( (boost::shared_ptr**) NULL, pu); if (ppu == NULL) { mUPtr = boost::shared_ptr(pu); // TODO: this is only safe if lifetime of in <= lifetime of this! in.mPointerContext.set( &mUPtr, pu); } else { mUPtr = *ppu; } } T &get() { return *mUPtr; } private: boost::shared_ptr mUPtr; }; template class OutParameter_Value { public: BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference > )); OutParameter_Value(const T &, SerializationProtocolIn &, bool oneway, bool retry) { RCF_UNUSED_VARIABLE(oneway); RCF_UNUSED_VARIABLE(retry); } template OutParameter_Value(InParameter_Value< V > &, SerializationProtocolOut &) {} template OutParameter_Value(InParameter_Enum< V > &, SerializationProtocolOut &) {} }; template class OutParameter_Enum { public: BOOST_MPL_ASSERT(( boost::mpl::not_< boost::is_pointer > )); BOOST_MPL_ASSERT(( boost::mpl::not_< boost::is_reference > )); OutParameter_Enum(const T &, SerializationProtocolIn &, bool oneway, bool retry) { RCF_UNUSED_VARIABLE(oneway); RCF_UNUSED_VARIABLE(retry); } template OutParameter_Enum(InParameter_Enum< V > &, SerializationProtocolOut &) {} }; template class OutParameter_Ptr { public: typedef typename RemovePointer::type T; // TODO: is this innocuous? #ifndef __BORLANDC__ BOOST_MPL_ASSERT(( IsPointer )); #endif BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); OutParameter_Ptr(const T *t, SerializationProtocolIn &in, bool oneway, bool retry) { RCF_UNUSED_VARIABLE(t); RCF_UNUSED_VARIABLE(in); RCF_UNUSED_VARIABLE(oneway); RCF_UNUSED_VARIABLE(retry); } template OutParameter_Ptr(InParameter_Ptr< V > &v, SerializationProtocolOut &out) { RCF_UNUSED_VARIABLE(v); RCF_UNUSED_VARIABLE(out); } }; template class OutParameter_CRef { public: typedef typename RemoveReference::type CT; typedef typename RemoveCv::type T; BOOST_MPL_ASSERT(( IsReference )); // TODO: is this innocuous? #ifndef __BORLANDC__ BOOST_MPL_ASSERT(( IsConst )); #endif BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); OutParameter_CRef(const T &t, SerializationProtocolIn &in, bool oneway, bool retry) { RCF_UNUSED_VARIABLE(t); RCF_UNUSED_VARIABLE(in); RCF_UNUSED_VARIABLE(oneway); RCF_UNUSED_VARIABLE(retry); } template OutParameter_CRef(InParameter_Ref< V > &v, SerializationProtocolOut &out) { RCF_UNUSED_VARIABLE(v); RCF_UNUSED_VARIABLE(out); } }; template class OutParameter_Ref { public: typedef typename RemoveReference::type T; BOOST_MPL_ASSERT(( IsReference )); BOOST_MPL_ASSERT(( boost::mpl::not_< IsConst > )); BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); OutParameter_Ref(T &t, SerializationProtocolIn &in, bool oneway, bool retry) { if (!oneway && !retry) { deserialize(in, t); } } template OutParameter_Ref( InParameter_Ref< V > &v, SerializationProtocolOut &out) { serialize(out, v.get()); } }; template class OutReturnValue { public: // RCF interfaces cannot return naked pointers BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); // RCF interfaces cannot return references BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference > )); OutReturnValue(SerializationProtocolOut &out, const T &t) { serialize(out, t); } }; template<> class OutReturnValue { public: OutReturnValue(SerializationProtocolOut &out, int t) { RCF_UNUSED_VARIABLE(out); RCF_UNUSED_VARIABLE(t); } }; template class InReturnValue_Value { public: // RCF interfaces cannot return naked pointers BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer > )); // RCF interfaces cannot return references BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference > )); InReturnValue_Value( ClientStub &clientStub, SerializationProtocolIn &in, SerializationProtocolOut &out, bool oneway, bool &retry); T &get(); private: T mT; }; template<> class InReturnValue_Value { public: InReturnValue_Value( ClientStub &clientStub, SerializationProtocolIn &in, SerializationProtocolOut &out, bool oneway, bool &retry); Void get() { return Void(); } }; template class InReturnValue_Enum { public: // RCF interfaces cannot return naked pointers BOOST_MPL_ASSERT(( boost::mpl::not_< boost::is_pointer > )); // RCF interfaces cannot return references BOOST_MPL_ASSERT(( boost::mpl::not_< boost::is_reference > )); InReturnValue_Enum( ClientStub &clientStub, SerializationProtocolIn &in, SerializationProtocolOut &out, bool oneway, bool &retry); T &get(); private: T mT; }; template struct InParameter { typedef typename boost::mpl::if_< boost::is_pointer, InParameter_Ptr, typename boost::mpl::if_< boost::is_reference, InParameter_Ref, typename boost::mpl::if_< boost::is_enum, InParameter_Enum, InParameter_Value >::type >::type >::type type; }; template struct InReturnValue { typedef typename boost::mpl::if_< boost::is_enum, InReturnValue_Enum, InReturnValue_Value >::type type; }; #ifdef __BORLANDC__ template struct OutParameter { typedef OutParameter_Value type; }; template struct OutParameter { typedef OutParameter_Ptr type; }; template struct OutParameter { typedef OutParameter_CRef type; }; template struct OutParameter { typedef OutParameter_Ref type; }; #else template struct is_const_reference { typedef typename boost::mpl::and_< boost::is_reference, boost::is_const< typename boost::remove_reference::type > >::type type; enum { value = type::value }; }; template struct OutParameter { typedef typename boost::mpl::if_< boost::is_pointer, OutParameter_Ptr, typename boost::mpl::if_< is_const_reference, OutParameter_CRef, typename boost::mpl::if_< boost::is_reference, OutParameter_Ref, typename boost::mpl::if_< boost::is_enum, OutParameter_Enum, OutParameter_Value >::type >::type >::type >::type type; }; #endif } // namespace IDL // NB: using this instead of scope_guard,because Borland C++ is not triggering the scope_guard at all. // At least with this class, it's triggered in debug builds (but not release apparently). class ConnectionResetGuard { public: ConnectionResetGuard(ClientStub &clientStub) : mClientStub(clientStub), mDismissed(RCF_DEFAULT_INIT) {} void dismiss() { mDismissed = true; } ~ConnectionResetGuard() { RCF_DTOR_BEGIN if (!mDismissed) { mClientStub.disconnect(); } RCF_DTOR_END } private: ClientStub &mClientStub; bool mDismissed; }; // ClientMarshal #ifdef __BORLANDC__ #define RCF_TYPENAME #else #define RCF_TYPENAME typename #endif template class ClientMarshal_R0 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); if (!retry) return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; template class ClientMarshal_R1 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId, A1 a1) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InParameter< A1 >::type(a1, clientStub.mOut); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A1 >::type(a1, clientStub.mIn, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); if (!retry) return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; template class ClientMarshal_R2 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId, A1 a1, A2 a2) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InParameter< A1 >::type(a1, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A2 >::type(a2, clientStub.mOut); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A1 >::type(a1, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A2 >::type(a2, clientStub.mIn, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); if (!retry) return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; template class ClientMarshal_R3 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId, A1 a1, A2 a2, A3 a3) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InParameter< A1 >::type(a1, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A2 >::type(a2, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A3 >::type(a3, clientStub.mOut); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A1 >::type(a1, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A2 >::type(a2, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A3 >::type(a3, clientStub.mIn, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); if (!retry) return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; template class ClientMarshal_R4 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId, A1 a1, A2 a2, A3 a3, A4 a4) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InParameter< A1 >::type(a1, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A2 >::type(a2, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A3 >::type(a3, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A4 >::type(a4, clientStub.mOut); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A1 >::type(a1, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A2 >::type(a2, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A3 >::type(a3, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A4 >::type(a4, clientStub.mIn, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); if (!retry) return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; template class ClientMarshal_R5 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InParameter< A1 >::type(a1, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A2 >::type(a2, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A3 >::type(a3, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A4 >::type(a4, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A5 >::type(a5, clientStub.mOut); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A1 >::type(a1, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A2 >::type(a2, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A3 >::type(a3, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A4 >::type(a4, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A5 >::type(a5, clientStub.mIn, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); if (!retry) return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; template class ClientMarshal_R6 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InParameter< A1 >::type(a1, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A2 >::type(a2, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A3 >::type(a3, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A4 >::type(a4, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A5 >::type(a5, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A6 >::type(a6, clientStub.mOut); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A1 >::type(a1, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A2 >::type(a2, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A3 >::type(a3, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A4 >::type(a4, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A5 >::type(a5, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A6 >::type(a6, clientStub.mIn, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); if (!retry) return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; template class ClientMarshal_R7 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InParameter< A1 >::type(a1, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A2 >::type(a2, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A3 >::type(a3, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A4 >::type(a4, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A5 >::type(a5, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A6 >::type(a6, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A7 >::type(a7, clientStub.mOut); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A1 >::type(a1, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A2 >::type(a2, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A3 >::type(a3, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A4 >::type(a4, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A5 >::type(a5, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A6 >::type(a6, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A7 >::type(a7, clientStub.mIn, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); if (!retry) return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; template class ClientMarshal_R8 { public: R operator()(ClientStub &clientStub, RemoteCallSemantics rcs, const std::string &subInterface, int fnId, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const { bool oneway = (Oneway == rcs); ConnectionResetGuard connectionResetGuard(clientStub); try { while (true) { RCF_VERIFY(clientStub.getTries() < 2, Exception(RcfError_RepeatedRetries)); bool retry = false; RCF::IDL::InHeader(clientStub, oneway, subInterface, fnId); RCF_TYPENAME RCF::IDL::InParameter< A1 >::type(a1, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A2 >::type(a2, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A3 >::type(a3, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A4 >::type(a4, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A5 >::type(a5, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A6 >::type(a6, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A7 >::type(a7, clientStub.mOut); RCF_TYPENAME RCF::IDL::InParameter< A8 >::type(a8, clientStub.mOut); RCF_TYPENAME RCF::IDL::InReturnValue< R >::type ret(clientStub, clientStub.mIn, clientStub.mOut, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A1 >::type(a1, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A2 >::type(a2, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A3 >::type(a3, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A4 >::type(a4, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A5 >::type(a5, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A6 >::type(a6, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A7 >::type(a7, clientStub.mIn, oneway, retry); RCF_TYPENAME RCF::IDL::OutParameter< A8 >::type(a8, clientStub.mIn, oneway, retry); connectionResetGuard.dismiss(); clientStub.mIn.clearByteBuffer(); return ret.get(); } } catch (const RCF::RemoteException &) { connectionResetGuard.dismiss(); throw; } } }; #undef RCF_TYPENAME } // namespace RCF #include #endif // ! INCLUDE_RCF_MARSHAL_HPP