Author: dmacvicar
Date: Thu Apr 19 18:56:11 2007
New Revision: 5417
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5417&view=rev
Log:
add ResolvableQuery....
Added:
trunk/libzypp/zypp2/cache/ResolvableQuery.cc
trunk/libzypp/zypp2/cache/ResolvableQuery.h
Modified:
trunk/libzypp/zypp2/CMakeLists.txt
Modified: trunk/libzypp/zypp2/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/CMakeLists.txt?rev=5417&r1=5416&r2=5417&view=diff
==============================================================================
--- trunk/libzypp/zypp2/CMakeLists.txt (original)
+++ trunk/libzypp/zypp2/CMakeLists.txt Thu Apr 19 18:56:11 2007
@@ -27,6 +27,7 @@
cache/CacheInitializer.cpp
cache/QueryFactory.cc
cache/CapabilityQuery.cc
+ cache/ResolvableQuery.cc
cache/CachedResolvableDataProvider.cc
cache/sqlite_detail/CapabilityQueryImpl.cc
cache/sqlite_detail/QueryFactoryImpl.cc
@@ -39,6 +40,7 @@
cache/CacheCommon.h
cache/CacheInitializer.h
cache/CacheStore.h
+ cache/ResolvableQuery.h
cache/CapablityQuery.h
cache/QueryFactory.h
cache/Utils.h
Added: trunk/libzypp/zypp2/cache/ResolvableQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQuery.cc?rev=5417&view=auto
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.cc (added)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.cc Thu Apr 19 18:56:11 2007
@@ -0,0 +1,61 @@
+
+#include "zypp2/cache/ResolvableQuery.h"
+#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
+
+using namespace sqlite3x;
+
+namespace zypp { namespace cache {
+
+
+struct ResolvableQuery::Impl
+{
+ Impl( const Pathname &dbdir, ProcessResolvable fnc )
+ : _dbdir(dbdir), _fnc(fnc)
+ {}
+
+ ~Impl()
+ {
+ }
+
+
+ void query( const data::RecordId &id )
+ {
+ sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
+ //con.executenonquery("PRAGMA cache_size=8000;");
+ con.executenonquery("BEGIN;");
+ sqlite3_command cmd( con, "select * from resolvables where id=:id;");
+ cmd.bind(":id", id);
+ sqlite3_reader reader = cmd.executereader();
+ while(reader.read())
+ {
+
+ }
+ con.executenonquery("COMMIT;");
+ }
+
+ void query( const std::string &s )
+ {
+
+ }
+
+ Pathname _dbdir;
+ ProcessResolvable _fnc;
+};
+
+ResolvableQuery::ResolvableQuery( const Pathname &dbdir, ProcessResolvable fnc )
+ : _pimpl(new Impl(dbdir, fnc))
+{
+}
+
+void ResolvableQuery::query( const data::RecordId &id )
+{
+ _pimpl->query(id);
+}
+
+void ResolvableQuery::query( const std::string &s )
+{
+ _pimpl->query(s);
+}
+
+
+} } // namespace zypp::cache
Added: trunk/libzypp/zypp2/cache/ResolvableQuery.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQuery.h?rev=5417&view=auto
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.h (added)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.h Thu Apr 19 18:56:11 2007
@@ -0,0 +1,64 @@
+
+#ifndef ZYPP_CACHE_RESOLVABLE_QUERY_H
+#define ZYPP_CACHE_RESOLVABLE_QUERY_H
+
+#include "zypp/base/Function.h"
+#include "zypp/Pathname.h"
+#include "zypp/data/ResolvableData.h"
+#include "zypp/data/RecordId.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace cache
+ { /////////////////////////////////////////////////////////////////
+
+ /**
+ * Allows to iterate around the capabilities in
+ * the cache.
+ * Use \ref CacheQuery to create this query.
+ *
+ * \code
+ * CacheQuery query(dbdir);
+ * CapabilityQuery capquery = query.createCapabilityQuery( zypp::Dep::REQUIRES, 1 );
+ * cout << capquery.value() << endl;
+ * while ( capquery.read() )
+ * {
+ * // value is a CapablityImpl::Ptr
+ * cout << capquery.value() << endl;
+ * }
+ * \endcode
+ */
+ struct ResolvableQuery
+ {
+ public:
+ /**
+ * Callback definition
+ * first parameter is the resolvable id.
+ * second parameter is a \ref data::ResObjectData object with the resource
+ */
+ typedef function