//****************************************************************************** // 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_METHODINVOCATION_HPP #define INCLUDE_RCF_METHODINVOCATION_HPP #include #include #include #include #include #include namespace RCF { class RcfServer; class StubEntry; typedef boost::shared_ptr StubEntryPtr; class RcfSession; typedef boost::shared_ptr RcfSessionPtr; class SerializationProtocolIn; class SerializationProtocolOut; class MethodInvocationResponse; // message types static const int Descriptor_Error = 0; static const int Descriptor_Request = 1; static const int Descriptor_Response = 2; static const int Descriptor_FilteredPayload = 3; // encoding and decoding void encodeBool(bool value, std::vector &vec, std::size_t &pos); void encodeInt(int value, std::vector &vec, std::size_t &pos); void encodeString(const std::string &value, std::vector &vec, std::size_t &pos); void encodeBool(bool value, const ByteBuffer &byteBuffer, std::size_t &pos); void encodeInt(int value, const ByteBuffer &byteBuffer, std::size_t &pos); void encodeString(const std::string &value, const ByteBuffer &byteBuffer, std::size_t &pos); void decodeBool(bool &value, const ByteBuffer &byteBuffer, std::size_t &pos); void decodeInt(int &value, const ByteBuffer &byteBuffer, std::size_t &pos); void decodeString(std::string &value, const ByteBuffer &byteBuffer, std::size_t &pos); class MethodInvocationRequest { public: MethodInvocationRequest(); void init( const Token &token, const std::string &service, const std::string &subInterface, int fnId, int serializationProtocol, bool oneway, bool close, int rcfRuntimeVersion, bool ignoreRcfRuntimeVersion); Token getToken() const; std::string getSubInterface() const; int getFnId() const; bool getOneway() const; bool getClose() const; std::string getService() const; void setService(const std::string &service); ByteBuffer encodeRequestHeader(); void encodeRequest( const std::vector &byteBuffersIn, std::vector &byteBuffersOut, const std::vector &filters); bool decodeRequest( const ByteBuffer &byteBufferIn, RcfSessionPtr rcfSessionPtr, RcfServer &rcfServer); void encodeResponse( const std::vector &byteBuffersIn, std::vector &byteBuffersOut, const std::vector &filters, bool isException); void decodeResponse( const ByteBuffer &byteBufferIn, ByteBuffer &byteBufferOut, MethodInvocationResponse &response, const std::vector &filters); StubEntryPtr locateStubEntryPtr(RcfServer &rcfServer); private: void decodeFiltered( const ByteBuffer &encodedByteBuffer, ByteBuffer &byteBufferClear, ByteBuffer &byteBufferUnfiltered, RcfServer *pRcfServer, RcfSessionPtr rcfSessionPtr, const std::vector &filters); void encodeFiltered( std::vector &byteBuffersIn, const std::vector &byteBuffersOut, const std::vector &filters); Token mToken; std::string mSubInterface; int mFnId; int mSerializationProtocol; bool mOneway; bool mClose; std::string mService; int mRcfRuntimeVersion; bool mIgnoreRcfRuntimeVersion; boost::shared_ptr > mVecPtr; }; class MethodInvocationResponse { public: MethodInvocationResponse(); bool isException() const; bool isError() const; int getError() const; int getArg0() const; private: friend class MethodInvocationRequest; bool mException; bool mError; int mErrorCode; int mArg0; }; } // namespace RCF #endif // ! INCLUDE_RCF_METHODINVOCATION_HPP