1 | /**************************************************************************************** |
2 | |
3 | Copyright (C) 2015 Autodesk, Inc. |
4 | All rights reserved. |
5 | |
6 | Use of this software is subject to the terms of the Autodesk license agreement |
7 | provided at the time of installation or download, or which otherwise accompanies |
8 | this software in either electronic or hard copy form. |
9 | |
10 | ****************************************************************************************/ |
11 | |
12 | //! \file fbxclassid.h |
13 | #ifndef _FBXSDK_CORE_CLASSID_H_ |
14 | #define _FBXSDK_CORE_CLASSID_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/fbxsdk_nsbegin.h> |
19 | |
20 | class FbxClassIdInfo; |
21 | class FbxObject; |
22 | class FbxPropertyHandle; |
23 | class FbxManager; |
24 | |
25 | //! The function pointer type for object constructor functions. |
26 | typedef FbxObject* (*FbxObjectCreateProc)(FbxManager& pManager, const char* pName, const FbxObject* pFrom); |
27 | |
28 | /** Internal class used to differentiate objects during run-time. Essentially, each class has an unique ClassId, that the |
29 | * system can request in order to test if the class match the description. This class implement the necessary tools to be able |
30 | * to perform hierarchic class testing. This means that a class B that inherits from the class A will answer yes to a "Is A" |
31 | * query of type A or B, but will answer no to a class C that can still inherit from A. All class must inherit from FbxObject |
32 | * before they can have their own ClassId. When using the standard macros to create new types of objects in the FBX SDK, a |
33 | * static ClassId will automatically be generated for that new class. |
34 | * |
35 | * When objects are exported to an FBX file, their class type is maintained using 3 sort of strings. They are the Object Type |
36 | * string, the Object Sub Type string and the Object Type Prefix. There is no good or bad way to choose the value of these |
37 | * identifiers, but it is preferable to use meaningful values to keep the ASCII version of FBX readable and easy to understand. |
38 | * \see FbxObject */ |
39 | class FBXSDK_DLL FbxClassId |
40 | { |
41 | public: |
42 | //! Constructor. |
43 | FbxClassId(); |
44 | |
45 | /** Advanced constructor were we can specify the general parameters for this ClassId. |
46 | * \param pClassName The name of the class represented. |
47 | * \param pParentClassId The parent ClassId of this class. |
48 | * \param pConstructor A function pointer to a construction method for this ClassId. |
49 | * \param pFBXType The FBX file Object Type string associated to this class. |
50 | * \param pFBXSubType The FBX file Object Sub Type string associated to this class. */ |
51 | FbxClassId(const char* pClassName, const FbxClassId& pParentClassId, FbxObjectCreateProc pConstructor=0, const char* pFBXType=NULL, const char* pFBXSubType=NULL); |
52 | |
53 | //! Destructor. |
54 | void Destroy(); |
55 | |
56 | /** Retrieve the class name. |
57 | * \return The class identification string name. */ |
58 | const char* GetName() const; |
59 | |
60 | /** Retrieve the parent ClassId. |
61 | * \return The parent ClassId. */ |
62 | FbxClassId GetParent() const; |
63 | |
64 | /** Create an instance of this class. |
65 | * \param pManager The FBX SDK Manager to be used to instantiate this object. This allow the object to use the same memory manager as the provided manager. |
66 | * \param pName The name to assign to this new object instance. |
67 | * \param pFrom An object to clone if it matches the same ClassId. This is an optional parameter. |
68 | * \return The newly created instance of this class. */ |
69 | FbxObject* Create(FbxManager& pManager, const char* pName, const FbxObject* pFrom); |
70 | |
71 | /** Override the function pointer method to construct this object. |
72 | * \param pConstructor A newly defined function pointer to a construction method to replace the existing one. |
73 | * \return True if the operation was successful. */ |
74 | bool Override(FbxObjectCreateProc pConstructor); |
75 | |
76 | /** Test if this class is a hierarchical children of the specified class type. This is the standard method to differentiate object classes. |
77 | * \param pId The class type to test against self. |
78 | * \return True if the object is a hierarchical children of the type specified. |
79 | * \remark This function will perform a complete search until it reaches the top level class, but it will stop as soon as one ClassId matches the test. */ |
80 | bool Is(const FbxClassId& pId) const; |
81 | |
82 | /** Equivalence operator. |
83 | * \param pClassId The class type to test against self. |
84 | * \return \c true if the ClassId is exactly the same, \c false otherwise. |
85 | * \remark This function only perform direct equality test, and doesn't test hierarchic children. */ |
86 | bool operator==(const FbxClassId& pClassId) const; |
87 | |
88 | /** Inequivalence operator. |
89 | * \param pClassId The class type to test against self. |
90 | * \return \c true if the ClassId is not the same, \c false otherwise. |
91 | * \remark This function only perform direct inequality test, and doesn't test hierarchic children. */ |
92 | bool operator!=(const FbxClassId& pClassId) const; |
93 | |
94 | /** Retrieve the FBX file Object Type string associated to this class. |
95 | * \param pAskParent If \c true, retrieve the parent ClassId, but only if self ClassId is not valid. |
96 | * \return The FBX file Object Type string associated to this class. */ |
97 | const char* GetFbxFileTypeName(bool pAskParent=false) const; |
98 | |
99 | /** Retrieve the FBX file Object Sub Type string associated to this class. |
100 | * \return The FBX file Object Sub Type string associated to this class. */ |
101 | const char* GetFbxFileSubTypeName() const; |
102 | |
103 | /** Find out if self ClassId is valid or not. |
104 | * \return \c true if self ClassId is valid, \c false otherwise. */ |
105 | inline bool IsValid() const { return mClassInfo ? true : false; } |
106 | |
107 | /** Set the Object Type Prefix string associated to this class. This will change the "ObjectTypePrefix::" found in front |
108 | * of object name in the FBX file. This is useful to differentiate objects by their name without using the Object Type or |
109 | * Sub Type strings in the file. |
110 | * \param pObjectTypePrefix The Object Type prefix string. */ |
111 | void SetObjectTypePrefix(const char* pObjectTypePrefix); |
112 | |
113 | /** Retrieve the Object Type Prefix string associated to this class. |
114 | * \return The Object Type Prefix string. */ |
115 | const char* GetObjectTypePrefix(); |
116 | |
117 | /** Retrieve the root property handle of this class. This is useful to access the default property hierarchy for this |
118 | * class. This allow users to retrieve information such as the default value for all properties of this class. |
119 | * \return The root property handle for this class. */ |
120 | FbxPropertyHandle* GetRootClassDefaultPropertyHandle(); |
121 | |
122 | /** Increase the instance reference count for this class type. |
123 | * \return the new count of reference to this class after increment. */ |
124 | int ClassInstanceIncRef(); |
125 | |
126 | /** Decrease the instance reference count for this class type. |
127 | * \return the new count of reference to this class after decrement. */ |
128 | int ClassInstanceDecRef(); |
129 | |
130 | /** Retrieve the instance reference count for this class type. |
131 | * \return The reference count of this class type. */ |
132 | int GetInstanceRef(); |
133 | |
134 | /***************************************************************************************************************************** |
135 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
136 | *****************************************************************************************************************************/ |
137 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
138 | inline FbxClassIdInfo* GetClassIdInfo() { return mClassInfo; } |
139 | inline const FbxClassIdInfo* GetClassIdInfo() const { return mClassInfo; } |
140 | |
141 | private: |
142 | FbxClassId(FbxClassIdInfo* mClassInfo); |
143 | |
144 | bool SetFbxFileTypeName(const char* pName); |
145 | bool SetFbxFileSubTypeName(const char* pName); |
146 | |
147 | FbxClassIdInfo* mClassInfo; |
148 | |
149 | friend class FbxManager; |
150 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
151 | }; |
152 | |
153 | //! Functor to compare FbxClassId |
154 | struct FbxClassIdCompare |
155 | { |
156 | inline int operator()(const FbxClassId& pKeyA, const FbxClassId& pKeyB) const |
157 | { |
158 | const FbxClassIdInfo* lKeyA = pKeyA.GetClassIdInfo(); |
159 | const FbxClassIdInfo* lKeyB = pKeyB.GetClassIdInfo(); |
160 | return lKeyA < lKeyB ? -1 : (lKeyA > lKeyB ? 1 : 0); |
161 | } |
162 | }; |
163 | |
164 | #include <fbxsdk/fbxsdk_nsend.h> |
165 | |
166 | #endif /* _FBXSDK_CORE_CLASSID_H_ */ |
167 | |