On Monday 05 September 2011 11:19:16 Duncan Mac-Vicar P. wrote:
- A C task-oriented API would allow zypper, YaST and PackageKit to deduplicate code and if the API is good, nice bindings.
zypper, YaST and PackageKit are actuallty C++ consumers, so it might make sense to design the API also as simple C++ API which should be straight forward to wrap to C: class Foo { Foo(); ~Foo(); int method( const char * arg ); int method( std::string arg ) { return method( arg.c_str() ); } int method( Capability arg ) { return method( arg.c_str() ); } }; ---- Foo* foo_init() { return new Foo; } void foo_delete(Foo* p) { delete p; } int foo_method( Foo*p, const char * arg ) { return p->method( arg ); } [ int foo_method_2( Foo*p, Capability * arg ); ] Within libzypp many stringbased types like Capability, Arch, Edition, .. exist. Most of them are just an index into the satsolvers string pool and the methods just wrap corresponding calls in libsatsolver. But it's quite convenient to have them as different types if you have a compiler that checks. Another - more important - reason for wrapping almost all satsolver 'classes' in libzypp (C++) is the need to write exception safe code. Each resource allocation (foo_init) which requires a corresponding release action (foo_delete) will have to be wrapped into a class to prevent resource leaks if exeptions were thrown. We probably do not want zypper, YaST and PackageKit to wrap back the C task-oriented API into C++. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres SUSE LINUX Products GmbH, Development, ma@suse.de GF:Jeff Hawn,Jennifer Guild,Felix Imendörffer, HRB16746(AG Nürnberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org