Re: API / thread safe libdar

Denis Corbin <[email protected]> Thu, 17 Jun 2004 19:37:02 +0200
Newsgroups gmane.comp.sysutils.backup.dar.libdar
Organization none
Message-ID <[email protected]>
Christian Neumann wrote:
> On Wed, 16 Jun 2004 21:50:31 +0200
> Denis Corbin <[email protected]> wrote:
> 
> 
>>I could keep the use of the op_create and other API functions as
>>normal function (not class members). They received several new
>>arguments, among which, the most important is the "dialog" class (as
>>first argument). This object contains all the callback functions, as
>>defined by the libdar user. Given this object libdar is able to use
>>the appropriate callback function.
> 
> It would be nice to have the possibility to derive from this Dialog
> class, so that one could overwrite the Dialog's write() members.
> Example: (I don't know yet how you implemented it..)

First I made a mistake the real name of the class is "user_interaction" 
not "dialog"... (this was the name at specification time but as it 
replaces the whole use_interaction module, I have kept the name of the 
module).

> 
> class Dialog { // @ libdar
> private:
> void set_warning_callback(...);
> protected:
> virtual void write_warning(...);
> }

This is an interesting idea ! In the user_interaction class, the 
constructor receives two arguments (the two callback functions), and 
provides to libdar rawly two methods : pause() and warning(). So it is 
absolutely possible to have an inherited class from user_interaction 
that do not rely at all on callback function. The constructor can pass 
fake callback functions to user_interaction, and the pause() and 
warning() be overwritten. I will just add the "virtual" keyword in the 
declaration of the concerned methods.

> 
> The dialog's implementation of write_warning should call the callback
> function defined by set_write_callback(...) or sth else. So the user
> could create a Dialog, set the callback functions, and pass the Dialog
> to op_create etc.

absolutely.

> 
> But he should also be able to do something like this:
> 
> class LogWindow : public Dialog { // @ backup gui
> private:
> void add_line_to_log(...);
> void write_warning(...) { add_line_to_log(...) };
> }
> 
> The overwritten write_warning(...) would write the warning directly to
> the LogWindow, without calling any callback function. I think that
> this would result in cleaner code (but as said, one could have both
> possibilities).

100% agreed  :-)

> 
> 
> 
>>The native language support is also a feature for next major release 
>>(version 2.2.0) ;-)
> 
> That's good :) If you need a german translator, tell me ;)

sure ! I note your proposal ! ;-)

> 
> Regards,
> Christian
> 

Cheers,
Denis.



-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND