CFugue
Public Member Functions | List of all members
OIL::CInvokableEventT< TEventHandlerArgs > Class Template Reference

#include <EventHandler.h>

Inherits OIL::CEventSource, and OIL::CEventT< const CEventSource, TEventHandlerArgs >.

Public Member Functions

void RaiseEvent (TEventHandlerArgs *pArgs)
 
- Public Member Functions inherited from OIL::CEventT< const CEventSource, TEventHandlerArgs >
void Subscribe (TEventReceiver *pReceiver, void(TEventReceiver::*lpfnHandler)(const CEventSource *, TEventHandlerArgs *))
 
void Subscribe (void(*lpfnHandler)(const CEventSource *, TEventHandlerArgs *))
 
void UnSubscribe (void(*lpfnHandler)(const CEventSource *, TEventHandlerArgs *))
 
void UnSubscribe (TReceiverClass *pReceiver)
 
void UnSubscribeAll ()
 
size_t SubscriberCount () const
 

Additional Inherited Members

- Protected Member Functions inherited from OIL::CEventSource
template<typename TEventSource , typename TEventHandlerArgs >
void RaiseEvent (CEventT< TEventSource, TEventHandlerArgs > *pEvent, TEventHandlerArgs *pArgs)
 
template<typename TEventSource , typename TEventHandlerArgs >
void RaiseEvent (CEventT< TEventSource, const TEventHandlerArgs > *pEvent, const TEventHandlerArgs *pArgs)
 
- Protected Member Functions inherited from OIL::CEventT< const CEventSource, TEventHandlerArgs >
void Subscribe (TEventReceiver *pReceiver, void(TEventReceiver::*lpfnHandler)(const CEventSource *, TEventHandlerArgs *))
 
void Subscribe (void(*lpfnHandler)(const CEventSource *, TEventHandlerArgs *))
 
void UnSubscribe (void(*lpfnHandler)(const CEventSource *, TEventHandlerArgs *))
 
void UnSubscribe (TReceiverClass *pReceiver)
 
void UnSubscribeAll ()
 
size_t SubscriberCount () const
 

Detailed Description

template<typename TEventHandlerArgs = CEventHandlerArgs>
class OIL::CInvokableEventT< TEventHandlerArgs >

An event that can be invoked by itself.

A CEventT event can only be used from within a class. To use events outside classes, you need to use CInvokableEventT.

Just declare the variable of CInvokableEventT anywhere in your code, and use its RaiseEvent() method to invoke it.

Use its subscribe() methods to subscribe either static metods or class based methods.

Note that in this case the EventSource is same as the event object itself, which means the handler prototype will be always of the form

void EventHandlerProc(const CEventSource* pSender, T* pArgs)

where T is the template argument passed while declaring the CInvokableEventT variable.

Following Snippet demonstrates sample usage.

<pre>
struct MyEventHandlerArgs : public CEventHandlerArgs
{
int m_nVal;
};
CInvokableEventT \<MyEventHandlerArgs\> Event;
class MyPseudoClass
{
public:
MyPseudoClass()
{
Event.RaiseEvent(&MyEventHandlerArgs());
}
};
void EventHandlerProc(const CEventSource* pSender, MyEventHandlerArgs* pArgs)
{
printf("\nEvent Received");
}
class MyListener : public CEventReceiver
{
public:
void EventHandlerProc(const CEventSource* pSender, MyEventHandlerArgs* pArgs)
{
printf("\nListener Received the Event");
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Event.Subscribe(&EventHandlerProc); // Subscribe a non-class method
MyListener listener;
Event.Subscribe(&listener, &MyListener::EventHandlerProc); // Subscribe a class method
MyPseudoClass Obj; // Raise the Event in the constructor
Event.RaiseEvent(&MyEventHandlerArgs()); // Event can be raised explicitly with from anywhere !!
return 0;
}
</pre>

Summary> Default form of CInvokableEventT that uses

void EventReceptionFunc(const CEventSource* pSrc, CEventHandlerArgs* pArgs)

as the Event handler procedure /Summary>

Definition at line 404 of file EventHandler.h.


The documentation for this class was generated from the following file:

CFugue, the C++ Music Programming Library © Copyright 2009 Cenacle Research India Private Limited Gopalakrishna Palem