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 fbxstatistics.h |
13 | #ifndef _FBXSDK_FILEIO_STATISTICS_H_ |
14 | #define _FBXSDK_FILEIO_STATISTICS_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/core/base/fbxarray.h> |
19 | #include <fbxsdk/core/base/fbxstring.h> |
20 | |
21 | #include <fbxsdk/fbxsdk_nsbegin.h> |
22 | |
23 | /** This class is a basic class to get the quantity of items. |
24 | * User processes the statistics raw data by deriving FbxStatistics class and overrides \c AddItem method. |
25 | * When overriding \c AddItem method, User must store item's name and item's count by pair which means |
26 | * The index of one item's name in array \c mItemName is the same as the index of this item's count in array \c mItemCount. |
27 | * |
28 | * \code Here is a code snippet to show how it used. |
29 | * //Define my own statistics class. |
30 | * class MyStatistics : public FbxStatistics |
31 | * { |
32 | * public: |
33 | virtual bool AddItem(FbxString& pItemName, int pItemCount) |
34 | { |
35 | mItemName.Add( FbxSdkNew< FbxString >(pItemName) ); |
36 | mItemCount.Add( pItemCount); |
37 | return true; |
38 | }; |
39 | * }; |
40 | * |
41 | * FbxManager* lSdkManager = FbxManager::Create(); |
42 | * FbxScene* lScene = FbxScene::Create( lSdkManager, "Scene"); |
43 | * FbxNode* lNode1 = FbxNode::Create(lScene, "Node1"); |
44 | * FbxNode* lNode2 = FbxNode::Create(lScene, "Node2"); |
45 | * FbxNode* lNode3 = FbxNode::Create(lScene, "Node3"); |
46 | * FbxNode* lNode4 = FbxNode::Create(lScene, "Node4"); |
47 | * lScene.AddNode(lNode1); |
48 | * lScene.AddNode(lNode2); |
49 | * lScene.AddNode(lNode3); |
50 | * MyStatistics lStatistics; |
51 | * lStatistics.AddItem("Node_Count", lScene.GetNodeCount() ); |
52 | * FbxString lItemName; |
53 | * int lItemCount; |
54 | * if( lStatistics.GetItemPair( 0, lItemName, lItemCount)) |
55 | * { |
56 | * //do something |
57 | * } |
58 | * \endcode |
59 | |
60 | * \nosubgrouping |
61 | */ |
62 | class FBXSDK_DLL FbxStatistics |
63 | { |
64 | public: |
65 | /// \name Constructor and Destructor. |
66 | //@{ |
67 | FbxStatistics(); |
68 | virtual ~FbxStatistics(); |
69 | //@} |
70 | |
71 | //! Reset the statistics. |
72 | void Reset(); |
73 | |
74 | //! Get the number of items. |
75 | int GetNbItems() const; |
76 | |
77 | /** Get the statistics information by pair. |
78 | * \param pNum The index of statistics data to be got. |
79 | * \param pItemName Output the item's name. |
80 | * \param pItemCount Output the item's count. |
81 | * \return \c True if successful, \c False otherwise. |
82 | */ |
83 | bool GetItemPair(int pNum, FbxString& pItemName, int& pItemCount) const; |
84 | |
85 | /** Assignment operator. |
86 | * \param pStatistics FbxStatistics assigned to this one. |
87 | */ |
88 | FbxStatistics& operator=(const FbxStatistics& pStatistics); |
89 | |
90 | protected: |
91 | /** virtual function to define the process of the incoming statistics data. |
92 | * \param pItemName The item's name |
93 | * \param pItemCount The item's count. |
94 | * \return False. |
95 | */ |
96 | virtual bool AddItem(FbxString& /*pItemName*/, int /*pItemCount*/) { return false; }; |
97 | |
98 | //! An array to store item's name. |
99 | FbxArray<FbxString*> mItemName; |
100 | |
101 | //! An array to store item's count. |
102 | FbxArray<int> mItemCount; |
103 | }; |
104 | |
105 | #include <fbxsdk/fbxsdk_nsend.h> |
106 | |
107 | #endif /* _FBXSDK_FILEIO_STATISTICS_H_ */ |
108 | |