On 09/06/2011 02:58 PM, Michael Andres wrote:
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 ); ]
That sounds reasonable. What do you think about this API? The indented functions are the granular versions of the parent methods. handler create(string root) error easy_init(handler) `-> error read_repos(handler) `-> error read_system(handler) iter query_whatprovides(hander, string what) iter query_search(handler, string what) iter query_updates(handler) error install_by_capability(string what) `-> error mark_to_install_by_capability(string what) `-> error resolve(zpm *, callback) `-> error commit(*zpm) error install(handler, solvable s) `-> error mark_to_install(handler, solvable s) `-> error resolve(handler) `-> error commit(handler) destroy(handler) So if you do easy_init you could accomplish the same doing read_repos and read_system. Same with installing a package compared to marking it, resolving and commiting. We should think all operations and what is the big task and how it could be made granular as well. -- Duncan Mac-Vicar P. - http://www.suse.com/ SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5, 90409 Nürnberg, Germany -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org