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
15protected:
16 ProgressMonitor() = default;
17
18public:
19 virtual ~ProgressMonitor() = default;
20
21
22#ifndef SWIG
23 const PDProgressMonitor* monitor() const { return &m_monitor; }
24 void* userdata() { return this; }
25#endif
26
32 virtual void BeginOperation(double start, double end) {}
33
37 virtual void EndOperation() {}
38
43 virtual void SetCurrentValue(double value) {}
44
49 virtual bool IsCanceled() const { return false; }
50
51private:
52 static PDErrCode PDFSDK_CALLCONV BeginOp(void* clientData, double progressMin, double progressMax) {
53 PDFSDK_CALLBACK_BEGIN
54 ProgressMonitor* monitor = static_cast<ProgressMonitor*>(clientData);
55 monitor->BeginOperation(progressMin, progressMax);
56 return kPDErrSuccess;
57 PDFSDK_CALLBACK_END
58 }
59
60 static PDErrCode PDFSDK_CALLCONV EndOp(void* clientData) {
61 PDFSDK_CALLBACK_BEGIN
62 ProgressMonitor* monitor = static_cast<ProgressMonitor*>(clientData);
63 monitor->EndOperation();
64 return kPDErrSuccess;
65 PDFSDK_CALLBACK_END
66 }
67
68 static PDErrCode PDFSDK_CALLCONV SetValue(void* clientData, double value) {
69 PDFSDK_CALLBACK_BEGIN
70 ProgressMonitor* monitor = static_cast<ProgressMonitor*>(clientData);
71 monitor->SetCurrentValue(value);
72 return kPDErrSuccess;
73 PDFSDK_CALLBACK_END
74 }
75
76 static PDErrCode PDFSDK_CALLCONV IsCanceled(void* clientData, bool* pCanceled) {
77 PDFSDK_CALLBACK_BEGIN
78 ProgressMonitor* monitor = static_cast<ProgressMonitor*>(clientData);
79 *pCanceled = monitor->IsCanceled();
80 return kPDErrSuccess;
81 PDFSDK_CALLBACK_END
82 }
83
84private:
85 PDProgressMonitor m_monitor = {
86 &ProgressMonitor::BeginOp,
87 &ProgressMonitor::EndOp,
88 &ProgressMonitor::SetValue,
90 };
91};
92
93} // namespace PDF
94
95#endif // PDFSDK_CXX_PROGRESS_MONITOR_H_INCLUDED_
Progress monitor for tracking the progress of an operation.
Definition progress_monitor.h:14
virtual void BeginOperation(double start, double end)
Called when an operation begins.
Definition progress_monitor.h:32
virtual void EndOperation()
Called when an operation ends.
Definition progress_monitor.h:37
virtual bool IsCanceled() const
Check if the operation has been canceled.
Definition progress_monitor.h:49
virtual void SetCurrentValue(double value)
Called to set the current value of the progress.
Definition progress_monitor.h:43
@ kPDErrSuccess
Operation was successful.
Definition errors.h:18
int32_t PDErrCode
Definition errors.h:44
Progress Monitor API.
Definition progress_monitor.h:15