KFbxEmitter Class Reference


Detailed Description

Base class to emit event with the specified event type.

The event type could be a specific class which derived from KFbxEvent. Please read KFbxEmitter::Emit() for more details. Event emitter contains a list of event handlers. FBX object could be used as emitter, since KFbxObject is derived from KFbxEmitter. Before using emitter to emit an event, one or more event handlers must be added to the handlers list of current emitter. In other words, it's "bind event handlers to emitter". There are two ways to bind event handlers to emitter.

  • 1. If you already got an event handler and would like to bind it to current emitter, please call KFbxEmitter::AddListener().
  • 2. Or you can create an event listener first and then call KFbxListener::Bind(). It will create an event handler automatically and bind the handler to the specified emitter. It's similar to unbind or remove an even handler. For more details,
    See also:
    KFbxEmitter::RemoveListener()
    KFbxListener::Unbind()
    Note:
    Only Emit() is thread-safe.
    Remarks:
    An object(emitter) can emit a certain type of event, the plug-in(listener) who are listening to that type of event, will receive a signal and take action to process the event data.
    The whole process of event is:
  • 1. Create an emitter and a listener, then bind them together via the same event handler.
  • 2. Emitter can emit an event at certain conditions. The event could be handled by event handler.
  • 3. Once an event is emitted, the listener to this event will receive a signal.
  • 4. And then the listener could process the event data according to the types of event, by calling event handler.
    Note:
    The event data is process by the callback function of event handler.
    See also:
    KFbxListener KFbxEventHandler KFbxEvent KFbxEventBase

Definition at line 82 of file kfbxemitter.h.

#include <kfbxemitter.h>

Inheritance diagram for KFbxEmitter:
Inheritance graph
[legend]

List of all members.

Classes

struct   KFbxEmitterData

Public Member Functions

  KFbxEmitter ()
  Constructor.
  ~KFbxEmitter ()
  Destructor.
void  AddListener (KFbxEventHandler &pHandler)
  The specified event handler will be added to the handlers list of current emitter.
void  RemoveListener (KFbxEventHandler &pHandler)
  The specified event handler will be removed from the handlers list of current emitter.
template<typename EventType >
void  Emit (const EventType &pEvent) const
  Emit an event with the specified the event type.

Protected Types

typedef KIntrusiveList
< KFbxEventHandler,
KFbxEventHandler::eNODE_EMITTER > 
EventHandlerList

Protected Attributes

KFbxEmitterData mData

Member Typedef Documentation

typedef KIntrusiveList<KFbxEventHandler, KFbxEventHandler::eNODE_EMITTER> EventHandlerList [protected]

Definition at line 143 of file kfbxemitter.h.


Constructor & Destructor Documentation

Constructor.

Destructor.


Member Function Documentation

void AddListener ( KFbxEventHandler pHandler )

The specified event handler will be added to the handlers list of current emitter.

Bind the specified event handler to current emitter actually.

Note:
This is not a thread-safe method!
Parameters:
pHandler the event handler will be added to the handlers list of current emitter.
void RemoveListener ( KFbxEventHandler pHandler )

The specified event handler will be removed from the handlers list of current emitter.

Note:
This is not a thread-safe method!
Parameters:
pHandler the event handler will be removed from the handlers list of current emitter.
void Emit ( const EventType &  pEvent ) const [inline]

Emit an event with the specified the event type.

One the event is emitted, the listener to this event will receive a signal.

Note:
This is a thread-safe method!
Parameters:
pEvent specify the event type to emit. pEvent could be a specific class which derived from KFbxEvent, such as KFbxObjectPropertyChanged.
Remarks:
For example:
See also:
KFbxEventBase KFbxObjectPropertyChanged KFbxEventReferencedDocument KFbxEventPostExport
KFbxEventPostImport KFbxEventPreExport KFbxEventPreImport KFbxEventPopulateSystemLibrary

Definition at line 116 of file kfbxemitter.h.

        {
            if ( mData )
            {
                kfbxmp::KFbxMutexHelper lLock( mData->mMutex );

                EventHandlerList::iterator itBegin = mData->mEventHandler.Begin();
                EventHandlerList::iterator itEnd = mData->mEventHandler.End();
                for (EventHandlerList::iterator it = itBegin; it!=itEnd; ++it)
                {
                    if ((*it).GetHandlerEventType() == pEvent.GetTypeId())
                        (*it).FunctionCall(pEvent);
                }
            }
        }

Member Data Documentation

KFbxEmitterData* mData [protected]

Reimplemented in KFbxCache.

Definition at line 151 of file kfbxemitter.h.


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

KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter
KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter KFbxEmitter