The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::Radio::oFono::Helpers::EventMgr - simple event manager

DESCRIPTION

Base class for classes which want be able to trigger events and want to delegate the event management.

METHODS

new

Constructs a new instance of a BDCtask. BDCtask is an abstract base class, so instantiating this class directly is prohibited.

Parameters:

This constructor expects a hash containing the named parameters:

ON_*

Event handler. See add_event for further details.

The value for this parameter can be either a code reference, then an event without a MEMO item is generated, or a hash reference with following items:

FUNC

Code reference to the callback routine.

MEMO

Memo given to the callback routine when event is triggered.

Supported events:

None by default - all added by derived classes ...

add_event

Adds an event to the list of actions to be executed when an event point is reached.

Parameters:

Expects following parameters in order of appearance:

string

The name of the event for this callback

coderef

Specifies a code reference which should be called when the event is triggered. The parameters passed to the callback are:

  • $memo when specified

  • $event_mgr

  • $event_name

  • $event_info when given

Whereby the first parameter is the MEMO parameter specified here and it's omitted when not specified. The fourth parameter is an optional information field given by the triggering routine.

scalar

Specifies a scalar which will be given as first argument to the callback function which is specified with FUNC.

Return values:

This method returns $self.

add_events(%)

Runs add_event for each key => value pair given.

remove_event

Removed a previously added event handler from the list of actions to be executed when an event point is reached.

Parameters:

Expects following parameters in order of appearance:

string

The name of the event for this callback.

coderef

Specifies a code reference which should be called when the event is triggered. The parameters passed to the callback are:

  • $memo when specified

set_event

Sets the list of actions to be executed when an event point is reached to a list containing just the specified event callback.

Any previously set or added event notification callback is silently discarded.

Parameters:

Expects following parameters in order of appearance:

string

The name of the event for this callback

coderef

Specifies a code reference which should be called when the event is triggered. The parameters passed to the callback are:

  • $memo when specified

  • $event_mgr

  • $event_name

  • $event_info when given

Whereby the first parameter is the MEMO parameter specified here and it's omitted when not specified. The fourth parameter is an optional information field given by the triggering routine.

scalar

Specifies a scalar which will be given as first argument to the callback function which is specified with FUNC.

Return values:

This method returns $self.

trigger_event

The event method handles the triggering of events. Every notification callback noted for an event is invoked when the event is triggered first time.

When an event is tried to be triggered twice, an exception is thrown to tell, it's forbidden.

Parameter:

string

The name of the event which should be triggered.

Return values:

This method returns $self.

Note:

It's strongly prohibited to override this method in derived classes. The expected behaviour may change without notification to the authors or maintainers of derived classes.

BUGS

Please report any bugs or feature requests to bug-net-radio-ofono at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Radio-oFono. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

If you think you've found a bug then please read "How to Report Bugs Effectively" by Simon Tatham: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Net::Radio::oFono

You can also look for information at:

Where can I go for help with a concrete version?

Bugs and feature requests are accepted against the latest version only. To get patches for earlier versions, you need to get an agreement with a developer of your choice - who may or not report the issue and a suggested fix upstream (depends on the license you have chosen).

Business support and maintenance

For business support you can contact Jens via his CPAN email address rehsackATcpan.org. Please keep in mind that business support is neither available for free nor are you eligible to receive any support based on the license distributed with this package.

ACKNOWLEDGEMENTS

AUTHOR

Jens Rehsack, <rehsack at cpan.org>

LICENSE AND COPYRIGHT

Copyright 2012 Jens Rehsack.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.