This class is an Event simulation that resembles some other languages'
functionalities, such as .NET events. The idea is that user creates an
Event put in the static array in the class, accessible only via the static
methods. The Event object itself is never accessible. However, there is an
EventWrapper, which wraps functionality in way shown in the example.php
file.
To create an Event first you need to provide i.Event_Name.Event interface
which has the on.Event_Name.Call and on.Event_name.Destroy functions (see
documentation of Event.php). You can also provide other interface name, but
the interface has to define these methods.
Events are either Private, Protected or Public. Private events can be
called only by the instance of EventCaller (or one of it's descendants)
provided during Event creation. Making this caller private member of class
makes event callable only by that class. Protected Events are callable only
via the instance of a class, which name is provided during the creation.
Since there is no possibility to create internal classes, object can be
created to call the event. Hovewer, informational purposes require making
it this way. When getting the CallerClass classname one can easily
determine which module/library is the "owner" of the Event. Public events
can be raised by any object which is EventCaller or one of it's
descendants.
Events provide datasets. Dataset is an information set which is an argument
for Listeners. Listener is an object which "listens" whether the Event was
raised. On raising the event, the on.Event_Name.Call is called. The callback function with one argument - dataset. Listeners have to implement the Event's interface provided at creation. Dataset can be of a null value,
nevertheless handler methods must have at least one argument.
Events are disposable or non-disposable. Disposable Events are unset after
raising. Non-disposable stay in the memory (private events can be destroyed
by unsetting the caller instance and calling the Event::callerDestroyed()
function).
First event is created either by the static Event::init() method or on first event creation. It's the EventCreated Event, non-disposable, with EventInfo dataset. EventCreated is raised when new event is created, as it's name says :).
More documentation in the .php files.
License: this package is available for non-commercial usage, after
notyfying the author (szpakowski@gmail.com), on GPL License. Using this
package in commercial projects has to be agreed by the author (usually
free). Author does not provide any guarantees for the class.
Have fun.
|