Odamex
Setting the Standard in Multiplayer Doom
agOdalaunch::ODA_EventRegister Class Reference

An Event Register. More...

#include <event_handler.h>

Inheritance diagram for agOdalaunch::ODA_EventRegister:
agOdalaunch::AGOL_About agOdalaunch::AGOL_MainWindow agOdalaunch::AGOL_Manual agOdalaunch::AGOL_Settings agOdalaunch::AGOL_Solo

Public Member Functions

 ~ODA_EventRegister ()
 Destructor.
EventHandlerRegisterEventHandler (EVENT_FUNC_PTR funcPtr)
 Register a function as an EventHandler.
bool DeleteEventHandler (EventHandler *handler)
 Delete an event handler.

Detailed Description

An Event Register.

Parent class for all classes that will have Agar event callback member functions.

Handling Agar events in ag-odalaunch:

Any Agar-based window/dialog that will register events with Agar needs to inherit from the ODA_EventRegister class.

A pointer to the EventReceiver function needs to be provided to Agar as the event callback function for any event that will call a class member function.

The Agar event must receive a pointer to an EventHandler returned from the RegisterEventHandler() function. This function receives the class member function that should be triggered by the event. When passing the function ptr cast to EVENT_FUNC_PTR. Any additional desired variables can be provided to the event after the required pointer.

The reason for this is that Agar is C-based and C functions cannot receive a class member function pointer. It is also illegal to cast a pointer-to-member-function to (void *) and vice versa.

Example: AG_SetEvent(win, "window-user-resize", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&OurClass::OnWindowResize));


Constructor & Destructor Documentation

agOdalaunch::ODA_EventRegister::~ODA_EventRegister ( )

Destructor.

At destruction all EventHandlers registered through this class instance are automatically deleted.


Member Function Documentation

bool agOdalaunch::ODA_EventRegister::DeleteEventHandler ( EventHandler handler)

Delete an event handler.

This method deletes an EventHandler from the list of registered handlers. You only need to call this if you want to delete an EventHandler before you are finished with the object instance derived from this class. All handlers are deleted automatically when the object instance is destructed.

Parameters:
handlerAn EventHandler.
EventHandler * agOdalaunch::ODA_EventRegister::RegisterEventHandler ( EVENT_FUNC_PTR  funcPtr)

Register a function as an EventHandler.

This method allows member functions of ODA_EventRegister derived classes to be registered as an event handler. The returned EventHandler instance can be passed to Agar functions or other C-based functions as a pointer with the EventReceiver method provided as the event callback function.

Parameters:
funcPtrAn ODA_EventRegister derived classes method.
Returns:
An EventHandler instance.

The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends