00001 #ifndef __FBBASE_H__
00002 #define __FBBASE_H__
00003
00004
00005
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
00047 #include <kaydaradef.h>
00048
00049
00050
00051 #include <fbsdk/fblibrary.h>
00052
00053 #ifndef FBSDK_DLL
00054
00057 #define FBSDK_DLL K_DLLIMPORT
00058 #endif
00059
00060
00061 #include <fbsdk/fbplug.h>
00062 #include <fbsdk/fbarray.h>
00063 #include <fbsdk/fbstring.h>
00064 #include <fbsdk/fbproperties.h>
00065
00066 #ifdef _MSC_VER
00067
00068 #pragma warning (disable: 4275) // 'int' : forcing value to bool 'true' or 'false' (performance warning)
00069 #pragma warning (disable: 4661) // no suitable definition provided for explicit template instantiation request
00070 #endif
00071
00072 K_FORWARD( IRegister );
00073 K_FORWARD( IError );
00074 K_FORWARD( IStore );
00075 K_FORWARD( IKtView );
00076 K_FORWARD( KEventBase );
00077 K_FORWARD( KGlobalNamedEvent );
00078
00079 #ifdef FBSDKUseNamespace
00080 namespace FBSDKNamespace {
00081 #endif
00082
00083 #ifndef FBINCLUDE
00084
00085 #else
00086 #endif
00087
00090 #define FB_DEFAULT_SDK_ICON "openreality_noicon.tif"
00091
00092
00096 #define __FBClassInit mLocalPtr = NULL;
00097
00098
00102 #define __FBClassInitSDKComponent( pObjectToWrappedIsAllocated ) \
00103 __FBClassInit; \
00104 mSDKComponent = pObjectToWrappedIsAllocated;
00105
00106
00110 #define __FBClassImplementation( ThisComponent,pInternalClassId ) \
00111 int ThisComponent::TypeInfo=FBPlug::mGlobalTypeInfo++; \
00112 int ThisComponent::mInternalClassId=pInternalClassId
00113
00117 #define __FBClassDeclare( Name,Parent ) \
00118 public: \
00119 \
00122 typedef Parent __FBParentClass;\
00123 \
00126 typedef Name __FBClassType;\
00127 \
00130 virtual char* ClassName() override { return #Name; } \
00131 \
00135 virtual bool Is( int pTypeId ) override { return (pTypeId==TypeInfo) ? true : Parent::Is( pTypeId ); } \
00136 virtual int GetTypeId() override { return TypeInfo; } \
00137 \
00140 static int GetInternalClassId() { return mInternalClassId; } \
00141 \
00144 Data##Name* mLocalPtr; \
00145 virtual ~Name(); \
00146 static int TypeInfo; \
00147 private: \
00148 static int mInternalClassId; \
00149
00150
00153 #define FBStorableClassImplementation(ClassName, Type)\
00154 char* ClassName::FbxGetObjectSubType(){ return #ClassName; }\
00155 HIObject RegisterStorable##ClassName##Create(HIObject , char* pName, void* ){\
00156 ClassName* Class = new ClassName(pName);\
00157 Class->mAllocated = true;\
00158 if( Class->FBCreate() ){\
00159 return Class->GetHIObject();\
00160 } else {\
00161 delete Class;\
00162 return NULL;}}\
00163 FBLibraryModule(ClassName##Storable){\
00164 FBString lGroup = "FbxStorable/";\
00165 lGroup += #Type;\
00166 FBRegisterObject(ClassName##R2, lGroup, #ClassName, "", RegisterStorable##ClassName##Create, true, NULL);}
00167
00171 #define FBElementClassImplementation(ClassName,IconFileName)\
00172 HIObject RegisterElement##ClassName##Create(HIObject , char* pName, void* ){\
00173 ClassName* Class = new ClassName(pName);\
00174 Class->mAllocated = true;\
00175 if( Class->FBCreate() ){\
00176 return Class->GetHIObject();\
00177 } else {\
00178 delete Class;\
00179 return NULL;}}\
00180 FBLibraryModule(ClassName##Element){\
00181 FBRegisterObject(ClassName##R2, "Browsing/Templates/Elements", #ClassName, "", RegisterElement##ClassName##Create, true, IconFileName);}
00182
00189 #define FBStorableClassDeclare(Name, Parent)\
00190 FBClassDeclare(Name, Parent);\
00191 public:\
00192 virtual char* FbxGetObjectSubType();
00193
00194
00202 #define FBPropertyInitComponent( Param,Type,PropName,Get,Set ) \
00203 { \
00204 PropertyAdd(PropName.Init( (void *)Param,#PropName,(H##Type (*)(void *))Get,(void (*)(void *,H##Type))Set )); \
00205 PropName.TypeInfo = &Type::TypeInfo; \
00206 }
00207
00215 #define FBIS( Component,ComponentType ) \
00216 ((Component) && (Component)->Is( ComponentType::TypeInfo ))
00217
00219
00221
00222 __FB_FORWARD( FBComponent );
00223 __FB_FORWARD( FBVisualComponent );
00224
00231 FBSDK_DLL FBComponent* GetFBComponent( const HIObject Object );
00232
00233 #if !defined(K_NO_UI)
00234
00239 FBSDK_DLL FBVisualComponent* FBGetFBVisualComponent( HIKtView pObject,bool pAutoCreate=true );
00240 #endif
00241
00247 FBSDK_DLL FBComponent* FBGetFBComponent( HIObject pObject, bool pAutoCreate=true );
00248
00254 FBSDK_DLL FBPlug* FBGetFBPlug( HIObject pObject, bool pAutoCreate=true );
00255
00257 typedef FBArrayTemplate<FBComponent*> FBComponentList;
00260 FBSDK_DLL FBArrayTemplate<FBComponent*>& FBGetComponentArray();
00261
00263
00265
00270 #define FBRegisterEvent ( Object, EventId, EventProc ) IQ( Object,IRegister)->Register ( EventId,(HICallback)this,(kICallbackHandler)EventProc );
00271
00275 #define FBUnregisterEvent ( Object, EventId, EventProc ) IQ( Object,IRegister)->Unregister ( EventId,(HICallback)this,(kICallbackHandler)EventProc );
00276 FBSDK_DLL bool FBObject_Register ( char * pGroupName,char * pEntryName,char * pDescription, kObjectCreatorFnc pCreatorFnc, bool pIsMultipleAllowed,char * pIconFilename);
00277 FBSDK_DLL bool FBObject_Unregister( char * pGroupName,char * pEntryName, int nth=0 );
00278
00286 FBSDK_DLL FBComponent* FBCreateObject( char* pGroupName, char* pEntryName, char* pName, void* pData = NULL, int nth = 0 );
00287
00293 inline bool FBUnregisterObject( char * pGroupName,char * pEntryName, int nth=0 ) { return FBObject_Unregister( pGroupName,pEntryName,nth ); }
00298 #define FBRegisterObject( LocalId,Path,Name,Description,Constructor,IsMultipleAllowed,IconFilename ) \
00299 static int __R##LocalId = FBObject_Register( Path,Name,Description,Constructor,IsMultipleAllowed,IconFilename )
00300
00301 typedef HIRegister HISender;
00303 typedef HKEventBase HKEvent;
00308 typedef void (ICallback::*FBCallback)(HISender pSender,HKEvent pEvent);
00309
00310 FBSDK_DLL int FBRegister_ClassId(char* pClassName);
00315 #define FBDeclareUserObject(ClassName)\
00316 public:\
00317 static int ClassId;\
00318 virtual int GetUserClassId();\
00319 virtual char* FbxGetObjectSubType()
00320
00322
00324 #ifdef new
00325
00328 #define RENEW new
00329 #undef new
00330 #endif
00331
00333
00335 FB_FORWARD( FBPropertyListComponent );
00336 __FB_FORWARD( FBComponent );
00337 FB_DEFINE_LIST( FBSDK_DLL, Component );
00338
00339 FB_FORWARD( FBFolder );
00340 FB_DEFINE_COMPONENT( FBSDK_DLL, Folder );
00341
00343 enum FBObjectFlag
00344 {
00345 kFBFlagSelectable = (1 << 0),
00346 kFBFlagDeletable = (1 << 1),
00347 kFBFlagSavable = (1 << 2),
00348 kFBFlagVisible = (1 << 3),
00349 kFBFlagClonable = (1 << 4),
00350 kFBFlagSystem = (1 << 5),
00351 kFBFlagNewable = (1 << 6),
00352 kFBFlagRenamable = (1 << 7),
00353 kFBFlagMergeable = (1 << 8),
00354 kFBFlagBrowsable = (1 << 9),
00355 kFBFlagDetachable = (1 << 10),
00356 kFBFlagUndoable = (1 << 11),
00357 kFBFlagKeyable = (1 << 12),
00358 kFBFlagAllocated = (1 << 13),
00359
00360
00361 kFBFlagStory = (1 << 14),
00362 kFBFlagStorable6 = (1 << 15),
00363 kFBFlagStorableData6 = (1 << 16),
00364 kFBFlagStorableBlindData = (1 << 17),
00365 kFBFlagUniqueName = (1 << 18),
00366 };
00367
00369 enum FBObjectStatus {
00370 kFBStatusNone = 0,
00371 kFBStatusCreating = (1 << 0),
00372 kFBStatusStoring = (1 << 1),
00373 kFBStatusRetrieving = (1 << 2),
00374 kFBStatusMerging = (1 << 3),
00375 kFBStatusDestroying = (1 << 4),
00376 kFBStatusOwnedByUndo= (1 << 5)
00377 };
00378
00380 enum FBNamespaceAction
00381 {
00382 kFBConcatNamespace,
00383 kFBReplaceNamespace,
00384 kFBRemoveAllNamespace
00385 };
00386
00387 FB_DEFINE_ENUM(FBSDK_DLL, ConnectionType);
00388 FB_DEFINE_ENUM(FBSDK_DLL, ConnectionAction);
00389 FB_DEFINE_ENUM(FBSDK_DLL, ObjectFlag);
00390
00393 class FBSDK_DLL FBPropertyListComponentBase : public FBPropertyBasicList
00394 {
00395 protected:
00397 int mClassId;
00399 bool mParents;
00400 public:
00402 FBPropertyListComponentBase();
00407 virtual int Add( FBComponent* pItem );
00411 virtual void RemoveAt( int pIndex );
00416 virtual FBComponent* GetAt(int pIndex)=0;
00421 FBComponent* operator[](int pIndex);
00425 virtual int GetCount();
00426
00431 virtual int Find( FBComponent* pItem );
00432
00437 virtual int Remove( FBComponent* pItem );
00438
00439
00440 void SetClassId( int pClassId );
00441 int GetClassId( );
00442 void SetListOfParents( bool pListOfParents );
00443 bool GetIsListOfParents();
00444
00448 virtual FBPropertyType GetPropertyType( ) override { return kFBPT_object; }
00449 };
00452 class FBSDK_DLL FBPropertyListComponent : public FBPropertyListComponentBase
00453 {
00454 public:
00459 virtual FBComponent* GetAt(int pIndex);
00460 };
00461
00463
00465
00466 FB_FORWARD( FBPropertyListObject );
00467
00472 class FBSDK_DLL FBPropertyListObject : public FBPropertyListComponent
00473 {
00474 public:
00476 FBPropertyListObject();
00477
00481 virtual int GetCount();
00482
00484
00488 virtual FBComponent* operator[]( int pIndex );
00489 virtual FBComponent* GetAt( int pIndex );
00491
00496 virtual int Add( FBComponent* pObject );
00497
00503 virtual int SetAt(int pIndex, FBComponent* pObject);
00504
00508 virtual void RemoveAt( int pIndex );
00509
00515 virtual int InsertAt(int pIndex, FBComponent* pObject);
00516
00519 virtual void Clear();
00520
00524 virtual void SetSingleConnect(bool pSingleConnect);
00525
00529 virtual int GetSingleConnect();
00530
00534 void SetFilter(int pInternalClassId);
00535
00539 int FBPropertyListObject::GetFilter();
00540
00541 private:
00543
00547 FBPropertyListObject( const FBPropertyListObject& );
00548 const FBPropertyListObject& operator =( const FBPropertyListObject& );
00550 };
00551
00564 class FBSDK_DLL FBComponent : public FBPlug
00565 {
00566 public:
00567 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00569 HDataFBComponent mLocalPtr;
00570 protected:
00572 FBString mName;
00573 #endif
00574
00575 public:
00577 static int TypeInfo;
00578
00580 static int mInternalClassId;
00581
00585 FBComponent( HIObject pObject );
00586
00588 virtual ~FBComponent();
00589
00593 virtual bool FBCreate();
00594
00596 virtual void FBDestroy();
00597
00599 virtual void FBDelete();
00600
00602 virtual bool SetHIObject(HIObject pObject, bool pSDKComponent);
00603
00608 virtual int PropertyAdd( FBProperty *Property );
00609
00614 void PropertyRemove( FBProperty* Property );
00615
00624 FBProperty* PropertyCreate( char* pName, FBPropertyType pType, char * pDataType, bool pAnimatable, bool pIsUser = false, FBProperty* pReferenceSource = NULL );
00625
00629 FBObjectFlag GetObjectFlags();
00630
00634 void SetObjectFlags(FBObjectFlag pFlags);
00635
00640 bool HasObjectFlags(FBObjectFlag pFlags);
00641
00645 void EnableObjectFlags(FBObjectFlag pFlags);
00646
00650 void DisableObjectFlags(FBObjectFlag pFlags);
00651
00656 void SetObjectStatus(FBObjectStatus pStatus, bool pValue);
00657
00661 bool GetObjectStatus(FBObjectStatus pStatus);
00662
00671 void ProcessNamespaceHierarchy( FBNamespaceAction pNamespaceAction, const char* pNamespaceName, const char* pReplaceTo=NULL, bool pAddRight=true );
00672
00677 void ProcessObjectNamespace ( FBNamespaceAction pNamespaceAction, const char* pNamespaceName, const char* pReplaceTo=NULL, bool pAddRight=true );
00678
00682 virtual char* ClassName();
00683
00687 void HardSelect();
00688
00689 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00690
00691
00692 void *operator new( size_t stAllocateBlock );
00693 void operator delete( void *pvMem );
00694
00695 void *operator new( size_t stAllocateBlock, int blockType, const char *filename, int linenumber );
00696 #if _MSC_VER >= 1200
00697 void operator delete( void *pvMem, int blockType, const char *filename, int linenumber );
00698 #endif
00699
00700
00702
00703 void RegisterPropertyEvent(FBPropertyEvent* pPropertyEvent);
00704 void UnregisterPropertyEvent(FBPropertyEvent* pPropertyEvent);
00705 void InvalidatePropertyEventsParents();
00707 #endif
00708
00709 FBPropertyManager PropertyList;
00710 FBPropertyListComponent Components;
00711 FBPropertyListComponent Parents;
00712 FBPropertyBool Selected;
00713 FBPropertyString Name;
00714 FBPropertyString LongName;
00715
00716 #if !defined(K_NO_FOLDER)
00717 FBPropertyFolder Folder;
00718 #endif
00719
00720 public:
00721 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00722 IObject_Declare(Implementation);
00723 ICallback_Declare(Implementation);
00724 #endif
00725
00730 virtual bool Is( int pTypeId );
00731 virtual int GetTypeId();
00732
00733 static void FBComponentSetName( HFBComponent pObject, char *pName );
00734 static char* FBComponentGetName( HFBComponent pObject );
00735
00736 static void FBComponentSetLongName( HFBComponent pObject, char *pName );
00737 static char* FBComponentGetLongName( HFBComponent pObject );
00738
00739
00740 public:
00741 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00742
00743 KObject* mDummyObject;
00744 void KObjectEvent(HIRegister pView, HKEventBase pEvent);
00745 #endif
00746 };
00747
00749 typedef FBComponent FBObject;
00750
00751 #ifdef RENEW
00752 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__)
00753 #undef RENEW
00754 #endif
00755
00757
00759 __FB_FORWARD( FBEvent );
00760
00764 class FBSDK_DLL FBEvent
00765 {
00766 public:
00772 FBEvent( HKEvent pEvent );
00773
00774 FBPropertyInt Type;
00775 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00776 protected:
00778 HKEventBase mEvent;
00779 public:
00781 void PropertyAdd( FBProperty* ) {};
00782 #endif
00783 };
00784
00786
00788 __FB_FORWARD( FBEventConnectionNotify );
00789
00791 class FBSDK_DLL FBEventConnectionNotify : public FBEvent
00792 {
00793 public:
00797 FBEventConnectionNotify(HKEventBase pEvent);
00798
00799 FBPropertyConnectionAction Action;
00800 FBPropertyInt SrcIndex;
00801 FBPropertyConnectionType ConnectionType;
00802 FBPropertyPlug SrcPlug;
00803 FBPropertyPlug DstPlug;
00804 FBPropertyPlug NewPlug;
00805 };
00806
00808
00810 __FB_FORWARD( FBEventConnectionDataNotify );
00811
00813 class FBSDK_DLL FBEventConnectionDataNotify : public FBEvent
00814 {
00815 public:
00819 FBEventConnectionDataNotify(HKEventBase pEvent);
00820
00821 FBPropertyConnectionAction Action;
00822 FBPropertyPlug Plug;
00823 void* GetData();
00824 void* GetOldData();
00825 };
00826
00828
00830 __FB_FORWARD( FBEventConnectionStateNotify );
00831
00833 class FBSDK_DLL FBEventConnectionStateNotify : public FBEvent
00834 {
00835 public:
00839 FBEventConnectionStateNotify(HKEventBase pEvent);
00840
00841 FBPropertyConnectionAction Action;
00842 FBPropertyPlug Plug;
00843 void* GetData();
00844 void* GetOldData();
00845 };
00846
00848
00850
00854 class FBSDK_DLL FBLibraryBase : public ICallback
00855 {
00856 public:
00857 FBLibraryBase();
00858 virtual ~FBLibraryBase();
00859 IObject_Declare(Implementation);
00860 ICallback_Declare(Implementation);
00861
00866 virtual bool LibInit();
00867
00872 virtual bool LibOpen();
00873
00879 virtual bool LibReady();
00880
00884 virtual bool LibClose();
00885
00889 virtual bool LibRelease();
00891 KGlobalNamedEvent *mLibrary_Open,
00892 *mLibrary_Ready,
00893 *mLibrary_Close,
00894 *mLibrary_Release;
00895
00896 void Library_OpenHandler(HIRegister pCaller,HKEventBase pEvent);
00897 void Library_ReadyHandler(HIRegister pCaller,HKEventBase pEvent);
00898 void Library_CloseHandler(HIRegister pCaller,HKEventBase pEvent);
00899 void Library_ReleaseHandler(HIRegister pCaller,HKEventBase pEvent);
00900 };
00901
00903
00905
00909 class FBLibrary : public FBLibraryBase
00910 {
00911 public:
00916 virtual bool LibInit();
00917
00922 virtual bool LibOpen();
00923
00929 virtual bool LibReady();
00930
00934 virtual bool LibClose();
00935
00939 virtual bool LibRelease();
00940 };
00941
00945 #define FBLibraryDeclare( LibName ) \
00946 static FBLibrary LibName##GlobalFBLibrary; \
00947 extern "C" { \
00948 K_DLLEXPORT bool LIBRARY_INIT(HIError ) \
00949 { \
00950 FB_EXT_INIT( LibName ); if (LibName##GlobalFBLibrary.LibInit()) return true; return false; \
00951 } \
00952 } \
00953 FB_DLL_INIT( LibName, Operation ) \
00954 { \
00955 switch( Operation ) \
00956 { \
00957 case kFBDllLoad: \
00958 {
00959
00964 #define FBLibraryModule(Name) \
00965 void FBModule##Name()
00966
00971 #define FBLibraryRegister( ClassName ) \
00972 extern void FBModule##ClassName( ); \
00973 FBModule##ClassName( );
00974
00979 #define FBLibraryRegisterStorable( ClassName ) \
00980 extern void FBModule##ClassName##Storable( ); \
00981 FBModule##ClassName##Storable( );
00982
00987 #define FBLibraryRegisterElement( ClassName ) \
00988 extern void FBModule##ClassName##Element( ); \
00989 FBModule##ClassName##Element( );
00990
00992 #define FBLibraryDeclareEnd \
00993 } \
00994 break; \
00995 default: \
00996 break; \
00997 } \
00998 }
00999
01000
01001
01005 #define FBCustomManagerImplementation( ThisComponent ) \
01006 FBClassImplementation( ThisComponent ) \
01007
01008
01011 #define FBRegisterCustomManager( ClassName ) \
01012 FBLibraryModule( ClassName ) \
01013 { \
01014 static ClassName g##ClassName; \
01015 g##ClassName.FBCreate(); \
01016 g##ClassName.RegisterManager(); \
01017 } \
01018
01019
01022 #define FBCustomManagerDeclare( ClassName ) \
01023 FBClassDeclare( ClassName, FBCustomManager ); \
01024 public: \
01025 ClassName() : FBCustomManager() { FBClassInit; } \
01026 private: \
01027
01028
01030
01032
01033 __FB_FORWARD( FBCustomManager );
01034
01047 class FBSDK_DLL FBCustomManager : public FBComponent {
01048 __FBClassDeclare( FBCustomManager, FBComponent );
01049 public:
01052 FBCustomManager();
01053
01058 void RegisterManager();
01059
01063 virtual bool FBCreate();
01064
01071 virtual bool Init() ;
01072
01078 virtual bool Open() ;
01079
01084 virtual bool Clear() ;
01085
01089 virtual bool Close() ;
01090
01091 };
01092
01093
01094 #ifdef FBSDKUseNamespace
01095 }
01096 #endif
01097
01098 #endif