1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#ifndef __XMP_ProgressTracker_hpp__
#define __XMP_ProgressTracker_hpp__ 1
// =================================================================================================
// Copyright Adobe
// Copyright 2012 Adobe
// All Rights Reserved
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it.
// =================================================================================================
#include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header.
#include "public/include/XMP_Const.h"
#include "source/PerfUtils.hpp"
// =================================================================================================
class XMP_ProgressTracker {
public:
struct CallbackInfo {
XMP_ProgressReportWrapper wrapperProc;
XMP_ProgressReportProc clientProc;
void * context;
float interval;
bool sendStartStop;
void Clear() { this->wrapperProc = 0; this->clientProc = 0;
this->context = 0; this->interval = 1.0; this->sendStartStop = false; };
CallbackInfo() { this->Clear(); };
CallbackInfo ( XMP_ProgressReportWrapper _wrapperProc, XMP_ProgressReportProc _clientProc,
void * _context, float _interval, bool _sendStartStop )
: wrapperProc(_wrapperProc), clientProc(_clientProc),
context(_context), interval(_interval), sendStartStop(_sendStartStop) {};
};
XMP_ProgressTracker ( const CallbackInfo & _cbInfo );
void BeginWork ( float _totalWork = 0.0 );
void AddTotalWork ( float workIncrement );
void AddWorkDone ( float workIncrement );
void WorkComplete();
CallbackInfo * GetCallbackInfo() {
//return ( (&cbInfo) ? (&cbInfo) : NULL); //cbInfo is an object so its address will always be available
return (&cbInfo);
}
bool WorkInProgress() { return this->workInProgress; };
~XMP_ProgressTracker() {};
private:
XMP_ProgressTracker() { this->Clear(); }; // Hidden on purpose.
void Clear();
void NotifyClient ( bool isStartStop = false );
CallbackInfo cbInfo;
bool workInProgress;
float totalWork, workDone;
PerfUtils::MomentValue startTime, prevTime;
}; // XMP_ProgressTracker
// =================================================================================================
#endif // __XMP_ProgressTracker_hpp__
|