00001 /**************************************************************************************** 00002 00003 Copyright (C) 2013 Autodesk, Inc. 00004 All rights reserved. 00005 00006 Use of this software is subject to the terms of the Autodesk license agreement 00007 provided at the time of installation or download, or which otherwise accompanies 00008 this software in either electronic or hard copy form. 00009 00010 ****************************************************************************************/ 00011 00013 #ifndef _FBXSDK_CORE_EMITTER_H_ 00014 #define _FBXSDK_CORE_EMITTER_H_ 00015 00016 #include <fbxsdk/fbxsdk_def.h> 00017 00018 #include <fbxsdk/core/base/fbxintrusivelist.h> 00019 #include <fbxsdk/core/fbxeventhandler.h> 00020 00021 #include <fbxsdk/fbxsdk_nsbegin.h> 00022 00023 class FbxListener; 00024 00049 class FBXSDK_DLL FbxEmitter 00050 { 00051 public: 00054 void AddListener(FbxEventHandler& pHandler); 00055 00058 void RemoveListener(FbxEventHandler& pHandler); 00059 00064 template <typename EventType> void Emit(const EventType& pEvent) const 00065 { 00066 if( !mData ) return; 00067 EventHandlerList::iterator itBegin = mData->mEventHandlerList.Begin(); 00068 EventHandlerList::iterator itEnd = mData->mEventHandlerList.End(); 00069 for( EventHandlerList::iterator it = itBegin; it != itEnd; ++it ) 00070 { 00071 if ((*it).GetHandlerEventType() == pEvent.GetTypeId()) 00072 { 00073 (*it).FunctionCall(pEvent); 00074 } 00075 } 00076 } 00077 00078 /***************************************************************************************************************************** 00079 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** 00080 *****************************************************************************************************************************/ 00081 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00082 FbxEmitter(); 00083 ~FbxEmitter(); 00084 00085 protected: 00086 typedef FbxIntrusiveList<FbxEventHandler, FbxEventHandler::eEmitter> EventHandlerList; 00087 struct EventData { EventHandlerList mEventHandlerList; }; 00088 EventData* mData; 00089 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ 00090 }; 00091 00092 #include <fbxsdk/fbxsdk_nsend.h> 00093 00094 #endif /* _FBXSDK_CORE_EMITTER_H_ */