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.png"
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::GetInternalClassId() { return pInternalClassId; } \
00113
00114
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(); \
00141 \
00144 Data##Name* mLocalPtr; \
00145 virtual ~Name(); \
00146 static int TypeInfo; \
00147
00148
00151 #define FBStorableClassImplementation(ClassName, Type)\
00152 char* ClassName::FbxGetObjectSubType(){ return #ClassName; }\
00153 HIObject RegisterStorable##ClassName##Create(HIObject , char* pName, void* ){\
00154 ClassName* Class = new ClassName(pName);\
00155 Class->mAllocated = true;\
00156 if( Class->FBCreate() ){\
00157 return Class->GetHIObject();\
00158 } else {\
00159 delete Class;\
00160 return NULL;}}\
00161 FBLibraryModule(ClassName##Storable){\
00162 FBString lGroup = "FbxStorable/";\
00163 lGroup += #Type;\
00164 FBRegisterObject(ClassName##R2, lGroup, #ClassName, "", RegisterStorable##ClassName##Create, true, NULL);}
00165
00169 #define FBElementClassImplementation(ClassName,IconFileName)\
00170 HIObject RegisterElement##ClassName##Create(HIObject , char* pName, void* ){\
00171 ClassName* Class = new ClassName(pName);\
00172 Class->mAllocated = true;\
00173 if( Class->FBCreate() ){\
00174 return Class->GetHIObject();\
00175 } else {\
00176 delete Class;\
00177 return NULL;}}\
00178 FBLibraryModule(ClassName##Element){\
00179 FBRegisterObject(ClassName##R2, "Browsing/Templates/Elements", #ClassName, "", RegisterElement##ClassName##Create, true, IconFileName);}
00180
00187 #define FBStorableClassDeclare(Name, Parent)\
00188 FBClassDeclare(Name, Parent);\
00189 public:\
00190 virtual char* FbxGetObjectSubType();
00191
00192
00200 #define FBPropertyInitComponent( Param,Type,PropName,Get,Set ) \
00201 { \
00202 PropertyAdd(PropName.Init( (void *)Param,#PropName,(H##Type (*)(void *))Get,(void (*)(void *,H##Type))Set )); \
00203 PropName.TypeInfo = &Type::TypeInfo; \
00204 }
00205
00213 #define FBIS( Component,ComponentType ) \
00214 ((Component) && (Component)->Is( ComponentType::TypeInfo ))
00215
00217
00219
00220 __FB_FORWARD( FBComponent );
00221 __FB_FORWARD( FBVisualComponent );
00222
00229 FBSDK_DLL FBComponent* GetFBComponent( const HIObject Object );
00230
00231 #if !defined(K_NO_UI)
00232
00237 FBSDK_DLL FBVisualComponent* FBGetFBVisualComponent( HIKtView pObject,bool pAutoCreate=true );
00238 #endif
00239
00245 FBSDK_DLL FBComponent* FBGetFBComponent( HIObject pObject, bool pAutoCreate=true );
00246
00252 FBSDK_DLL FBPlug* FBGetFBPlug( HIObject pObject, bool pAutoCreate=true );
00253
00255 typedef FBArrayTemplate<FBComponent*> FBComponentList;
00258 FBSDK_DLL FBArrayTemplate<FBComponent*>& FBGetComponentArray();
00259
00261
00263
00268 #define FBRegisterEvent ( Object, EventId, EventProc ) IQ( Object,IRegister)->Register ( EventId,(HICallback)this,(kICallbackHandler)EventProc );
00269
00273 #define FBUnregisterEvent ( Object, EventId, EventProc ) IQ( Object,IRegister)->Unregister ( EventId,(HICallback)this,(kICallbackHandler)EventProc );
00274
00279 FBSDK_DLL void FBSetStoreableCustomModelReigstered();
00280 FBSDK_DLL bool FBGetStoreableCustomModelReigstered();
00281
00282 FBSDK_DLL bool FBObject_Register ( char * pGroupName,char * pEntryName,char * pDescription, kObjectCreatorFnc pCreatorFnc, bool pIsMultipleAllowed,char * pIconFilename);
00283 FBSDK_DLL bool FBObject_Unregister( char * pGroupName,char * pEntryName, int nth=0 );
00284
00292 FBSDK_DLL FBComponent* FBCreateObject( char* pGroupName, char* pEntryName, char* pName, void* pData = NULL, int nth = 0 );
00293
00299 inline bool FBUnregisterObject( char * pGroupName,char * pEntryName, int nth=0 ) { return FBObject_Unregister( pGroupName,pEntryName,nth ); }
00304 #define FBRegisterObject( LocalId,Path,Name,Description,Constructor,IsMultipleAllowed,IconFilename ) \
00305 static int __R##LocalId = FBObject_Register( Path,Name,Description,Constructor,IsMultipleAllowed,IconFilename )
00306
00307 typedef HIRegister HISender;
00309 typedef HKEventBase HKEvent;
00314 typedef void (ICallback::*FBCallback)(HISender pSender,HKEvent pEvent);
00315
00316 FBSDK_DLL int FBRegister_ClassId(char* pClassName);
00321 #define FBDeclareUserObject(ClassName)\
00322 public:\
00323 static int ClassId;\
00324 virtual int GetUserClassId();\
00325 virtual char* FbxGetObjectSubType()
00326
00328
00330 #ifdef new
00331
00334 #define RENEW new
00335 #undef new
00336 #endif
00337
00339
00341 FB_FORWARD( FBPropertyListComponent );
00342 __FB_FORWARD( FBComponent );
00343 FB_DEFINE_LIST( FBSDK_DLL, Component );
00344
00345 FB_FORWARD( FBFolder );
00346 FB_DEFINE_COMPONENT( FBSDK_DLL, Folder );
00347
00349 enum FBObjectFlag
00350 {
00351 kFBFlagSelectable = (1 << 0),
00352 kFBFlagDeletable = (1 << 1),
00353 kFBFlagSavable = (1 << 2),
00354 kFBFlagVisible = (1 << 3),
00355 kFBFlagClonable = (1 << 4),
00356 kFBFlagSystem = (1 << 5),
00357 kFBFlagNewable = (1 << 6),
00358 kFBFlagRenamable = (1 << 7),
00359 kFBFlagMergeable = (1 << 8),
00360 kFBFlagBrowsable = (1 << 9),
00361 kFBFlagDetachable = (1 << 10),
00362 kFBFlagUndoable = (1 << 11),
00363 kFBFlagKeyable = (1 << 12),
00364 kFBFlagAllocated = (1 << 13),
00365
00366
00367 kFBFlagStory = (1 << 14),
00368 kFBFlagStorable6 = (1 << 15),
00369 kFBFlagStorableData6 = (1 << 16),
00370 kFBFlagStorableBlindData = (1 << 17),
00371 kFBFlagUniqueName = (1 << 18),
00372 kFBFlagNotSelectableNameSpace = (1 << 19),
00373 kFBFlagCustomNode = (1 << 20),
00374 };
00375
00377 enum FBObjectStatus {
00378 kFBStatusNone = 0,
00379 kFBStatusCreating = (1 << 0),
00380 kFBStatusStoring = (1 << 1),
00381 kFBStatusRetrieving = (1 << 2),
00382 kFBStatusMerging = (1 << 3),
00383 kFBStatusDestroying = (1 << 4),
00384 kFBStatusOwnedByUndo= (1 << 5)
00385 };
00386
00388 enum FBNamespaceAction
00389 {
00390 kFBConcatNamespace,
00391 kFBReplaceNamespace,
00392 kFBRemoveAllNamespace
00393 };
00394
00395 FB_DEFINE_ENUM(FBSDK_DLL, ConnectionType);
00396 FB_DEFINE_ENUM(FBSDK_DLL, ConnectionAction);
00397 FB_DEFINE_ENUM(FBSDK_DLL, ObjectFlag);
00398
00401 class FBSDK_DLL FBPropertyListComponentBase : public FBPropertyBasicList
00402 {
00403 protected:
00405 int mClassId;
00407 bool mParents;
00408 public:
00410 FBPropertyListComponentBase();
00415 virtual int Add( FBComponent* pItem );
00419 virtual void RemoveAt( int pIndex );
00424 virtual FBComponent* GetAt(int pIndex)=0;
00429 FBComponent* operator[](int pIndex);
00433 virtual int GetCount();
00434
00439 virtual int Find( FBComponent* pItem );
00440
00445 virtual int Remove( FBComponent* pItem );
00446
00447
00448 void SetClassId( int pClassId );
00449 int GetClassId( );
00450 void SetListOfParents( bool pListOfParents );
00451 bool GetIsListOfParents();
00452
00456 virtual FBPropertyType GetPropertyType( ) override { return kFBPT_object; }
00457 };
00460 class FBSDK_DLL FBPropertyListComponent : public FBPropertyListComponentBase
00461 {
00462 public:
00467 virtual FBComponent* GetAt(int pIndex);
00468 };
00469
00471
00473
00474 FB_FORWARD( FBPropertyListObject );
00475
00480 class FBSDK_DLL FBPropertyListObject : public FBPropertyListComponent
00481 {
00482 public:
00484 FBPropertyListObject();
00485
00489 virtual int GetCount();
00490
00492
00496 virtual FBComponent* operator[]( int pIndex );
00497 virtual FBComponent* GetAt( int pIndex );
00499
00504 virtual int Add( FBComponent* pObject );
00505
00511 virtual int SetAt(int pIndex, FBComponent* pObject);
00512
00516 virtual void RemoveAt( int pIndex );
00517
00523 virtual int InsertAt(int pIndex, FBComponent* pObject);
00524
00527 virtual void Clear();
00528
00532 virtual void SetSingleConnect(bool pSingleConnect);
00533
00537 virtual int GetSingleConnect();
00538
00542 void SetFilter(int pInternalClassId);
00543
00547 int FBPropertyListObject::GetFilter();
00548
00549 private:
00551
00555 FBPropertyListObject( const FBPropertyListObject& );
00556 const FBPropertyListObject& operator =( const FBPropertyListObject& );
00558 };
00559
00572 class FBSDK_DLL FBComponent : public FBPlug
00573 {
00574 public:
00575 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00576
00577 HDataFBComponent mLocalPtr;
00578 protected:
00580 FBString mName;
00581 #endif
00582
00583 public:
00585 static int TypeInfo;
00586
00590 static int GetInternalClassId();
00591
00595 FBComponent( HIObject pObject );
00596
00598 virtual ~FBComponent();
00599
00603 virtual bool FBCreate();
00604
00606 virtual void FBDestroy();
00607
00609 virtual void FBDelete();
00610
00612 virtual bool SetHIObject(HIObject pObject, bool pSDKComponent);
00613
00618 virtual int PropertyAdd( FBProperty *Property );
00619
00624 void PropertyRemove( FBProperty* Property );
00625
00634 FBProperty* PropertyCreate( char* pName, FBPropertyType pType, char * pDataType, bool pAnimatable, bool pIsUser = false, FBProperty* pReferenceSource = NULL );
00635
00639 FBObjectFlag GetObjectFlags();
00640
00644 void SetObjectFlags(FBObjectFlag pFlags);
00645
00650 bool HasObjectFlags(FBObjectFlag pFlags);
00651
00655 void EnableObjectFlags(FBObjectFlag pFlags);
00656
00660 void DisableObjectFlags(FBObjectFlag pFlags);
00661
00666 void SetObjectStatus(FBObjectStatus pStatus, bool pValue);
00667
00671 bool GetObjectStatus(FBObjectStatus pStatus);
00672
00681 void ProcessNamespaceHierarchy( FBNamespaceAction pNamespaceAction, const char* pNamespaceName, const char* pReplaceTo=NULL, bool pAddRight=true );
00682
00687 void ProcessObjectNamespace ( FBNamespaceAction pNamespaceAction, const char* pNamespaceName, const char* pReplaceTo=NULL, bool pAddRight=true );
00688
00692 virtual char* ClassName();
00693
00697 void HardSelect();
00698
00699 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00700
00701
00702 void *operator new( size_t stAllocateBlock );
00703 void operator delete( void *pvMem );
00704
00705 void *operator new( size_t stAllocateBlock, int blockType, const char *filename, int linenumber );
00706 #if _MSC_VER >= 1200
00707 void operator delete( void *pvMem, int blockType, const char *filename, int linenumber );
00708 #endif
00709
00710
00712
00713 void RegisterPropertyEvent(FBPropertyEvent* pPropertyEvent);
00714 void UnregisterPropertyEvent(FBPropertyEvent* pPropertyEvent);
00715 void InvalidatePropertyEventsParents();
00717 #endif
00718
00719 FBPropertyManager PropertyList;
00720 FBPropertyListComponent Components;
00721 FBPropertyListComponent Parents;
00722 FBPropertyBool Selected;
00723 FBPropertyString Name;
00724 FBPropertyString LongName;
00725
00726 #if !defined(K_NO_FOLDER)
00727 FBPropertyFolder Folder;
00728 #endif
00729
00730 public:
00731 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00732 IObject_Declare(Implementation);
00733 ICallback_Declare(Implementation);
00734 #endif
00735
00740 virtual bool Is( int pTypeId );
00741 virtual int GetTypeId();
00742
00743 static void FBComponentSetName( HFBComponent pObject, char *pName );
00744 static char* FBComponentGetName( HFBComponent pObject );
00745
00746 static void FBComponentSetLongName( HFBComponent pObject, char *pName );
00747 static char* FBComponentGetLongName( HFBComponent pObject );
00748
00749
00750 public:
00751 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00752
00753 KObject* mDummyObject;
00754 void KObjectEvent(HIRegister pView, HKEventBase pEvent);
00755 #endif
00756 };
00757
00759 typedef FBComponent FBObject;
00760
00761 #ifdef RENEW
00762 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__)
00763 #undef RENEW
00764 #endif
00765
00767
00769 __FB_FORWARD( FBEvent );
00770
00774 class FBSDK_DLL FBEvent
00775 {
00776 public:
00782 FBEvent( HKEvent pEvent );
00783
00784 FBPropertyInt Type;
00785 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00786 protected:
00788 HKEventBase mEvent;
00789 public:
00791 void PropertyAdd( FBProperty* ) {};
00792 #endif
00793 };
00794
00796
00798 __FB_FORWARD( FBEventConnectionNotify );
00799
00801 class FBSDK_DLL FBEventConnectionNotify : public FBEvent
00802 {
00803 public:
00807 FBEventConnectionNotify(HKEventBase pEvent);
00808
00809 FBPropertyConnectionAction Action;
00810 FBPropertyInt SrcIndex;
00811 FBPropertyConnectionType ConnectionType;
00812 FBPropertyPlug SrcPlug;
00813 FBPropertyPlug DstPlug;
00814 FBPropertyPlug NewPlug;
00815 };
00816
00818
00820 __FB_FORWARD( FBEventConnectionDataNotify );
00821
00823 class FBSDK_DLL FBEventConnectionDataNotify : public FBEvent
00824 {
00825 public:
00829 FBEventConnectionDataNotify(HKEventBase pEvent);
00830
00831 FBPropertyConnectionAction Action;
00832 FBPropertyPlug Plug;
00833 void* GetData();
00834 void* GetOldData();
00835 };
00836
00838
00840 __FB_FORWARD( FBEventConnectionStateNotify );
00841
00843 class FBSDK_DLL FBEventConnectionStateNotify : public FBEvent
00844 {
00845 public:
00849 FBEventConnectionStateNotify(HKEventBase pEvent);
00850
00851 FBPropertyConnectionAction Action;
00852 FBPropertyPlug Plug;
00853 void* GetData();
00854 void* GetOldData();
00855 };
00856
00858
00860
00864 class FBSDK_DLL FBLibraryBase : public ICallback
00865 {
00866 public:
00867 FBLibraryBase();
00868 virtual ~FBLibraryBase();
00869 IObject_Declare(Implementation);
00870 ICallback_Declare(Implementation);
00871
00876 virtual bool LibInit();
00877
00882 virtual bool LibOpen();
00883
00889 virtual bool LibReady();
00890
00894 virtual bool LibClose();
00895
00899 virtual bool LibRelease();
00901 KGlobalNamedEvent *mLibrary_Open,
00902 *mLibrary_Ready,
00903 *mLibrary_Close,
00904 *mLibrary_Release;
00905
00906 void Library_OpenHandler(HIRegister pCaller,HKEventBase pEvent);
00907 void Library_ReadyHandler(HIRegister pCaller,HKEventBase pEvent);
00908 void Library_CloseHandler(HIRegister pCaller,HKEventBase pEvent);
00909 void Library_ReleaseHandler(HIRegister pCaller,HKEventBase pEvent);
00910 };
00911
00913
00915
00919 class FBLibrary : public FBLibraryBase
00920 {
00921 public:
00926 virtual bool LibInit();
00927
00932 virtual bool LibOpen();
00933
00939 virtual bool LibReady();
00940
00944 virtual bool LibClose();
00945
00949 virtual bool LibRelease();
00950 };
00951
00955 #if defined(K_NODLL)
00956 #define FBLibraryDeclare( LibName ) \
00957 FB_DLL_INIT( LibName, Operation ) \
00958 { \
00959 switch( Operation ) \
00960 { \
00961 case kFBDllLoad: \
00962 { \
00963
00964 #else
00965 #define FBLibraryDeclare( LibName ) \
00966 static FBLibrary LibName##GlobalFBLibrary; \
00967 extern "C" { \
00968 K_DLLEXPORT bool LIBRARY_INIT(HIError ) \
00969 { \
00970 FB_EXT_INIT( LibName ); if (LibName##GlobalFBLibrary.LibInit()) return true; return false; \
00971 } \
00972 } \
00973 FB_DLL_INIT( LibName, Operation ) \
00974 { \
00975 switch( Operation ) \
00976 { \
00977 case kFBDllLoad: \
00978 {
00979 #endif
00980
00985 #define FBLibraryModule(Name) \
00986 void FBModule##Name()
00987
00992 #define FBLibraryRegister( ClassName ) \
00993 extern void FBModule##ClassName( ); \
00994 FBModule##ClassName( );
00995
01000 #define FBLibraryRegisterStorable( ClassName ) \
01001 extern void FBModule##ClassName##Storable( ); \
01002 FBModule##ClassName##Storable( );
01003
01008 #define FBLibraryRegisterElement( ClassName ) \
01009 extern void FBModule##ClassName##Element( ); \
01010 FBModule##ClassName##Element( );
01011
01013 #define FBLibraryDeclareEnd \
01014 } \
01015 break; \
01016 default: \
01017 break; \
01018 } \
01019 }
01020
01021
01022
01026 #define FBCustomManagerImplementation( ThisComponent ) \
01027 FBClassImplementation( ThisComponent ) \
01028
01029
01032 #define FBRegisterCustomManager( ClassName ) \
01033 FBLibraryModule( ClassName ) \
01034 { \
01035 static ClassName g##ClassName; \
01036 g##ClassName.FBCreate(); \
01037 g##ClassName.RegisterManager(); \
01038 } \
01039
01040
01043 #define FBCustomManagerDeclare( ClassName ) \
01044 FBClassDeclare( ClassName, FBCustomManager ); \
01045 public: \
01046 ClassName() : FBCustomManager() { FBClassInit; } \
01047 private: \
01048
01049
01051
01053
01054 __FB_FORWARD( FBCustomManager );
01055
01068 class FBSDK_DLL FBCustomManager : public FBComponent {
01069 __FBClassDeclare( FBCustomManager, FBComponent );
01070 public:
01073 FBCustomManager();
01074
01079 void RegisterManager();
01080
01084 virtual bool FBCreate();
01085
01092 virtual bool Init() ;
01093
01099 virtual bool Open() ;
01100
01105 virtual bool Clear() ;
01106
01110 virtual bool Close() ;
01111
01112 };
01113
01114
01115 #ifdef FBSDKUseNamespace
01116 }
01117 #endif
01118
01119 #endif