- Main Page
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# fbxconnectionpoint.h

Go to the documentation of this file.

    00001 /****************************************************************************************
    00002
    00003    Copyright (C) 2012 Autodesk, Inc.
    00004    All rights reserved.
    00005
    00006    Use of this software is subject to the terms of the Autodesk license agreement
    00007    provided at the time of installation or download, or which otherwise accompanies
    00008    this software in either electronic or hard copy form.
    00009
    00010 ****************************************************************************************/
    00011
    00013 #ifndef _FBXSDK_CORE_CONNECTION_POINT_H_
    00014 #define _FBXSDK_CORE_CONNECTION_POINT_H_
    00015
    00016 #include <fbxsdk/fbxsdk_def.h>
    00017
    00018 #include <fbxsdk/core/base/fbxarray.h>
    00019 #include <fbxsdk/core/base/fbxmemory.h>
    00020
    00021 #include <fbxsdk/fbxsdk_nsbegin.h>
    00022
    00023 class FBXSDK_DLL FbxConnection
    00024 {
    00025 public:
    00026     enum EType
    00027     {
    00028         eNone = 0,
    00029         // System or user
    00030         eSystem = 1 << 0,
    00031         eUser = 1 << 1,
    00032         eSystemOrUser = eUser | eSystem,
    00033         // Type of Link
    00034         eReference = 1 << 2,
    00035         eContains = 1 << 3,
    00036         eData = 1 << 4,
    00037         eLinkType = eReference | eContains | eData,
    00038         eDefault = eUser | eReference,
    00039         eUnidirectional = 1 << 7
    00040     };
    00041 };
    00042
    00043 class FbxConnectionPointFilter;
    00044
    00045 class FBXSDK_DLL FbxConnectionPoint
    00046 {
    00047 public:
    00048     enum EDirection
    00049     {
    00050         eDirSrc = 1 << 0,   // Contains sources
    00051         eDirDst = 1 << 1,   // Contains destinations
    00052         eDirUni = 1 << 2,   // Connection is not 2 ways
    00053         eDirBoth = eDirSrc | eDirDst,
    00054         eDirMask = eDirSrc | eDirDst | eDirUni
    00055     };
    00056
    00057     enum EType
    00058     {
    00059         eStandard = 0,
    00060         eSubConnection = 1 << 3,        // Connect is a sub Connect of another
    00061         eTypeMask = eSubConnection
    00062     };
    00063
    00064     enum EAttribute
    00065     {
    00066         eDefault = 0,
    00067         eCache = 1 << 4,
    00068         eAttributeMask = eCache
    00069     };
    00070
    00071     enum EAllocFlag
    00072     {
    00073         eNotAllocated = 0,
    00074         eAllocated = 1 << 5,
    00075         eAllocFlagMask = eAllocated
    00076     };
    00077
    00078     enum ECleanedFlag
    00079     {
    00080         eNotCleaned = 0,
    00081         eCleaned = 1 << 6,
    00082         eCleanedFlagMask = eCleaned
    00083     };
    00084
    00085     // --------------------------------------------
    00086     // Actions
    00087     // --------------------------------------------
    00088     enum EEvent
    00089     {
    00090         eSrcConnectRequest,
    00091         eDstConnectRequest,
    00092
    00093         eSrcConnect,
    00094         eDstConnect,
    00095         eSrcConnected,
    00096         eDstConnected,
    00097
    00098         eSrcDisconnect,
    00099         eDstDisconnect,
    00100         eSrcDisconnected,
    00101         eDstDisconnected, //do not destroy Connect on disconnected
    00102
    00103         eSrcReplaceBegin,
    00104         eSrcReplaceEnd,
    00105         eDstReplaceBegin,
    00106         eDstReplaceEnd,
    00107
    00108         eSrcReorder,
    00109         eSrcReordered
    00110     };
    00111
    00112     class ConnectionList
    00113     {
    00114     public:
    00115         ConnectionList();
    00116         ~ConnectionList();
    00117
    00118         void Clear();
    00119
    00120         // Src
    00121         void InsertSrcAt(int pIndex, FbxConnectionPoint* pConnect, FbxConnection::EType pType);
    00122         void AddSrc(FbxConnectionPoint* pConnect, FbxConnection::EType pType);
    00123         void RemoveSrcAt(int pIndex);
    00124         int FindSrc(FbxConnectionPoint* pConnect) const;
    00125         int GetSrcCount() const;
    00126         FbxConnectionPoint* GetSrc(int pIndex) const;
    00127         FbxConnection::EType GetSrcType(int pIndex) const;
    00128
    00129         // Dst
    00130         void InsertDstAt(int pIndex, FbxConnectionPoint* pConnect, FbxConnection::EType pType);
    00131         void AddDst(FbxConnectionPoint* pConnect, FbxConnection::EType pType);
    00132         void RemoveDstAt(int pIndex);
    00133         int FindDst(FbxConnectionPoint* pConnect) const;
    00134         int GetDstCount() const;
    00135         FbxConnectionPoint* GetDst(int pIndex) const;
    00136         FbxConnection::EType GetDstType(int pIndex) const;
    00137
    00138     protected:
    00139         FbxArray<FbxConnectionPoint*>   mList;
    00140         FbxArray<char>                  mType;
    00141         int                             mSrcCount, mDstCount;
    00142     };
    00143
    00144     // Constructor/Destructor
    00145     FbxConnectionPoint(void* pData=0);
    00146     virtual ~FbxConnectionPoint();
    00147
    00148     void SetFilter(FbxConnectionPointFilter* pConnectFilter, EType pType=eStandard);
    00149     void InternalClear();
    00150
    00152     void WipeConnectionList();
    00153     void Destroy();
    00154     void SubConnectRemoveAll();
    00155
    00156     inline FbxConnectionPoint* GetSubOwnerConnect(){ return GetConnectType()==eSubConnection ? mOwner : NULL; }
    00157     inline FbxConnectionPointFilter* GetFilter(){ return mFilter; }
    00158
    00159     virtual bool        IsInReplace(FbxConnectionPoint* p1, FbxConnectionPoint* p2);
    00160
    00161     inline void         SetConnectType(EType pType){ mFlags = (mFlags & ~eTypeMask) | pType; }
    00162     inline EType        GetConnectType(){ return EType(mFlags & eTypeMask); }
    00163     inline void         SetDirection(int pDirections){ mFlags = (mFlags & ~eDirMask) | pDirections; }
    00164     inline EDirection   GetDirection(){ return EDirection(mFlags & eDirMask); }
    00165     inline void         SetAttribute(int pAttributes){ mFlags = (mFlags & ~eAttributeMask) | pAttributes; }
    00166     inline EAttribute   GetAttribute(){ return EAttribute(mFlags & eAttributeMask); }
    00167     inline void         SetAllocatedFlag(bool pBool){ mFlags = ( pBool ) ? mFlags | eAllocated : mFlags & ~eAllocFlagMask; }
    00168     inline bool         GetAllocatedFlag(){ return ( mFlags & eAllocFlagMask ) ? true : false; }
    00169     inline void         SetCleanedFlag(bool pBool){ mFlags = ( pBool ) ? mFlags | eCleaned : mFlags & ~eCleanedFlagMask; }
    00170     inline bool         GetCleanedFlag(){ return ( mFlags & eCleanedFlagMask ) ? true : false; }
    00171
    00172     bool                IsValidSrc(FbxConnectionPoint* pConnect);
    00173     bool                IsValidDst(FbxConnectionPoint* pConnect);
    00174     bool                IsValidSrcConnection(FbxConnectionPoint* pConnect,FbxConnection::EType pConnectionType);
    00175     bool                IsValidDstConnection(FbxConnectionPoint* pConnect,FbxConnection::EType pConnectionType);
    00176     bool                RequestValidSrcConnection(FbxConnectionPoint* pConnect,FbxConnection::EType pConnectionType );
    00177     bool                RequestValidDstConnection(FbxConnectionPoint* pConnect,FbxConnection::EType pConnectionType );
    00178
    00179     // Connection services
    00180     bool            ConnectSrc          (FbxConnectionPoint* pSrc,FbxConnection::EType pConnectionType = FbxConnection::eNone );
    00181     bool            ConnectDst          (FbxConnectionPoint* pDst,FbxConnection::EType pConnectionType = FbxConnection::eNone );
    00182     bool            ConnectSrcAt        (int pDst_SrcIndex, FbxConnectionPoint* pSrc, FbxConnection::EType pConnectionType = FbxConnection::eNone );
    00183     bool            ConnectDstAt        (int pSrc_DstIndex, FbxConnectionPoint* pDst, FbxConnection::EType pConnectionType = FbxConnection::eNone );
    00184     static bool     ConnectConnect      (FbxConnectionPoint* pSrc,FbxConnectionPoint* pDst,FbxConnection::EType pConnectionType );
    00185     static bool     ConnectAt           (FbxConnectionPoint* pSrc,int pSrc_DstIndex,FbxConnectionPoint* pDst,int pDst_SrcIndex,FbxConnection::EType pConnectionType  );
    00186
    00187     bool            DisconnectDst       (FbxConnectionPoint* pSrc);
    00188     bool            DisconnectSrc       (FbxConnectionPoint* pSrc);
    00189     void            DisconnectAllSrc    ();
    00190     void            DisconnectAllDst    ();
    00191     static bool     DisconnectConnect   (FbxConnectionPoint* pSrc,FbxConnectionPoint* pDst);
    00192     bool            DisconnectDstAt     (int pIndex);
    00193     bool            DisconnectSrcAt     (int pIndex);
    00194
    00195     bool            ReplaceInDst        (FbxConnectionPoint* pDstOld,FbxConnectionPoint* pDstNew, int pIndexInNew);
    00196     bool            ReplaceInSrc        (FbxConnectionPoint* pSrcOld,FbxConnectionPoint* pSrcNew, int pIndexInNew);
    00197     bool            ReplaceDstAt        (int pIndex,FbxConnectionPoint* pDst);
    00198     bool            ReplaceSrcAt        (int pIndex,FbxConnectionPoint* pSrc);
    00199     bool            SwapSrc             (int pIndexA,int pIndexB);
    00200
    00207     bool MoveSrcAt(int pIndex, int pAtIndex);
    00208
    00215     bool MoveSrcAt(FbxConnectionPoint* pSrc, FbxConnectionPoint* pAtSrc);
    00216
    00217     // Access services
    00218     bool IsConnectedSrc(FbxConnectionPoint*);
    00219     bool IsConnectedDst(FbxConnectionPoint*);
    00220     inline bool IsConnected(FbxConnectionPoint* pConnect) { return IsConnectedSrc(pConnect) || IsConnectedDst(pConnect); }
    00221
    00222     inline int                  GetSrcCount() const { return mConnectionList.GetSrcCount(); }
    00223     inline FbxConnectionPoint*  GetSrc(int pIndex) const { return mConnectionList.GetSrc(pIndex);}
    00224     inline FbxConnection::EType GetSrcType(int pIndex) const { return mConnectionList.GetSrcType(pIndex);}
    00225     inline int                  GetDstCount() const { return mConnectionList.GetDstCount(); }
    00226     inline FbxConnectionPoint*  GetDst(int pIndex) const { return mConnectionList.GetDst(pIndex);}
    00227     inline FbxConnection::EType GetDstType(int pIndex) const { return mConnectionList.GetDstType(pIndex);}
    00228
    00229     inline int                  FindSrc(FbxConnectionPoint* pConnect){ return mConnectionList.FindSrc(pConnect); }
    00230     inline int                  FindDst(FbxConnectionPoint* pConnect){ return mConnectionList.FindDst(pConnect); }
    00231
    00232     // Filtered versions
    00233     inline int                  GetSrcCount(FbxConnectionPointFilter* pFilter){ return (pFilter) ? SubConnectGetOrCreate(pFilter)->GetSrcCount() : GetSrcCount(); }
    00234     inline FbxConnectionPoint*  GetSrc(int pIndex,FbxConnectionPointFilter* pFilter){ return (pFilter) ? SubConnectGetOrCreate(pFilter)->GetSrc(pIndex) : GetSrc(pIndex); }
    00235     inline FbxConnection::EType GetSrcType(int pIndex,FbxConnectionPointFilter* pFilter){ return (pFilter) ? SubConnectGetOrCreate(pFilter)->GetSrcType(pIndex) : GetSrcType(pIndex); }
    00236     inline int                  GetDstCount(FbxConnectionPointFilter* pFilter){ return (pFilter) ? SubConnectGetOrCreate(pFilter)->GetDstCount() : GetDstCount(); }
    00237     inline FbxConnectionPoint*  GetDst(int pIndex,FbxConnectionPointFilter* pFilter){ return (pFilter) ? SubConnectGetOrCreate(pFilter)->GetDst(pIndex): GetDst(pIndex); }
    00238     inline FbxConnection::EType GetDstType(int pIndex,FbxConnectionPointFilter* pFilter){ return (pFilter) ? SubConnectGetOrCreate(pFilter)->GetDstType(pIndex) : GetDstType(pIndex); }
    00239
    00240     void* GetData(){ return mData; }
    00241
    00242 protected:
    00243     void SubConnectAdd(FbxConnectionPoint* pConnect);
    00244     void SubConnectRemove(FbxConnectionPoint* pConnect);
    00245     FbxConnectionPoint* SubConnectFind(FbxConnectionPointFilter* pFilter);
    00246     FbxConnectionPoint* SubConnectGetOrCreate(FbxConnectionPointFilter* pFilter);
    00247     void SubConnectFill(FbxConnectionPoint* pConnect);
    00248
    00249     // Connections
    00250     virtual bool ConnectNotify(EEvent pAction,FbxConnectionPoint* pThis,int pIndex,FbxConnectionPoint* pConnect = NULL,FbxConnection::EType pConnectionType=FbxConnection::eNone,FbxConnectionPoint* pNewConnect=NULL );
    00251     virtual void ConnectCleanUp(FbxConnectionPoint* pThis); //Call after disconnected
    00252
    00253     int FindSrcIndexFromOwnerConnectIndex(FbxConnectionPoint* pOwner,int pOwnerIndex);
    00254     int FindDstIndexFromOwnerConnectIndex(FbxConnectionPoint* pOwner,int pOwnerIndex);
    00255
    00262     bool InternalMoveSrcBefore( int pIndex, int pBeforeIndex );
    00263
    00264     // Internal Access
    00265 private:
    00266     inline void InsertSrcAt(int pIndex,FbxConnectionPoint* pConnect,FbxConnection::EType pConnectionType){ mConnectionList.InsertSrcAt(pIndex,pConnect,pConnectionType); }
    00267     inline void InsertDstAt(int pIndex,FbxConnectionPoint* pConnect,FbxConnection::EType pConnectionType){ mConnectionList.InsertDstAt(pIndex,pConnect,pConnectionType); }
    00268     inline void RemoveSrcAt(int pIndex){ mConnectionList.RemoveSrcAt(pIndex); }
    00269     inline void RemoveDstAt(int pIndex){ mConnectionList.RemoveDstAt(pIndex); }
    00270
    00271     static bool InternalConnectBefore (FbxConnectionPoint* pSrc,FbxConnectionPoint* pSrc_BeforeDst,FbxConnectionPoint* pDst,FbxConnectionPoint* pDst_BeforeSrc,FbxConnection::EType pConnectionType );
    00272     static bool UserConnectBefore (FbxConnectionPoint* pSrc,FbxConnectionPoint* pSrc_BeforeDst,FbxConnectionPoint* pDst,FbxConnectionPoint* pDst_BeforeSrc,FbxConnection::EType pConnectionType );
    00273     static bool EmitReplaceNotify(FbxConnectionPoint* pDstOwner, FbxConnectionPoint* pSrcOwner, FbxConnectionPoint* pDst, FbxConnectionPoint* pSrc, EEvent pConnectAction, FbxConnectionPoint* pNew);
    00274
    00275     // Owner ship management
    00276     virtual bool SetOwnerConnect(FbxConnectionPoint* pConnect);
    00277     inline FbxConnectionPoint* GetOwnerConnect(){ return mOwner;  }
    00278     bool ConnectOwnedConnect(FbxConnectionPoint* pConnect);
    00279     bool DisconnectOwnedConnect(FbxConnectionPoint* pConnect);
    00280
    00281     //Connection Data
    00282     void*                           mData;
    00283     int                             mFlags;
    00284     FbxConnectionPoint*             mOwner;
    00285     ConnectionList                  mConnectionList;
    00286
    00287     //SubConnection Data
    00288     FbxArray<FbxConnectionPoint*>   mSubConnectList;
    00289     FbxArray<FbxConnectionPoint*>   mSubConnectCreatedList;
    00290     FbxConnectionPointFilter*       mFilter;
    00291 };
    00292
    00296 class FBXSDK_DLL FbxConnectionPointFilter
    00297 {
    00298 public:
    00303
    00304         FbxConnectionPointFilter(){}
    00305
    00307         virtual ~FbxConnectionPointFilter();
    00309
    00314
    00315         virtual FbxConnectionPointFilter* Ref();
    00316
    00318         virtual void Unref();
    00319
    00321         virtual FbxInt GetUniqueId() const { return 0; }
    00322
    00327         virtual bool IsValid(FbxConnectionPoint* pConnect) const;
    00328
    00334         virtual bool IsValidConnection(FbxConnectionPoint* pConnect, FbxConnection::EType pType) const;
    00335
    00340         virtual bool IsEqual(FbxConnectionPointFilter* pConnectFilter) const;
    00342 };
    00343
    00344 #include <fbxsdk/fbxsdk_nsend.h>
    00345
    00346 #endif /* _FBXSDK_CORE_CONNECTION_POINT_H_ */