Cinder  0.9.1
Public Types | List of all members
cinder::signals::Signal< Signature, Collector > Struct Template Reference

#include <Signals.h>

Inherits cinder::signals::detail::SignalProto< Signature, Collector >.

Public Types

typedef detail::SignalProto< Signature, Collector > SignalProto
 
typedef SignalProto::CallbackFn CallbackFn
 

Detailed Description

template<typename Signature, class Collector = detail::CollectorDefault<typename std::function<Signature>::result_type>>
struct cinder::signals::Signal< Signature, Collector >

Signal is a template type providing an interface for arbitrary callback lists.

A signal type is declared with the function signature of its callbacks, and optionally a return result collector class type. The callbacks of a signal are invoked with the emit() method and arguments according to the signature.

The result returned by emit() depends on the signal collector class. By default, the result of the last callback is returned from emit(). Collectors can be implemented to accumulate callback results or to halt the running emissions in correspondance to callback results.

You can control the order in which callbacks are connected by providing a priority int as the first argument to connect(). A higher priority means the callback will happen sooner in the emission chain. Callbacks within the same emission group will be called according to the order they were connected, first in first out. By default all connected slots will be assigned to the priority group 0, e.g. you call connect() with no priority argument. This also means by default, when no priority groups are used then whatever callback is connected first to a signal will be called first.

To disconnect a slot, you use the Connection class returned from the connect() methods. You can also capture a ScopedConnection from connect(), which will automatically disconnect when it goes out of scope.

The signal implementation is safe against recursion, so callbacks may be connected and disconnected during a signal emission. Recursive emit() calls are also safe.

Note
Signals are non-copyable.

Member Typedef Documentation

template<typename Signature, class Collector = detail::CollectorDefault<typename std::function<Signature>::result_type>>
typedef detail::SignalProto<Signature, Collector> cinder::signals::Signal< Signature, Collector >::SignalProto
template<typename Signature, class Collector = detail::CollectorDefault<typename std::function<Signature>::result_type>>
typedef SignalProto::CallbackFn cinder::signals::Signal< Signature, Collector >::CallbackFn

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