kfbxplugin.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H
00005 #define FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright (C) 2001 - 2010 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 #include <fbxfilesdk/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00044 
00045 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00046 #include <fbxfilesdk/components/kbaselib/klib/kintrusivelist.h>
00047 #include <fbxfilesdk/components/kbaselib/object/klibrary.h>
00048 #include <fbxfilesdk/components/kbaselib/klib/kscopedptr.h>
00049 
00050 #include <fbxfilesdk/kfbxevents/kfbxemitter.h>
00051 #include <fbxfilesdk/kfbxevents/kfbxlistener.h>
00052 
00053 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00054 
00055 class KFbxSdkManager;
00056 class KFbxLoadingStrategy;
00057 class KFbxPluginContainer;
00058 
00060 #define KFBXPLUGIN_DECLARE(Plugin)\
00061 KFBXNEW_DECLARE_FRIEND \
00062 public:\
00063     static Plugin * Create(const KFbxPluginDefinition& pDefinition, kLibHandle pLibHandle);\
00064     void Destroy();
00065 
00067 #define KFBXPLUGIN_IMPLEMENT(Plugin)\
00068     Plugin* Plugin::Create(const KFbxPluginDefinition& pDefinition, kLibHandle pLibHandle){ return FbxSdkNew<Plugin>(pDefinition, pLibHandle); }\
00069     void Plugin::Destroy(){ FbxSdkDelete(this); }
00070 
00077 struct KFBX_DLL KFbxPluginDefinition
00078 {
00080     KFbxPluginDefinition() :
00081         mName("Unknown Name"),
00082         mVersion("Unknown Version")
00083     {
00084     }
00085 
00086     KString mName;      
00087     KString mVersion;   
00088 };
00089 
00092 struct KFBX_DLL KFbxPluginData
00093 {
00095     KFbxPluginData() :
00096         mQueryEmitter(NULL),
00097         mSDKManager(NULL),
00098         mPluginContainer(NULL)
00099     {
00100     }
00101 
00103     explicit KFbxPluginData(const KFbxPluginData& pOther) :
00104         mQueryEmitter(pOther.mQueryEmitter),
00105         mSDKManager(pOther.mSDKManager),
00106         mPluginContainer(pOther.mPluginContainer)
00107     {
00108     }
00109 
00110     kfbxevents::KFbxEmitter*    mQueryEmitter;      
00111     KFbxSdkManager*             mSDKManager;        
00112     KFbxPluginContainer*        mPluginContainer;   
00113 };
00114 
00178 class KFBX_DLL KFbxPlugin : public kfbxevents::KFbxListener
00179 {
00180     KFBX_LISTNODE(KFbxPlugin, 1);
00181 
00182 public:
00187     const KFbxPluginDefinition& GetDefinition() const;
00188 
00192     kLibHandle GetLibraryHandle();
00193 
00197     virtual bool SpecificInitialize() = 0;
00198 
00202     virtual bool SpecificTerminate() = 0;
00203 
00208     virtual void WriteBegin(KFbxScene& pScene);
00209 
00215     virtual void WriteParameters(KFbxObject& pParams);
00216 
00222     virtual void WriteEnd(KFbxScene& pScene);
00223 
00228     virtual void ReadBegin(KFbxScene& pScene);
00229 
00235     virtual void ReadParameters(KFbxObject& pParams);
00236 
00241     virtual void ReadEnd(KFbxScene& pScene);
00242 
00243 protected:
00248     explicit KFbxPlugin(const KFbxPluginDefinition& pDefinition, kLibHandle pLibHandle);
00249 
00251     virtual ~KFbxPlugin();
00252 
00256     KFbxPluginData& GetData();
00257 
00261     const KFbxPluginData& GetData() const;
00262 
00264 //
00265 //  WARNING!
00266 //
00267 //  Anything beyond these lines may not be documented accurately and is 
00268 //  subject to change without notice.
00269 //
00271 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00272 public:
00273     inline KFbxObject& GetPluginSettings() { return *(mPluginSettings.Get()); }
00274     inline const KFbxObject& GetPluginSettings() const { return *(mPluginSettings.Get()); }
00275     template <typename EventType, typename ListernerType> inline KFbxEventHandler* Bind(void (ListernerType::*pFunc)(const EventType*))
00276     {
00277         return KFbxListener::Bind<EventType,ListernerType>(*(GetData().mQueryEmitter), pFunc );
00278     }
00279     virtual void Destroy() = 0;
00280 
00281 private:
00282     friend class                    KFbxLoadingStrategy;
00283     bool                            Initialize(const KFbxPluginData& pData);
00284     bool                            Terminate();
00285 
00286     bool                            mInitialized;
00287     KFbxPluginData                  mData;
00288     KFbxPluginDefinition            mDefinition;
00289     kLibHandle                      mLibraryHandle;
00290     KFBXObjectScopedPtr<KFbxObject> mPluginSettings;
00291 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00292 };
00293 
00294 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00295 
00296 #endif // FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H