Poco

template < class TArgs, class TDelegate >

class DefaultStrategy

Library: Foundation
Package: Events
Header: Poco/DefaultStrategy.h

Description

Default notification strategy.

Internally, a std::vector<> is used to store delegate objects. Delegates are invoked in the order in which they have been registered.

Inheritance

Direct Base Classes: NotificationStrategy < TArgs, TDelegate >

All Base Classes: NotificationStrategy < TArgs, TDelegate >

Member Summary

Member Functions: add, clear, detach, detachAll, empty, notify, operator =, remove

Types Aliases

DelegateHandle

using DelegateHandle = TDelegate *;

DelegatePtr

using DelegatePtr = SharedPtr < TDelegate >;

Delegates

using Delegates = std::vector < DelegatePtr >;

Iterator

using Iterator = typename Delegates::iterator;

Constructors

DefaultStrategy

DefaultStrategy() = default;

DefaultStrategy inline

DefaultStrategy(
    const DefaultStrategy & s
);

Destructor

~DefaultStrategy

~DefaultStrategy() = default;

Member Functions

add inline

DelegateHandle add(
    const TDelegate & delegate
);

clear inline

void clear();

detach inline

DelegatePtr detach(
    const TDelegate & delegate
);

Removes a matching delegate from the internal list without disabling it, and returns the detached delegate (or an empty DelegatePtr if no match). The caller is responsible for calling disable() on the returned delegate. This separation allows AbstractEvent to call disable() outside its own mutex, breaking the lock-order edge M_event -> M_delegate.

detach inline

DelegatePtr detach(
    DelegateHandle delegateHandle
);

detachAll inline

Delegates detachAll();

Removes all delegates from the internal list without disabling them, and returns them so the caller can call disable() outside its mutex. See detach().

empty inline

bool empty() const;

notify inline

void notify(
    const void * sender,
    TArgs & arguments
);

operator = inline

DefaultStrategy & operator = (
    const DefaultStrategy & s
);

remove inline

void remove(
    const TDelegate & delegate
);

remove inline

void remove(
    DelegateHandle delegateHandle
);

Variables

_delegates protected

Delegates _delegates;