| 1 |
#ifndef __XMP_ProgressTracker_hpp__ |
| 2 |
#define __XMP_ProgressTracker_hpp__ 1 |
| 3 |
|
| 4 |
// ================================================================================================= |
| 5 |
// Copyright Adobe |
| 6 |
// Copyright 2012 Adobe |
| 7 |
// All Rights Reserved |
| 8 |
// |
| 9 |
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms |
| 10 |
// of the Adobe license agreement accompanying it. If you have received this file from a source other |
| 11 |
// than Adobe, then your use, modification, or distribution of it requires the prior written permission |
| 12 |
// of Adobe. |
| 13 |
// ================================================================================================= |
| 14 |
|
| 15 |
#if AdobePrivate |
| 16 |
// ================================================================================================= |
| 17 |
// Change history |
| 18 |
// ============== |
| 19 |
// |
| 20 |
// Writers: |
| 21 |
// AWL Alan Lillich |
| 22 |
// AB Amit Bhatti |
| 23 |
// |
| 24 |
// mm-dd-yy who Description of changes, most recent first. |
| 25 |
// |
| 26 |
// 01-05-15 AB 5.6-f122 Provide more functionalities to Plugin( Existing XMP packet, PacketInfo, OpenFlags, Error Callback and progress notification), |
| 27 |
// more standard handler access API getFileModDate,IsMetadataWritable,putXMP,getAssociatedResources. |
| 28 |
// New plugin handler for MPEG4 with Exif support. |
| 29 |
// |
| 30 |
// 06-22-12 AWL 5.5-f019 Add file update progress tracking to the MPEG-4 handler. |
| 31 |
// 06-20-12 AWL 5.5-f018 Add outer layers for XMPFiles progress notifications, no handlers use it yet. |
| 32 |
// |
| 33 |
// ================================================================================================= |
| 34 |
#endif // AdobePrivate |
| 35 |
|
| 36 |
#include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. |
| 37 |
|
| 38 |
#include "public/include/XMP_Const.h" |
| 39 |
|
| 40 |
#include "source/PerfUtils.hpp" |
| 41 |
|
| 42 |
// ================================================================================================= |
| 43 |
|
| 44 |
class XMP_ProgressTracker { |
| 45 |
public: |
| 46 |
|
| 47 |
struct CallbackInfo { |
| 48 |
|
| 49 |
XMP_ProgressReportWrapper wrapperProc; |
| 50 |
XMP_ProgressReportProc clientProc; |
| 51 |
void * context; |
| 52 |
float interval; |
| 53 |
bool sendStartStop; |
| 54 |
|
| 55 |
void Clear() { this->wrapperProc = 0; this->clientProc = 0; |
| 56 |
this->context = 0; this->interval = 1.0; this->sendStartStop = false; }; |
| 57 |
CallbackInfo() { this->Clear(); }; |
| 58 |
CallbackInfo ( XMP_ProgressReportWrapper _wrapperProc, XMP_ProgressReportProc _clientProc, |
| 59 |
void * _context, float _interval, bool _sendStartStop ) |
| 60 |
: wrapperProc(_wrapperProc), clientProc(_clientProc), |
| 61 |
context(_context), interval(_interval), sendStartStop(_sendStartStop) {}; |
| 62 |
|
| 63 |
}; |
| 64 |
|
| 65 |
XMP_ProgressTracker ( const CallbackInfo & _cbInfo ); |
| 66 |
|
| 67 |
void BeginWork ( float _totalWork = 0.0 ); |
| 68 |
void AddTotalWork ( float workIncrement ); |
| 69 |
void AddWorkDone ( float workIncrement ); |
| 70 |
void WorkComplete(); |
| 71 |
CallbackInfo * GetCallbackInfo() { |
| 72 |
//return ( (&cbInfo) ? (&cbInfo) : NULL); //cbInfo is an object so its address will always be available |
| 73 |
return (&cbInfo); |
| 74 |
} |
| 75 |
|
| 76 |
bool WorkInProgress() { return this->workInProgress; }; |
| 77 |
|
| 78 |
~XMP_ProgressTracker() {}; |
| 79 |
|
| 80 |
private: |
| 81 |
|
| 82 |
XMP_ProgressTracker() { this->Clear(); }; // Hidden on purpose. |
| 83 |
|
| 84 |
void Clear(); |
| 85 |
void NotifyClient ( bool isStartStop = false ); |
| 86 |
|
| 87 |
CallbackInfo cbInfo; |
| 88 |
bool workInProgress; |
| 89 |
float totalWork, workDone; |
| 90 |
PerfUtils::MomentValue startTime, prevTime; |
| 91 |
|
| 92 |
}; // XMP_ProgressTracker |
| 93 |
|
| 94 |
// ================================================================================================= |
| 95 |
|
| 96 |
#endif // __XMP_ProgressTracker_hpp__ |