FBX SDK Reference Guide: kfbxplugin.h Source File
00001 #ifndef FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H
00002 #define FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H
00003 
00004 /**************************************************************************************
00005 
00006  Copyright (C) 2001 - 2006 Autodesk, Inc. and/or its licensors.
00007  All Rights Reserved.
00008 
00009  The coded instructions, statements, computer programs, and/or related material
00010  (collectively the "Data") in these files contain unpublished information
00011  proprietary to Autodesk, Inc. and/or its licensors, which is protected by
00012  Canada and United States of America federal copyright law and by international
00013  treaties.
00014 
00015  The Data may not be disclosed or distributed to third parties, in whole or in
00016  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00017 
00018  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00019  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00020  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00021  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE,
00022  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE.
00023  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00024  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE.
00025 
00026  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00027  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00028  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00029  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00030  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00031  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00032  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00033  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00034  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00035  OR DAMAGE.
00036 
00037 **************************************************************************************/
00038 #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00039 // FBX includes
00040 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00041 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00042 #include <fbxfilesdk/components/kbaselib/klib/kintrusivelist.h>
00043 #include <fbxfilesdk/kfbxevents/kfbxemitter.h>
00044 #include <fbxfilesdk/kfbxevents/kfbxlistener.h>
00045 
00046 // FBX begin namespace
00047 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00048 
00049 // Forward declaration
00050 class KFbxSdkManager;
00051 
00053 // TODO: todonamespace
00054 //       Every FBX module should have a namespace but for consistency, 
00055 //       you have, for this version of fbx, to use the fbx object without namespace
00056 //namespace kfbxmodules
00057 //{
00058     // Forward declaration
00059     class KFbxLoadingStrategy;
00060     class KFbxPluginContainer;
00061 
00062 #define KFBXPLUGIN_DECLARE(Plugin)\
00063     public:\
00064         static Plugin* Create( const KFbxPluginDefinition& pDefinition );\
00065         void Destroy();
00066 
00067 #define KFBXPLUGIN_IMPLEMENT(Plugin)\
00068     Plugin* Plugin::Create( const KFbxPluginDefinition& pDefinition )\
00069     {\
00070         return new Plugin( pDefinition );\
00071     }\
00072     void Plugin::Destroy()\
00073     {\
00074         delete this;\
00075     }
00076 
00077 
00083     struct KFBX_DLL KFbxPluginDefinition
00084     {
00085         KFbxPluginDefinition():mName("Unknown Name"),mVersion("Unknown Version"){}
00086         KString mName;
00087         KString mVersion;
00088     };
00089 
00095     struct KFBX_DLL KFbxPluginData
00096     {
00097         KFbxPluginData():mQueryEmitter(0),mSDKManager(0),mPluginContainer(0){}
00098         explicit                    KFbxPluginData(const KFbxPluginData& r):mQueryEmitter(r.mQueryEmitter),mSDKManager(r.mSDKManager),mPluginContainer(r.mPluginContainer){}
00099         KFbxSdkManager*             mSDKManager;             // (Optional) SDK manager to which the plug-in can register custom types
00100         KFbxPluginContainer*        mPluginContainer;   // (Optional) Container which will have the ownership of the plug-in
00101         kfbxevents::KFbxEmitter*    mQueryEmitter;  // (Optional) The plug-in can listen to this query emitter
00102     };
00103 
00109     class KFBX_DLL KFbxPlugin : public kfbxevents::KFbxListener
00110     {
00111         KFBX_LISTNODE(KFbxPlugin,1);
00112 
00113     public:
00118 
00122         inline const KFbxPluginDefinition& GetDefinition()const;
00123 
00124         virtual void Destroy() = 0;
00125 
00126         inline KFbxObject& GetPluginSettings() { return *(mPluginSettings.Get()); }
00127 
00128         inline const KFbxObject& GetPluginSettings() const { return *(mPluginSettings.Get()); }
00129 
00131 
00132     protected:
00133 
00140         explicit KFbxPlugin(const KFbxPluginDefinition& pDefinition);
00141         
00145         inline KFbxPluginData& GetData();
00146 
00150         inline const KFbxPluginData& GetData()const;
00151 
00152     private:
00153         bool mInitialized;
00154         KFbxPluginData mData;
00155         KFbxPluginDefinition mDefinition;
00156 
00157     public:
00162 
00166         virtual bool SpecificInitialize() = 0;
00167 
00171         virtual bool SpecificTerminate() = 0;
00173 
00174         virtual bool NeedReadWrite(){ return false; }
00175         virtual void WriteBegin(KFbxScene& pScene){}
00176         virtual void WriteSettings(KFbxObject& pSettings){}
00177         virtual void WriteEnd(KFbxScene& pScene){}
00178         virtual void ReadBegin(KFbxScene& pScene){}
00179         virtual void ReadSettings(KFbxObject& pSettings){}
00180         virtual void ReadEnd(KFbxScene& pScene){}
00181 
00186         template <typename EventType,typename ListernerType> inline KFbxEventHandler* Bind(void (ListernerType::*pFunc)(const EventType*))
00187         {
00188             return KFbxListener::Bind<EventType,ListernerType>(*(GetData().mQueryEmitter), pFunc );
00189         }
00190 
00191 
00192     private:
00194         //
00195         //  WARNING!
00196         //
00197         //  Anything beyond these lines may not be documented accurately and is 
00198         //  subject to change without notice.
00199         //
00201         #ifndef DOXYGEN_SHOULD_SKIP_THIS
00202 
00203         friend class KFbxLoadingStrategy;
00204         bool Initialize(const KFbxPluginData& pData);
00205         bool Terminate();
00206 
00207         KFBXObjectScopedPtr<KFbxObject> mPluginSettings;
00208 
00209         #endif
00210     };
00211 
00213     inline const KFbxPluginDefinition& KFbxPlugin::GetDefinition()const{ return mDefinition; }
00215     inline KFbxPluginData& KFbxPlugin::GetData(){ return mData; }
00217     inline const KFbxPluginData& KFbxPlugin::GetData()const{ return mData; }
00218 //}
00219 
00220 // FBX end namespace
00221 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00222 
00223 #endif // FBXFILESDK_KFBXMODULES_KFBXPLUGIN_H