Mailinglist Archive: zypp-devel (115 mails)
| < Previous | Next > |
[zypp-devel] Callbacks and reports proposal
- From: Duncan Mac-Vicar Prett <dmacvicar@xxxxxxx>
- Date: Tue, 10 Jul 2007 14:21:18 +0200
- Message-id: <200707101421.19122.dmacvicar@xxxxxxx>
I have been trying different approaches for progress reporting
Here is one of my proposals:
New report ProgressReport
struct ProgressReport : public callback::ReportBase
{
virtual void start( const ProgressData &/*task*/ )
virtual bool progress( const ProgressData &/*task*/ )
virtual void finish( const ProgressData &/*task*/ )
};
Most of the methods of ZYpp time consuming tasks accept a ProgressData
function, so if you reuse a ZYpp parser in a small program, you can setup
your own progress callback.
The idea is that RepoManager functions use an ProgressReportAdaptor internally
that appart of sending the progress to the user callback, it also sends it to
the global ProgressReport. The reports get the complete progress object, and
from it they can get a unique runtime id for the task, text, and progress
value.
I just implemented the receiver for ZYpper like this:
struct ProgressReportReceiver : public
zypp::callback::ReceiveReport<zypp::ProgressReport>
{
virtual void start( const zypp::ProgressData &data )
{
display_progress ( data.name() , data.min() );
}
virtual bool progress( const zypp::ProgressData &data )
{
display_progress ( data.name() , data.val() );
return true;
}
virtual void finish( const zypp::ProgressData &data )
{
display_progress ( data.name() , data.max() );
}
};
The nice thing is, with this we could remove all Source*Reports. Only internal
reports like media change and download needs to be kept.
Internally, ZYpp uses ProgressData and CombinedProgress data to produce quite
nice estimates for progress.
If you like the idea, I would add later (next week?)
an Error class (or use Exception), a Message class, and provide in the same
report perhaps some generic user interaction like continue-cancel, press-ok,
etc.
--
Duncan Mac-Vicar Prett
Novell :: SUSE R&D, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
| < Previous | Next > |