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 fbxsymbol.h |
13 | #ifndef _FBXSDK_CORE_SYMBOL_H_ |
14 | #define _FBXSDK_CORE_SYMBOL_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/core/base/fbxstring.h> |
19 | #include <fbxsdk/core/base/fbxmap.h> |
20 | |
21 | #include <fbxsdk/fbxsdk_nsbegin.h> |
22 | |
23 | /** Defines a symbol string. A symbol string is a string that is unique and stored in a global symbol table. |
24 | * \nosubgrouping */ |
25 | class FBXSDK_DLL FbxSymbol |
26 | { |
27 | public: |
28 | /** |
29 | * \name Constructors and Destructor |
30 | */ |
31 | //@{ |
32 | |
33 | /** Constructor. |
34 | * Construct a symbol and add it to global symbol table. |
35 | * \param pName Symbol name. |
36 | * \param pRealm The real value for this symbol. |
37 | */ |
38 | FbxSymbol(const char* pName, const char* pRealm); |
39 | |
40 | //! Destructor. |
41 | ~FbxSymbol(); |
42 | //@} |
43 | |
44 | /** |
45 | * \name Access function. |
46 | */ |
47 | //@{ |
48 | /** |
49 | * Get ID in global symbol table. |
50 | * \return Symbol ID in global symbol table. |
51 | */ |
52 | unsigned int GetID() const; |
53 | //@} |
54 | |
55 | /** |
56 | * \name Symbol comparison |
57 | */ |
58 | //@{ |
59 | /** Equality operator. |
60 | * \param pSymbol The symbol to be compared. |
61 | */ |
62 | bool operator==(FbxSymbol const& pSymbol) const; |
63 | |
64 | /** Inequality operator. |
65 | * \param pSymbol The symbol to be compared. |
66 | */ |
67 | bool operator!=(FbxSymbol const& pSymbol) const; |
68 | //@} |
69 | |
70 | private: |
71 | unsigned int mID; |
72 | }; |
73 | |
74 | typedef FbxMap< FbxString, int, FbxStringCompare > FbxStringSymbolMap; |
75 | |
76 | |
77 | /** This class is to mark a string as symbol. |
78 | * String Symbol only has its name. |
79 | * /remarks Each symbol is unique. That means there are no symbols which have the same name. |
80 | * \nosubgrouping */ |
81 | class FBXSDK_DLL FbxStringSymbol |
82 | { |
83 | public: |
84 | /** |
85 | * \name Constructors and Destructor |
86 | */ |
87 | //@{ |
88 | |
89 | //! Default constructor. |
90 | FbxStringSymbol(); |
91 | |
92 | /** Constructor. |
93 | * Construct a symbol and add it to global symbol table. |
94 | * \param pName Symbol name. |
95 | */ |
96 | FbxStringSymbol(const char* pName); |
97 | |
98 | //! Copy constructor. |
99 | FbxStringSymbol(const FbxStringSymbol& pOther); |
100 | |
101 | //! Destructor. |
102 | ~FbxStringSymbol(); |
103 | //@} |
104 | |
105 | //! Cast operator to const char* type. |
106 | inline operator const char*() const { return mItem ? ((const char*) mItem->GetKey()) : NULL; } |
107 | |
108 | |
109 | /** Determine the symbol empty or not. |
110 | * \return \c true if empty. \c false otherwise. |
111 | */ |
112 | inline bool IsEmpty() const |
113 | { |
114 | return !mItem || mItem->GetKey().IsEmpty(); |
115 | } |
116 | |
117 | //! Static function to allocate global string symbol map. |
118 | static void AllocateGlobalStringSymbolMap(); |
119 | |
120 | //! Static function to deallocate global string symbol map. |
121 | static void FreeGlobalStringSymbolMap(); |
122 | |
123 | /** Assignment operator. |
124 | * \param pName The symbol value. |
125 | * \return The self after assignment. |
126 | */ |
127 | FbxStringSymbol& operator=(const char* pName); |
128 | |
129 | private: |
130 | FbxStringSymbolMap::RecordType* mItem; |
131 | }; |
132 | |
133 | #include <fbxsdk/fbxsdk_nsend.h> |
134 | |
135 | #endif /* _FBXSDK_CORE_SYMBOL_H_ */ |
136 | |