Turi Create  4.0
C++ Interprocess Communication Library

Namespaces

 cppipc
 

Classes

struct  cppipc::detail::deserialize_return_and_clear< RetType, is_proxied_object >
 
class  cppipc::comm_client
 
struct  cppipc::detail::issue_disect< ArgumentTuple, Args >
 
struct  cppipc::detail::issue_disect< std::tuple<>, Args... >
 
class  cppipc::object_proxy< T >
 
struct  cppipc::call_message
 
struct  cppipc::reply_message
 
class  cppipc::object_factory_base
 
class  cppipc::object_factory_impl
 
class  cppipc::object_factory_proxy
 
class  cppipc::comm_server
 
struct  cppipc::dispatch
 
struct  cppipc::detail::exec_and_serialize_response< RetType, T, MemFn, Args >
 
struct  cppipc::detail::exec_and_serialize_response< void, T, MemFn, Args... >
 
struct  cppipc::detail::execute_disect< T, Memfn, ArgumentTuple, Args >
 
struct  cppipc::detail::execute_disect< T, Memfn, std::tuple<>, Args... >
 
struct  cppipc::detail::execute_disect_call< T, Memfn >
 
struct  cppipc::dispatch_impl< T, MemFn >
 
struct  cppipc::function_args_to_tuple< Fn >
 
struct  cppipc::left_shift_tuple< std::tuple< T, Ts... > >
 

Macros

#define GENERATE_INTERFACE(base_name, proxy_name, functions)
 
#define GENERATE_PROXY(base_name, proxy_name, functions)
 
#define GENERATE_INTERFACE_AND_PROXY(base_name, proxy_name, functions)
 
#define REGISTRATION_BEGIN(name)
 

Enumerations

enum  cppipc::reply_status : size_t {
  cppipc::reply_status::OK, cppipc::reply_status::BAD_MESSAGE, cppipc::reply_status::NO_OBJECT, cppipc::reply_status::NO_FUNCTION,
  cppipc::reply_status::COMM_FAILURE, cppipc::reply_status::AUTH_FAILURE, cppipc::reply_status::IO_ERROR, cppipc::reply_status::MEMORY_ERROR,
  cppipc::reply_status::INDEX_ERROR, cppipc::reply_status::TYPE_ERROR, cppipc::reply_status::EXCEPTION
}
 

Functions

template<typename MemFn , typename... Args>
void cppipc::issue (turi::oarchive &msg, MemFn fn, const Args &... args)
 
std::string cppipc::reply_status_to_string (reply_status)
 
template<typename MemFn >
dispatchcppipc::create_dispatch (MemFn memfn)
 

Detailed Description

Macro Definition Documentation

◆ GENERATE_INTERFACE

#define GENERATE_INTERFACE (   base_name,
  proxy_name,
  functions 
)
Value:
class base_name : public cppipc::ipc_object_base { \
public: \
typedef proxy_name proxy_object_type; \
inline virtual ~base_name() { } \
inline virtual void save(turi::oarchive& oarc) const {} \
inline virtual void load(turi::iarchive& iarc) {} \
BOOST_PP_SEQ_FOR_EACH(__GENERATE_BASE__, _, __ADD_PARENS__(functions)) \
REGISTRATION_BEGIN(base_name) \
BOOST_PP_SEQ_FOR_EACH(__GENERATE_REGISTRATION__, base_name, __ADD_PARENS__(functions)) \
REGISTRATION_END \
};
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
Definition: iarchive.hpp:60
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.
Definition: oarchive.hpp:80

Magic Interface generating macro. Like GENERATE_INTERFACE_AND_PROXY but only generates the interface.

To use, call with the 1st argument as the base name of the interface, and the 2nd argument as a sequence of:

(return_type, function_name, (arg1type)(arg2type)(arg3type))

To get a function with no arguments simply have an empty 3rd argument. (the 3rd argument is still needed. Observe the comma. It is just empty.)

(return_type, function_name, )

For instance,

GENERATE_INTERFACE(object_base, object_proxy,
(std::string, ping, (std::string))
(int, add_one, (int))
(int, add, (int)(int))
)

will create a base class called object_base with 3 functions, ping, add_one, and add, with the appropriate registration functions.

The above macro generates the following code:

class object_base : public cppipc::ipc_object_base{
public:
typedef object_proxy proxy_object_type;
virtual ~object_base() { }
virtual std::string ping(std::string) = 0;
virtual int add_one(int) = 0;
virtual int add_one(int, int) = 0;
virtual void save(turi::oarchive& oarc) const {}
virtual void load(turi::iarchive& iarc) {}
REGISTRATION_BEGIN(test_object_base)
REGISTER(test_object_base::ping)
REGISTER(test_object_base::add)
REGISTER(test_object_base::add_one)
REGISTRATION_END
};

Definition at line 106 of file magic_macros.hpp.

◆ GENERATE_INTERFACE_AND_PROXY

#define GENERATE_INTERFACE_AND_PROXY (   base_name,
  proxy_name,
  functions 
)
Value:
class proxy_name; \
GENERATE_INTERFACE(base_name, proxy_name, functions) \
GENERATE_PROXY(base_name, proxy_name, functions)

Magic Interface and proxy generating macro.

To use, call with the 1st argument as the base name of the interface, the 2nd argument as the name of the proxy class, and the 3nd argument as a sequence of:

(return_type, function_name, (arg1type)(arg2type)(arg3type))

To get a function with no arguments simply have an empty 3rd argument. (the 3rd argument is still needed. Observe the comma. It is just empty.)

(return_type, function_name, )

For instance,

GENERATE_INTERFACE_AND_PROXY(object_base, object_proxy,
(std::string, ping, (std::string))
(int, add_one, (int))
(int, add, (int)(int))
)

will create a base class called object_base with 3 functions, ping, add_one, and add, with the appropriate registration functions, as well as a proxy object with the appropriate proxy forwarding calls.

The above macro generates all of the following code:

class proxy_object_type;
class object_base : public cppipc::ipc_object_base {
public:
typedef object_proxy proxy_object_type;
virtual inline ~object_base() { }
virtual std::string ping(std::string) = 0;
virtual int add_one(int) = 0;
virtual int add_one(int, int) = 0;
virtual void save(turi::oarchive& oarc) const {}
virtual void load(turi::iarchive& iarc) {}
REGISTRATION_BEGIN(test_object_base)
REGISTER(test_object_base::ping)
REGISTER(test_object_base::add)
REGISTER(test_object_base::add_one)
REGISTRATION_END
};
class object_proxy : public object_base {
public:
inline test_object_proxy(cppipc::comm_client& comm,
bool auto_create = true,
size_t object_id = (size_t)(-1)):
proxy(comm, auto_create, object_id){ }
inline std::string ping(std::string arg_0) {
return proxy.call(&object_base::ping, arg_0)
}
inline int add_one(int arg_0) {
return proxy.call(&object_base::add_one, arg_0)
}
inline int add(int arg_0, int arg_1) {
return proxy.call(&object_base::add, arg_0 , arg_1);
}
inline void save(turi::oarchive& oarc) const {
oarc << proxy.get_object_id();
}
inline void load(turi::iarchive& iarc) {
size_t objid; iarc >> objid;
proxy.set_object_id(objid);
}
};

Definition at line 293 of file magic_macros.hpp.

◆ GENERATE_PROXY

#define GENERATE_PROXY (   base_name,
  proxy_name,
  functions 
)
Value:
class proxy_name : public base_name { \
public: \
cppipc::object_proxy<base_name> proxy; \
inline proxy_name(cppipc::comm_client& comm, \
bool auto_create = true, \
size_t object_id = (size_t)(-1)): \
proxy(comm, auto_create, object_id){ } \
inline void save(turi::oarchive& oarc) const { \
oarc << proxy.get_object_id(); \
} \
inline size_t __get_object_id() const { \
return proxy.get_object_id(); \
} \
inline void load(turi::iarchive& iarc) { \
size_t objid; iarc >> objid; \
proxy.set_object_id(objid); \
} \
BOOST_PP_SEQ_FOR_EACH(__GENERATE_PROXY_CALLS__, base_name, __ADD_PARENS__(functions)) \
};
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
Definition: iarchive.hpp:60
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.
Definition: oarchive.hpp:80

Magic proxy generating macro.

Like GENERATE_INTERFACE_AND_PROXY but only generates the proxy.

To use, call with the 1st argument as the base name of the interface, the 2nd argument as the name of the proxy class, and the 3nd argument as a sequence of:

(return_type, function_name, (arg1type)(arg2type)(arg3type))

To get a function with no arguments simply have an empty 3rd argument. (the 3rd argument is still needed. Observe the comma. It is just empty.)

(return_type, function_name, )

For instance,

GENERATE_PROXY(object_base, object_proxy,
(std::string, ping, (std::string))
(int, add_one, (int))
(int, add, (int)(int))
)

will create a base class called object_base with 3 functions, ping, add_one, and add, with the appropriate registration functions, as well as a proxy object with the appropriate proxy forwarding calls.

The above macro generates all of the following code:

class object_proxy : public object_base {
public:
inline test_object_proxy(cppipc::comm_client& comm,
bool auto_create = true,
size_t object_id = (size_t)(-1)):
proxy(comm, auto_create, object_id){ }
inline test_object_proxy(cppipc::comm_client& comm):proxy(comm){ }
inline std::string ping(std::string arg_0) {
return proxy.call(&object_base::ping, arg_0)
}
inline int add_one(int arg_0) {
return proxy.call(&object_base::add_one, arg_0)
}
inline int add(int arg_0, int arg_1) {
return proxy.call(&object_base::add, arg_0 , arg_1);
}
inline void save(turi::oarchive& oarc) const {
oarc << proxy.get_object_id();
}
inline void load(turi::iarchive& iarc) {
size_t objid; iarc >> objid;
proxy.set_object_id(objid);
}
};

Definition at line 184 of file magic_macros.hpp.

◆ REGISTRATION_BEGIN

#define REGISTRATION_BEGIN (   name)
Value:
static inline std::string __get_type_name__() { \
return #name; \
} \
template <typename Registry> \
static inline void __register__(Registry& reg) {

Macros which help member function registration for IPC objects. For instance, given the following base class which we would like to export.

class object_base: public cppipc::ipc_object_base {
public:
virtual ~object_base() { }
virtual std::string ping(std::string) = 0;
virtual int add_one(int) = 0;
virtual int add_one(int, int) = 0;
};

We simply introduce a REGISTRATION_BEGIN inside the public section of the object, and call REGISTER once for each member function to export. The result object definition is as follows:

class object_base {
public:
virtual ~object_base() { }
virtual std::string ping(std::string) = 0;
virtual int add_one(int) = 0;
virtual int add_one(int, int) = 0;
REGISTRATION_BEGIN(object_base) // argument is a name which must
// uniquely identify the object
REGISTER(object_base::ping)
REGISTER(object_base::add)
REGISTER(object_base::add_one)
REGISTRATION_END
};

The registration macros adds 2 static functions. The first function is

static inline std::string __get_type_name__() {
return name;
}

Where "name" is the argument provided to REGISTRATION_BEGIN macro. This name is used for object creation and must uniquely identify the type of the object.

The second function is

template <typename Registry>
static inline void __register__(Registry& reg) {
reg.register_function(&object_base::ping, "object_base::ping");
reg.register_function(&object_base::add, "object_base::add");
reg.register_function(&object_base::add_one, "object_base::add_one");
}

and is used by both the client side and the server side to identify and name the member functions available.

See also
GENERATE_INTERFACE
GENERATE_INTERFACE_AND_PROXY

Definition at line 69 of file registration_macros.hpp.

Enumeration Type Documentation

◆ reply_status

enum cppipc::reply_status : size_t
strong

The reply status.

Enumerator
OK 

Call was successful.

BAD_MESSAGE 

The object requested did not exist.

NO_OBJECT 

The object requested did not exist.

NO_FUNCTION 

The function requested did not exist.

COMM_FAILURE 

Communication error.

AUTH_FAILURE 

Authentication failure.

IO_ERROR 

IO Error.

MEMORY_ERROR 

Memory Error.

INDEX_ERROR 

Index Error.

TYPE_ERROR 

Type Error.

EXCEPTION 

Other general exception. Body will contain the exception message.

Definition at line 79 of file message_types.hpp.

Function Documentation

◆ create_dispatch()

template<typename MemFn >
dispatch* cppipc::create_dispatch ( MemFn  memfn)

Creates a dispatch object which wraps a given member function.

Definition at line 174 of file dispatch_impl.hpp.

◆ issue()

template<typename MemFn , typename... Args>
void cppipc::issue ( turi::oarchive msg,
MemFn  fn,
const Args &...  args 
)

Casts the arguments into the required types for the member function and serializes it into the output archive

Definition at line 79 of file issue.hpp.

◆ reply_status_to_string()

std::string cppipc::reply_status_to_string ( reply_status  )

Generates a printable string version of the a reply_status