00001
00004 #ifndef FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H
00005 #define FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <fbxfilesdk/fbxfilesdk_def.h>
00042
00043
00044 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00045
00046 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00047 #include <fbxfilesdk/components/kbaselib/klib/kintrusivelist.h>
00048 #include <fbxfilesdk/components/kbaselib/object/klibrary.h>
00049
00050 #include <fbxfilesdk/kfbxevents/kfbxemitter.h>
00051 #include <fbxfilesdk/kfbxevents/kfbxlistener.h>
00052
00053
00054 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00055
00056
00057 class KFbxSdkManager;
00058
00059
00060 class KFbxLoadingStrategy;
00061 class KFbxPluginContainer;
00062
00063 #define KFBXPLUGIN_DECLARE(Plugin)\
00064 KFBXNEW_DECLARE_FRIEND\
00065 public:\
00066 static Plugin* Create( const KFbxPluginDefinition& pDefinition, kLibHandle pLibHandle );\
00067 void Destroy();
00068
00069 #define KFBXPLUGIN_IMPLEMENT(Plugin)\
00070 Plugin* Plugin::Create( const KFbxPluginDefinition& pDefinition, kLibHandle pLibHandle )\
00071 {\
00072 return FbxSdkNew< Plugin >( pDefinition, pLibHandle );\
00073 }\
00074 void Plugin::Destroy()\
00075 {\
00076 FbxSdkDelete(this);\
00077 }
00078
00079
00085 struct KFBX_DLL KFbxPluginDefinition
00086 {
00087 KFbxPluginDefinition():mName("Unknown Name"),mVersion("Unknown Version"){}
00088 KString mName;
00089 KString mVersion;
00090 };
00091
00097 struct KFBX_DLL KFbxPluginData
00098 {
00099 KFbxPluginData() : mQueryEmitter(0), mSDKManager(0), mPluginContainer(0) {}
00100 explicit KFbxPluginData(const KFbxPluginData& r) : mQueryEmitter(r.mQueryEmitter), mSDKManager(r.mSDKManager), mPluginContainer(r.mPluginContainer){}
00101 kfbxevents::KFbxEmitter* mQueryEmitter;
00102 KFbxSdkManager* mSDKManager;
00103 KFbxPluginContainer* mPluginContainer;
00104 };
00105
00111 class KFBX_DLL KFbxPlugin : public kfbxevents::KFbxListener
00112 {
00113 KFBX_LISTNODE(KFbxPlugin,1);
00114
00115 public:
00120
00122 virtual ~KFbxPlugin();
00123
00127 inline const KFbxPluginDefinition& GetDefinition()const;
00128
00129 virtual void Destroy() = 0;
00130
00131 inline KFbxObject& GetPluginSettings() { return *(mPluginSettings.Get()); }
00132
00133 inline const KFbxObject& GetPluginSettings() const { return *(mPluginSettings.Get()); }
00134
00136
00137 protected:
00145 explicit KFbxPlugin(const KFbxPluginDefinition& pDefinition, kLibHandle pLibHandle);
00146
00150 inline KFbxPluginData& GetData();
00151
00155 inline const KFbxPluginData& GetData()const;
00156
00157 private:
00158 bool mInitialized;
00159 KFbxPluginData mData;
00160 KFbxPluginDefinition mDefinition;
00161 kLibHandle mLibraryHandle;
00162
00163 public:
00168
00172 virtual bool SpecificInitialize() = 0;
00173
00177 virtual bool SpecificTerminate() = 0;
00179
00180 virtual void WriteBegin(KFbxScene& pScene){}
00181 virtual void WriteParameters(KFbxObject& pParams){}
00182 virtual void WriteEnd(KFbxScene& pScene){}
00183 virtual void ReadBegin(KFbxScene& pScene){}
00184 virtual void ReadParameters(KFbxObject& pParams){}
00185 virtual void ReadEnd(KFbxScene& pScene){}
00186
00191 template <typename EventType,typename ListernerType> inline KFbxEventHandler* Bind(void (ListernerType::*pFunc)(const EventType*))
00192 {
00193 return KFbxListener::Bind<EventType,ListernerType>(*(GetData().mQueryEmitter), pFunc );
00194 }
00195
00199 kLibHandle GetLibraryHandle();
00200
00201 private:
00203
00204
00205
00206
00207
00208
00210 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00211
00212 friend class KFbxLoadingStrategy;
00213 bool Initialize(const KFbxPluginData& pData);
00214 bool Terminate();
00215
00216 KFBXObjectScopedPtr<KFbxObject> mPluginSettings;
00217
00218 #endif
00219 };
00220
00222 inline const KFbxPluginDefinition& KFbxPlugin::GetDefinition()const{ return mDefinition; }
00224 inline KFbxPluginData& KFbxPlugin::GetData(){ return mData; }
00226 inline const KFbxPluginData& KFbxPlugin::GetData()const{ return mData; }
00227
00228
00229 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00230
00231 #endif // FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H