//*****************************************************************************
// RCF - Remote Call Framework
// Copyright (c) 2005. All rights reserved.
// Developed by Jarl Lindrud.
// Contact: jlindrud@hotmail.com .
//*****************************************************************************
#ifndef INCLUDE_RCF_RCFCLIENT_HPP
#define INCLUDE_RCF_RCFCLIENT_HPP
#include <boost/mpl/bool_fwd.hpp>
#include <boost/shared_ptr.hpp>
#include <RCF/ServerStub.hpp>
#include <SF/SfNew.hpp>
#include <RCF/CheckRtti.hpp>
namespace RCF {
class ClientStub;
class ServerStub;
/// Base class of all RcfClient<> templates.
class I_RcfClient
{
public:
/// Virtual destructor.
virtual ~I_RcfClient() {}
/// Returns a reference to the contained client stub, if one is available, i.e. if the RcfClient<> template is configured as a client stub.
virtual ClientStub &getClientStub() = 0;
/// Returns a reference to the contained server stub, if one is available, i.e. if the RcfClient<> template is configured as a server stub.
virtual ServerStub &getServerStub() = 0;
};
typedef boost::shared_ptr<I_RcfClient> RcfClientPtr;
//SF_NO_CTOR(I_RcfClient)
//template<typename Archive>
//void serialize(Archive &archive, I_RcfClient &rcfClient, const unsigned int)
//{
//archive & rcfClient.getClientStub();
//}
// some meta-programming functionality needed by the macros in IDL.hpp
#ifndef __BORLANDC__
typedef char (&yes_type)[1];
typedef char (&no_type)[2];
template<typename U> static yes_type HasRcfClient_helper(typename U::RcfClient *);
template<typename U> static no_type HasRcfClient_helper(...);
template<typename T>
struct HasRcfClient
{
typedef typename boost::mpl::bool_<sizeof(yes_type) == sizeof(HasRcfClient_helper<T>(0))> type;
};
template<typename T, typename U>
struct GetRcfClient;
template<typename U>
struct GetRcfClient<boost::mpl::true_, U>
{
typedef typename U::RcfClient type;
};
template<typename U>
struct GetRcfClient<boost::mpl::false_, U>
{
typedef U type;
};
template<typename T>
struct ToDeriveFrom
{
typedef typename GetRcfClient< typename HasRcfClient<T>::type, T >::type type;
};
#endif
template<typename T, typename U>
class RegisterInvokeFunctors;
template<typename U>
class RegisterInvokeFunctors<boost::mpl::true_, U>
{
public:
template<typename V, typename DerefPtrT>
void operator()(V &v, InvokeFunctorMap &invokeFunctorMap, DerefPtrT derefPtr)
{
typedef typename U::RcfClient Parent;
//v.RcfClient::registerInvokeFunctors(invokeFunctorMap, derefPtr);
StubAccess().registerParentInvokeFunctors<Parent>(v, invokeFunctorMap, derefPtr);
}
};
template<typename U>
class RegisterInvokeFunctors<boost::mpl::false_, U>
{
public:
template<typename V, typename DerefPtrT>
void operator()(V &v, InvokeFunctorMap &invokeFunctorMap, DerefPtrT derefPtr)
{}
};
template<typename T>
class Dummy
{};
} // namespace RCF
#endif // ! INCLUDE_RCF_RCFCLIENT_HPP