fbxprogress.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_FILEIO_PROGRESS_H_
00014 #define _FBXSDK_FILEIO_PROGRESS_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/base/fbxstring.h>
00019 
00020 #include <fbxsdk/fbxsdk_nsbegin.h>
00021 
00022 #define FBXSDK_PROGRESS_UPDATE_THRESHOLD 0.5f
00023 
00024 typedef bool (*FbxProgressCallback)(float pPercentage, FbxString pStatus);
00025 
00026 class FbxSpinLock;
00027 
00031 class FBXSDK_DLL FbxProgress
00032 {
00033 public:
00034     FbxProgress();
00035     ~FbxProgress();
00036     
00040     void SetTotal(float pTotal);
00041 
00046     void Add(float pDetaWorkload, const FbxString & pStatus);
00047 
00049     void Reset();
00050 
00054     void Complete(const FbxString & pStatus);
00055 
00060     float GetProgress(FbxString & pStatus) const;
00061 
00065     void SetProgressCallback(FbxProgressCallback pCallback);
00066 
00070     void Cancel(bool pIsCanceled)
00071     {
00072         mCanceled = pIsCanceled;
00073     }
00074 
00076     bool IsCanceled() const
00077     {
00078         return mCanceled;
00079     }
00080 
00081 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00082 
00083 private:
00084     float GetPercentage() const;
00085     FbxSpinLock *mLock;
00086     float mTotal;
00087     float mCurrent;
00088     FbxString mStatus;
00089     float mUpdateThreshold;
00090     float mLastCallbackProgress;
00091     FbxProgressCallback mCallback;
00092     bool mCanceled;
00093 
00094 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00095 
00096 };
00097 
00098 #include <fbxsdk/fbxsdk_nsend.h>
00099 
00100 #endif /* _FBXSDK_FILEIO_PROGRESS_H_ */