Repository navigation
state_populating
A policy that defines how the populators and withdrawers work.
namespace state_populating
{
struct populator_only;
struct populator_and_withdrawer;
struct none;
}-
Supplied policies
- populator_only (default)
- populator_and_withdrawer
- none
- How to implement your own policy
A signal holds a populator std::function, which is invoked when connecting to a signal.
This is a default policy because you usually need a populator in mutithreaded code and rarely need a withdrawer. It is also an acceptable choice for a single-threaded code because the overhead is not that large.
A signal holds both populator and withdrawer std::functions, that are invoked when connecting to and disconnecting from a signal.
An empty policy. Best if you don't need state populating (e.g. in single-threaded environment) because it has no overhead.
struct my_state_populating
{
using tag = wigwag::state_populating::tag<wigwag::api_version<2, 0>>;
template < typename HandlerType_ >
struct handler_processor
{
bool has_populate_state() const { /*...*/ }
void populate_state(const HandlerType_& handler) const { /*...*/ }
bool has_withdraw_state() const { /*...*/ }
void withdraw_state(const HandlerType_& handler) const { /*...*/ }
};
};using tag = wigwag::state_populating::tag<wigwag::api_version<2, 0>>;The policy tag. Must be a type alias for wigwag::state_populating::tag<wigwag::api_version<2, 0>>.
template < typename HandlerType_ >
struct handler_processor;A handler_processor object is stored inside a signal.
Template arguments:
- HandlerType_ - the type of a handler (std::function<Signature_> for signal, ListenerType_ for listenable)
bool has_populate_state() const;Used to determine whether the populate_state method should be invoked
Return value: false if the populate_state method invokation may be omitted, true otherwise
void populate_state(const HandlerType_& handler) const;Invoked when a handler is being connected to a signal
Arguments:
- handler - the handler
bool has_withdraw_state() const;Used to determine whether the withdraw_state method should be invoked
Return value: false if the withdraw_state method invokation may be omitted, true otherwise
void withdraw_state(const HandlerType_& handler) const;Invoked when a handler is being disconnected from a signal
Arguments:
- handler - the handler