FBX C++ API Reference
fbxeventhandler.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2015 Autodesk, Inc.
4  All rights reserved.
5 
6  Use of this software is subject to the terms of the Autodesk license agreement
7  provided at the time of installation or download, or which otherwise accompanies
8  this software in either electronic or hard copy form.
9 
10 ****************************************************************************************/
11 
13 #ifndef _FBXSDK_CORE_EVENT_HANDLER_H_
14 #define _FBXSDK_CORE_EVENT_HANDLER_H_
15 
16 #include <fbxsdk/fbxsdk_def.h>
17 
18 #include <fbxsdk/core/fbxevent.h>
20 
21 #include <fbxsdk/fbxsdk_nsbegin.h>
22 
23 class FbxListener;
24 
42 {
43 public:
45  enum EType
46  {
50  };
51 
54  virtual int GetHandlerEventType()=0;
55 
59  virtual void FunctionCall(const FbxEventBase& pEvent)=0;
60 
63  virtual FbxListener* GetListener()=0;
64 
65 /*****************************************************************************************************************************
66 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
67 *****************************************************************************************************************************/
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69  FbxEventHandler(){}
70  virtual ~FbxEventHandler(){}
71 
72  FBXSDK_INTRUSIVE_LIST_NODE(FbxEventHandler, eCount);
73 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
74 };
75 
76 /*****************************************************************************************************************************
77 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
78 *****************************************************************************************************************************/
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80 
81 template <typename EventType, typename ListenerType> class FbxMemberFuncEventHandler : public FbxEventHandler
82 {
83  typedef void (ListenerType::*CallbackFnc)(const EventType*);
84 
85 public:
86  FbxMemberFuncEventHandler(ListenerType* pListenerInstance, CallbackFnc pFunction) : mListener(pListenerInstance), mFunction(pFunction){}
87  virtual int GetHandlerEventType(){ return EventType::GetStaticTypeId(); }
88  virtual void FunctionCall(const FbxEventBase& pEvent){ (*mListener.*mFunction)(reinterpret_cast<const EventType*>(&pEvent)); }
89  virtual FbxListener* GetListener(){ return mListener; }
90 
91 private:
92  ListenerType* mListener;
93  CallbackFnc mFunction;
94 };
95 
96 template <typename EventType, typename ListenerType> class FbxConstMemberFuncEventHandler : public FbxEventHandler
97 {
98  typedef void (ListenerType::*CallbackFnc)(const EventType*) const;
99 
100 public:
101  FbxConstMemberFuncEventHandler(ListenerType* pListenerInstance, CallbackFnc pFunction) : mListener(pListenerInstance), mFunction(pFunction){}
102  virtual int GetHandlerEventType(){ return EventType::GetStaticTypeId(); }
103  virtual void FunctionCall(const FbxEventBase& pEvent){ (*mListener.*mFunction)(reinterpret_cast<const EventType*>(&pEvent)); }
104  virtual FbxListener* GetListener(){ return mListener; }
105 
106 private:
107  ListenerType* mListener;
108  CallbackFnc mFunction;
109 };
110 
111 template <typename EventType> class FbxFuncEventHandler : public FbxEventHandler
112 {
113  typedef void (*CallbackFnc)(const EventType*, FbxListener*);
114 
115 public:
116  FbxFuncEventHandler(FbxListener* pListener, CallbackFnc pFunction) : mListener(pListener), mFunction(pFunction){}
117  virtual int GetHandlerEventType(){ return EventType::GetStaticTypeId(); }
118  virtual void FunctionCall(const FbxEventBase& pEvent){ (*mFunction)(reinterpret_cast<const EventType*>(&pEvent), mListener); }
119  virtual FbxListener* GetListener(){ return mListener; }
120 
121 private:
122  FbxListener* mListener;
123  CallbackFnc mFunction;
124 };
125 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
126 
127 #include <fbxsdk/fbxsdk_nsend.h>
128 
129 #endif /* _FBXSDK_CORE_EVENT_HANDLER_H_ */
FBX SDK environment definition.
Event handler class contains a listener and a callback function.
FBX SDK event base class.
Definition: fbxevent.h:40
Emitter event handler type.
virtual FbxListener * GetListener()=0
Get listener of current handler.
FBX SDK listener class.
Definition: fbxlistener.h:41
Listener event handler type.
EType
Event handler base type.
virtual void FunctionCall(const FbxEventBase &pEvent)=0
Call function that process event data.
Count of different event handler types.
virtual int GetHandlerEventType()=0
Get event type of current handler.