Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

RMI for C++

, 6 Aug 2009 CPOL
User-friendly remote method invocation in C++.
rcf.zip
RCF
demo
vs2003
RCF
Client
Server
doc
include
RCF
Connection.inl
Marshal.inl
Multiplexer.inl
RCF.inl
RcfServer.inl
ServerStub.inl
Protocol
util
Platform
Compiler
bcc55
cw80
gcc32
icl70
msvc71
Library
bcc55
cw80
gcc32
msvc60
msvc71
Machine
SPARC
x86
OS
Cygwin
Unix
Windows
System
NonWindows
Windows
Threads
SF
src
RCF
Protocol
util
SF
test
Jamfile
Jamrules
borland
Jamfile
Jamrules
vs2003
RCF
RCF
RCFTest
//*****************************************************************************
// RCF - Remote Call Framework
// Copyright (c) 2005, Jarl Lindrud.
// Contact: jlindrud@hotmail.com .
//
// Distributed under the so-called MIT license, see accompanying file license.txt.
//*****************************************************************************

#ifndef _RCF_CLIENTSTUB_HPP_
#define _RCF_CLIENTSTUB_HPP_

#include <string>
#include <memory>

#include <RCF/Token.hpp>
#include <RCF/Protocol/Protocol.hpp>

namespace RCF {

    class Connection;

    extern const int DefaultClientRecvTimeoutMs;

    class ClientStub
    {
    public:
        ClientStub();
        ClientStub(
            const std::string &ip, 
            int port, 
            int fd, 
            bool oneway,
            bool service,
            unsigned int recvTimeoutMs,
            const std::string &endpointName, 
            const std::string &objectName, 
            const std::string &interfaceName);
        ClientStub(const ClientStub &rhs);
        ClientStub &operator=(const ClientStub &rhs);
        virtual ~ClientStub();
        
        // TODO: a lot of these get/set functions should not be publicly available
        Token getToken() const;
        void setToken(Token token);

        std::string getObjectName() const { return objectName; }
        void setObjectName(const std::string &objectName) { this->objectName = objectName; }
        
        bool getOneway() const { return oneway; }
        void setOneway(bool oneway) { this->oneway = oneway; } // TODO: oneway should be immutable
        
        bool getService() const { return service; }
        void setService(bool service) { this->service = service; }

        unsigned int getRecvTimeoutMs() const { return recvTimeoutMs; }
        void setRecvTimeoutMs(unsigned int recvTimeoutMs) { this->recvTimeoutMs = recvTimeoutMs; }
        
        std::string getIp() const { return ip; }
        void setIp(const std::string &ip) { this->ip = ip; }

        int getPort() const { return port; }
        void setPort(int port) { this->port = port; }

        void setFd(int fd) { this->fd = fd; }
        int getFd() const { return fd; }

        void setProtocol(int protocol) { this->protocol = protocol; }
        int getProtocol() { return protocol; }

        Connection& getConnection();
        void setConnection( std::auto_ptr<Connection> connection );
        std::auto_ptr<Connection> releaseConnection();
        bool isConnected();

        template<typename Archive> void serialize(Archive &ar, const unsigned int)
        {
            ar & token
               & ip
               & port
               & oneway 
               & service 
               & recvTimeoutMs 
               & protocol
               & endpointName 
               & objectName 
               & interfaceName;
        }

    private:
        Token token;
        std::string ip;
        int port;
        int fd;
        bool oneway;
        bool service;
        unsigned int recvTimeoutMs;
        int protocol;
        std::string endpointName;
        std::string objectName;
        std::string interfaceName;
        std::auto_ptr<Connection> connection;
    };

} // namespace RCF

#endif // ! _RCF_CLIENTSTUB_HPP_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jarl Lindrud

Australia Australia
Software developer, ex-resident of Sweden and now living in Canberra, Australia, working on distributed C++ applications. Jarl enjoys programming, but prefers skiing and playing table tennis. He derives immense satisfaction from referring to himself in third person.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141216.1 | Last Updated 6 Aug 2009
Article Copyright 2005 by Jarl Lindrud
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid