#include <pdfwriter.h>
Public Member Functions | |
| ProgressObserver (IProgressBar *pB) | |
| virtual | ~ProgressObserver () throw () |
| void | notify (boost::shared_ptr< OperationStep > newValue, boost::shared_ptr< const observer::IChangeContext< OperationStep > > context) const throw () |
| observer::IObserver < OperationStep >::priority_t | getPriority () const throw () |
Private Attributes | |
| IProgressBar * | progressBar |
| bool | started |
Prograss bar observer. Simple observer which holds IProgressBar implementator. Observer interface implementation delegates progress visualization to maintained progressBar field which is provided in constructor. notify method also recognizes progress start and end and announces this fact to progressBar by IProgressBar::start and IProgressBar::finish methods.
Instance should be created with IProgressBar implementator as constructor parameter and registered to ObserverHandler which supports OperationStep typed observers.
| pdfobjects::utils::ProgressObserver::ProgressObserver | ( | IProgressBar * | pB | ) | [inline] |
Initialization constructor.
| pB | ProgressBar visualizator. |
Sets progressBar field with given parameter. It may be NULL, when no progress is displayed. started field is initialized to false.
| virtual pdfobjects::utils::ProgressObserver::~ProgressObserver | ( | ) | throw () [inline, virtual] |
Virtual destructor.
If started is true and progressBar is non NULL (progress is running now and it is displayed) calls progressBar->finish() and then deallocates progressBar instance.
References pdfobjects::utils::IProgressBar::finish(), progressBar, and started.
| observer::IObserver<OperationStep>::priority_t pdfobjects::utils::ProgressObserver::getPriority | ( | ) | const throw () [inline, virtual] |
| void pdfobjects::utils::ProgressObserver::notify | ( | boost::shared_ptr< OperationStep > | newValue, | |
| boost::shared_ptr< const observer::IChangeContext< OperationStep > > | context | |||
| ) | const throw () |
Observer notification method.
| newValue | Current step of progress. | |
| context | Context of progress. |
This method is called by observed object when progress has changed. If progressBar implementation is not provided, skips all further steps.
If no progress has started yet (started is false), calls IProgressBar::start and IProgressBar::setMaxStep (with ScopedChangeContext::getScope()total value).
Then updates progress with given newValue (calls IProgressBar::update).
Finally checks whether current step is last one and if so, sets started back to false and calls IProgressBar::finish method.
References pdfobjects::utils::IProgressBar::finish(), progressBar, observer::ScopedChangeContextType, pdfobjects::utils::IProgressBar::setMaxStep(), pdfobjects::utils::IProgressBar::start(), started, and pdfobjects::utils::IProgressBar::update().
Implementation of progress bar. This instance is responsible for progress visualization. It is set in constructor. Instance is deallocated in destructor.
Referenced by notify(), and ~ProgressObserver().
bool pdfobjects::utils::ProgressObserver::started [mutable, private] |
Flag for started progress. This flag is set to false by default and it is changed when first notification comes and it changed back when all operations are performed.
Referenced by notify(), and ~ProgressObserver().