Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Signal Namespace Reference

Namespaces

 Lib
 

Classes

struct  Signal
 Signal is a template type providing an interface for arbitrary callback lists. A signal type needs to be declared with the function signature of its callbacks, and optionally a return result collector class type. Signal callbacks can be added with operator+= to a signal and removed with operator-=, using a callback connection ID return by operator+= as argument. 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 a running emissions in correspondance to callback results. The signal implementation is safe against recursion, so callbacks may be removed and added during a signal emission and recursive emit() calls are also safe. The overhead of an unused signal is intentionally kept very low, around the size of a single pointer. Note that the Signal template types is non-copyable. More...
 

Functions

template<class instance , class Class , class R , class... Args>
std::function< R(Args...)> slot (instance &object, R(Class::*method)(Args...))
 This function creates a std::function by binding object to the member function pointer method. More...
 
template<class Class , class R , class... Args>
std::function< R(Args...)> slot (Class *object, R(Class::*method)(Args...))
 This function creates a std::function by binding object to the member function pointer method. More...
 

Function Documentation

◆ slot() [1/2]

template<class Class , class R , class... Args>
std::function<R(Args...)> Signal::slot ( Class *  object,
R(Class::*)(Args...)  method 
)

This function creates a std::function by binding object to the member function pointer method.

Definition at line 173 of file Signal.hxx.

174 {
175  return [object, method](Args... args) { return (object->*method)(args...); };
176 }

◆ slot() [2/2]

template<class instance , class Class , class R , class... Args>
std::function<R(Args...)> Signal::slot ( instance &  object,
R(Class::*)(Args...)  method 
)

This function creates a std::function by binding object to the member function pointer method.

Definition at line 167 of file Signal.hxx.

168 {
169  return [&object, method](Args... args) { return (object.*method)(args...); };
170 }
+ Here is the caller graph for this function: