File: eventHandler.hxx - Tab length: 1 2 4 8 - Lines: on off - No wrap: on off


namespace   Pane
{
    /*
    ** Destroy event handler and all attached events (4 parameters)
    */

    template<typename Return, typename Param1, typename Param2, typename Param3, typename Param4>
    /**/                            EventHandler<Return, Param1, Param2, Param3, Param4>::~EventHandler ()
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            delete (*i);
    }

    /*
    ** Destroy event handler and all attached events (3 parameters)
    */

    template<typename Return, typename Param1, typename Param2, typename Param3>
    /**/                            EventHandler<Return, Param1, Param2, Param3>::~EventHandler ()
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            delete (*i);
    }

    /*
    ** Destroy event handler and all attached events (4 parameters)
    */

    template<typename Return, typename Param1, typename Param2>
    /**/                            EventHandler<Return, Param1, Param2>::~EventHandler ()
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            delete (*i);
    }

    /*
    ** Destroy event handler and all attached events (4 parameters)
    */

    template<typename Return, typename Param1>
    /**/                            EventHandler<Return, Param1>::~EventHandler ()
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            delete (*i);
    }

    /*
    ** Destroy event handler and all attached events (0 parameter)
    */

    template<typename Return>
    /**/                            EventHandler<Return>::~EventHandler ()
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            delete (*i);
    }

    /*
    ** Attach new event to handler (4 parameters)
    ** event:   event to attach
    */

    template<typename Return, typename Param1, typename Param2, typename Param3, typename Param4>
    void    EventHandler<Return, Param1, Param2, Param3, Param4>::operator += (EventClass* event)
    {
        this->events.push_back (event);
    }

    /*
    ** Attach new event to handler (4 parameters)
    ** event:   event to attach
    */

    template<typename Return, typename Param1, typename Param2, typename Param3>
    void    EventHandler<Return, Param1, Param2, Param3>::operator += (EventClass* event)
    {
        this->events.push_back (event);
    }

    /*
    ** Attach new event to handler (4 parameters)
    ** event:   event to attach
    */

    template<typename Return, typename Param1, typename Param2>
    void    EventHandler<Return, Param1, Param2>::operator += (EventClass* event)
    {
        this->events.push_back (event);
    }

    /*
    ** Attach new event to handler (1 parameter)
    ** event:   event to attach
    */

    template<typename Return, typename Param1>
    void    EventHandler<Return, Param1>::operator += (EventClass* event)
    {
        this->events.push_back (event);
    }

    /*
    ** Attach new event to handler (0 parameter)
    ** event:   event to attach
    */

    template<typename Return>
    void    EventHandler<Return>::operator += (EventClass* event)
    {
        this->events.push_back (event);
    }

    /*
    ** Call attached events (4 parameters)
    ** param1:  parameter #1
    ** param2:  parameter #2
    ** param3:  parameter #3
    ** param4:  parameter #4
    ** return:  true if at least one event was attached, false else
    */

    template<typename Return, typename Param1, typename Param2, typename Param3, typename Param4>
    bool                            EventHandler<Return, Param1, Param2, Param3, Param4>::operator () (Param1 param1, Param2 param2, Param3 param3, Param4 param4)
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            (**i) (param1, param2, param3, param4);

        return this->events.size () > 0;
    }

    /*
    ** Call attached events (3 parameters)
    ** param1:  parameter #1
    ** param2:  parameter #2
    ** param3:  parameter #3
    ** return:  true if at least one event was attached, false else
    */

    template<typename Return, typename Param1, typename Param2, typename Param3>
    bool                            EventHandler<Return, Param1, Param2, Param3>::operator () (Param1 param1, Param2 param2, Param3 param3)
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            (**i) (param1, param2, param3);

        return this->events.size () > 0;
    }

    /*
    ** Call attached events (2 parameters)
    ** param1:  parameter #1
    ** param2:  parameter #2
    ** return:  true if at least one event was attached, false else
    */

    template<typename Return, typename Param1, typename Param2>
    bool                            EventHandler<Return, Param1, Param2>::operator () (Param1 param1, Param2 param2)
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            (**i) (param1, param2);

        return this->events.size () > 0;
    }

    /*
    ** Call attached events (1 parameter)
    ** param1:  parameter #1
    ** return:  true if at least one event was attached, false else
    */

    template<typename Return, typename Param1>
    bool                            EventHandler<Return, Param1>::operator () (Param1 param1)
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            (**i) (param1);

        return this->events.size () > 0;
    }

    /*
    ** Call attached events (0 parameter)
    ** return:  true if at least one event was attached, false else
    */

    template<typename Return>
    bool                            EventHandler<Return>::operator () ()
    {
        typename Events::iterator   i;

        for (i = this->events.begin (); i != this->events.end (); ++i)
            (**i) ();

        return this->events.size () > 0;
    }
}