PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
progress_monitor.h
1// Copyright (c) 2009-2025 Avanquest Software. All rights reserved.
2
3#ifndef PDFSDK_CXX_PROGRESS_MONITOR_H_INCLUDED_
4#define PDFSDK_CXX_PROGRESS_MONITOR_H_INCLUDED_
5
6#include <pdfsdk/cxx/callback.h>
8
9namespace PDF {
10
14class ProgressMonitor {
15protected:
16 ProgressMonitor() = default;
17
18public:
19 virtual ~ProgressMonitor() = default;
20
21#ifndef SWIG
22 const PDProgressMonitor* monitor() const { return &m_monitor; }
23 void* userdata() { return this; }
24#endif
25
31 virtual void BeginOperation(double /*start*/, double /*end*/) { /* intentionally empty */ }
32
36 virtual void EndOperation() {}
37
42 virtual void SetCurrentValue(double /*value*/) { /* intentionally empty */ }
43
48 virtual bool IsCanceled() const { return false; }
49
50private:
51 static PDErrCode PDFSDK_CALLCONV BeginOp(void* clientData, double progressMin, double progressMax) {
52 PDFSDK_CALLBACK_BEGIN
53 ProgressMonitor* monitor = static_cast<ProgressMonitor*>(clientData);
54 monitor->BeginOperation(progressMin, progressMax);
55 return kPDErrSuccess;
56 PDFSDK_CALLBACK_END
57 }
58
59 static PDErrCode PDFSDK_CALLCONV EndOp(void* clientData) {
60 PDFSDK_CALLBACK_BEGIN
61 ProgressMonitor* monitor = static_cast<ProgressMonitor*>(clientData);
62 monitor->EndOperation();
63 return kPDErrSuccess;
64 PDFSDK_CALLBACK_END
65 }
66
67 static PDErrCode PDFSDK_CALLCONV SetValue(void* clientData, double value) {
68 PDFSDK_CALLBACK_BEGIN
69 ProgressMonitor* monitor = static_cast<ProgressMonitor*>(clientData);
70 monitor->SetCurrentValue(value);
71 return kPDErrSuccess;
72 PDFSDK_CALLBACK_END
73 }
74
75 static PDErrCode PDFSDK_CALLCONV IsCanceled(void* clientData, bool* pCanceled) {
76 PDFSDK_CALLBACK_BEGIN
77 ProgressMonitor* monitor = static_cast<ProgressMonitor*>(clientData);
78 *pCanceled = monitor->IsCanceled();
79 return kPDErrSuccess;
80 PDFSDK_CALLBACK_END
81 }
82
83private:
84 PDProgressMonitor m_monitor = {
85 &ProgressMonitor::BeginOp,
86 &ProgressMonitor::EndOp,
87 &ProgressMonitor::SetValue,
89 };
90};
91
92} // namespace PDF
93
94#endif // PDFSDK_CXX_PROGRESS_MONITOR_H_INCLUDED_
Progress monitor for tracking the progress of an operation.
Definition progress_monitor.h:14
virtual void SetCurrentValue(double)
Called to set the current value of the progress.
Definition progress_monitor.h:42
virtual void EndOperation()
Called when an operation ends.
Definition progress_monitor.h:36
virtual void BeginOperation(double, double)
Called when an operation begins.
Definition progress_monitor.h:31
virtual bool IsCanceled() const
Check if the operation has been canceled.
Definition progress_monitor.h:48
@ kPDErrSuccess
Operation was successful.
Definition errors.h:18
int32_t PDErrCode
Definition errors.h:44
Progress Monitor API.
Definition progress_monitor.h:15