template class Poco::NObserver

Overview

This template class implements an adapter that sits between a NotificationCenter and an object receiving notifications from it. Moreā€¦

#include <NObserver.h>

template <
    class C,
    class N
    >
class NObserver: public Poco::AbstractObserver
{
public:
    // typedefs

    typedef AutoPtr<N> NotificationPtr;
    typedef void(C::* Callback)(const NotificationPtr &);

    // construction

    NObserver(
        C& object,
        Callback method
        );

    NObserver(const NObserver& observer);

    // methods

    NObserver&
    operator=(const NObserver& observer);

    virtual
    void
    notify(Notification* pNf) const;

    virtual
    bool
    equals(const AbstractObserver& abstractObserver) const;

    virtual
    bool
    accepts(Notification* pNf) const;

    virtual
    AbstractObserver*
    clone() const;

    virtual
    void
    disable();
};

Inherited Members

public:
    // methods

    AbstractObserver&
    operator=(const AbstractObserver& observer);

    virtual
    void
    notify(Notification* pNf) const = 0;

    virtual
    bool
    equals(const AbstractObserver& observer) const = 0;

    virtual
    bool
    accepts(Notification* pNf) const = 0;

    virtual
    AbstractObserver*
    clone() const = 0;

    virtual
    void
    disable() = 0;

Detailed Documentation

This template class implements an adapter that sits between a NotificationCenter and an object receiving notifications from it.

It is quite similar in concept to the RunnableAdapter, but provides some NotificationCenter specific additional methods. See the NotificationCenter class for information on how to use this template class.

This class template is quite similar to the Observer class template. The only difference is that the NObserver expects the callback function to accept a const AutoPtr & instead of a plain pointer as argument, thus simplifying memory management.