siplasplas
A library for C++ reflection and introspection
cpp::SignalSink Class Referenceabstract

Interface to the signals sink API. More...

#include <siplasplas/signals/sink.hpp>

Inheritance diagram for cpp::SignalSink:
cpp::AsyncSink cpp::SyncSink

Public Member Functions

template<typename Caller , typename Callee >
 SignalSink (Caller &caller, Callee &callee)
 Constructs a sink given the connection caller and the callee. More...
 
template<typename Caller >
 SignalSink (Caller &caller)
 Constructs a sink given the connection caller object. More...
 
template<typename... Args>
void operator() (Args &&...args)
 Invokes the sink with the given arguments. More...
 
SignalEmittercallee () const
 Gives the callee of the connection. More...
 
SignalEmittercaller () const
 Gives the caller of the connection. More...
 
virtual bool pull ()=0
 

Protected Member Functions

virtual void invoke (std::vector< cpp::SimpleAny32 > &&args)=0
 
virtual bool invokeWithoutCallee () const =0
 

Detailed Description

Interface to the signals sink API.

A signal sink represents the destination of an emitted signal, that is, the action that should be invoked and how. Sinks keep track of the objects participating in a signal interchange (The source SignalEmitter and the destination object, if any). The interface provides two member functions to be overrided:

  • SignalSink::invoke(): Implements the behavior of the sink, that is, what is done when the source signal is emitted.
  • SignalSink::pull(): Implements the pull behavior of the sink, what should be done if the user of the connection explicitly asks for incoming signals.

Also the user must specify whether the sink should be invoked with ot without a callee object (See SignalSink::operator()() template). Callee (if any) is always the first argument of type erased invoke() function.

When an user invokes the signal, he/she does through the SignalSInk::invoke() template, which perfect forwards the signal arguments to the type erased protected functions above.

Constructor & Destructor Documentation

template<typename Caller , typename Callee >
cpp::SignalSink::SignalSink ( Caller &  caller,
Callee &  callee 
)
inline

Constructs a sink given the connection caller and the callee.

This constructor is used by child classes to initialize connection participants. Note the SignalSink is pure virtual.

Parameters
callerReference to the caller object. Caller must inherit SignalEmitter.
calleeReference to the callee object. Caller must inherit SignalEmitter.
template<typename Caller >
cpp::SignalSink::SignalSink ( Caller &  caller)
inline

Constructs a sink given the connection caller object.

This constructor is used by child classes to initialize connection caller. This constructor is used by connections with no associated callee (Such as connections invoking a lambda or a free function). Note the SignalSink is pure virtual.

Parameters
callerReference to the caller object. Caller must inherit SignalEmitter.

Member Function Documentation

SignalEmitter* cpp::SignalSink::callee ( ) const
inline

Gives the callee of the connection.

Returns
A pointer to the callee object if the connection has an associated callee. Throws in other case.
SignalEmitter* cpp::SignalSink::caller ( ) const
inline

Gives the caller of the connection.

Returns
A pointer to the caller object.
template<typename... Args>
void cpp::SignalSink::operator() ( Args &&...  args)
inline

Invokes the sink with the given arguments.

This function invokes the sink by type erasing the call arguments and passing them to SignalSink::invoke(). If neccesary (See SignalSink::invokeWithoutCallee()) it also passes a reference to the callee object first.

Parameters
argscall arguments.

The documentation for this class was generated from the following file: