template class Poco::DefaultStrategy

Overview

Default notification strategy. Moreā€¦

#include <DefaultStrategy.h>

template <
    class TArgs,
    class TDelegate
    >
class DefaultStrategy: public Poco::NotificationStrategy
{
public:
    // typedefs

    typedef TDelegate* DelegateHandle;
    typedef SharedPtr<TDelegate> DelegatePtr;
    typedef std::vector<DelegatePtr> Delegates;
    typedef Delegates::iterator Iterator;

    // construction

    DefaultStrategy();
    DefaultStrategy(const DefaultStrategy& s);

    // methods

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

    virtual
    DelegateHandle
    add(const TDelegate& delegate);

    virtual
    void
    remove(const TDelegate& delegate);

    virtual
    void
    remove(DelegateHandle delegateHandle);

    DefaultStrategy&
    operator=(const DefaultStrategy& s);

    virtual
    void
    clear();

    virtual
    bool
    empty() const;

protected:
    // fields

    Delegates _delegates;
};

// direct descendants

template <
    class TArgs,
    class TDelegate
    >
class FIFOStrategy;

Inherited Members

public:
    // typedefs

    typedef TDelegate* DelegateHandle;

    // methods

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

    virtual
    DelegateHandle
    add(const TDelegate& delegate) = 0;

    virtual
    void
    remove(const TDelegate& delegate) = 0;

    virtual
    void
    remove(DelegateHandle delegateHandle) = 0;

    virtual
    void
    clear() = 0;

    virtual
    bool
    empty() const = 0;

Detailed Documentation

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.

Methods

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

Sends a notification to all registered delegates.

virtual
DelegateHandle
add(const TDelegate& delegate)

Adds a delegate to the strategy.

virtual
void
remove(const TDelegate& delegate)

Removes a delegate from the strategy, if found.

Does nothing if the delegate has not been added.

virtual
void
remove(DelegateHandle delegateHandle)

Removes a delegate from the strategy, if found.

Does nothing if the delegate has not been added.

virtual
void
clear()

Removes all delegates from the strategy.

virtual
bool
empty() const

Returns false if the strategy contains at least one delegate.