try to start with something... not definitive in any case.
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 23 Mar 2007 17:01:54 +0000 (17:01 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 23 Mar 2007 17:01:54 +0000 (17:01 +0000)
zypp2/CMakeLists.txt
zypp2/cache/CacheQuery.cc [new file with mode: 0644]
zypp2/cache/CacheQuery.h [new file with mode: 0644]
zypp2/cache/CacheStore.cpp
zypp2/cache/CacheStore.h
zypp2/cache/SQLITE3X-README.txt [new file with mode: 0644]

index b50a4e4..8a4c2cf 100644 (file)
@@ -25,6 +25,7 @@ SET( zypp2_HEADERS
 
 SET( zypp2_cache_SRCS
   cache/CacheInitializer.cpp
+  cache/CacheQuery.cc
   cache/CacheStore.cpp
   cache/Utils.cpp
 )
@@ -33,6 +34,7 @@ SET( zypp2_cache_HEADERS
   cache/CacheCommon.h
   cache/CacheInitializer.h
   cache/CacheStore.h
+  cache/CacheQuery.h
   cache/Utils.h
 )
 
@@ -62,6 +64,14 @@ SET( zypp2_source_SRCS
   source/dummy.cc
 )
 
+SET( zypp2_source_cached_SRCS
+  source/cached/CachedSourceImpl.cc
+)
+
+SET( zypp2_source_cached_HEADERS
+  source/cached/CachedSourceImpl.h
+)
+
 SET( zypp2_source_sqlite-source_SRCS
   source/sqlite-source/SqliteAccess.cc
   source/sqlite-source/SqliteAtomImpl.cc
@@ -102,6 +112,7 @@ ${zypp2_source_SRCS}
 ${zypp2_SRCS}
 ${zypp2_cache_SRCS}
 #${zypp2_source_sqlite-source_SRCS}
+${zypp2_source_cached_SRCS}
 ${zypp2_cache_sqlite3x_SRCS}
 )
 
diff --git a/zypp2/cache/CacheQuery.cc b/zypp2/cache/CacheQuery.cc
new file mode 100644 (file)
index 0000000..29ba72f
--- /dev/null
@@ -0,0 +1,93 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+
+#include <sqlite3.h>
+#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
+
+#include "zypp/base/Logger.h"
+
+#include "zypp2/cache/CacheInitializer.h"
+#include "zypp2/cache/CacheQuery.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::capability;
+using namespace zypp::cache;
+using namespace sqlite3x;
+
+class CapabilityQuery::Impl
+{
+  public:
+  Impl( sqlite3_connection &con )
+    : _con(con), _read(false)
+  {}
+  
+  sqlite3_connection &_con;
+  sqlite3_reader _reader;
+  bool _read;
+};
+
+CapabilityQuery::CapabilityQuery( Impl *impl )
+  : _pimpl( impl)
+{
+    sqlite3_command cmd(_pimpl->_con, "select * from capabilities where resolvable_id=:id;");
+    //cmd.bind(":id", id);
+  
+    sqlite3_reader reader = cmd.executereader();
+    read();
+}
+
+bool CapabilityQuery::read()
+{
+  return ( _pimpl->_read = _pimpl->_reader.read() );
+}
+  
+bool CapabilityQuery::valid() const
+{
+  return _pimpl->_read;
+}
+
+struct CacheQuery::Impl
+{
+  Impl()
+  {}
+  
+  sqlite3_connection con;
+};
+
+CacheQuery::CacheQuery( const Pathname &dbdir )
+    : _pimpl( new Impl() )
+{
+  cache::CacheInitializer initializer(dbdir, "zypp.db");
+  if ( initializer.justInitialized() )
+  {
+    MIL << "database " << (dbdir + "zypp.db") << " was just created" << endl;
+  }
+  
+  try
+  {
+    _pimpl->con.open( (dbdir + "zypp.db").asString().c_str());
+    //_insert_resolvable_cmd = new sqlite3_command( *_con, INSERT_RESOLVABLE_QUERY );                                    
+    //_insert_package_cmd = new sqlite3_command( *_con, INSERT_PACKAGE_QUERY );
+  }
+  catch(exception &ex)
+  {
+    //ZYPP_CAUGHT(ex);
+    ZYPP_THROW(Exception(ex.what()));
+  }
+}
+
+CapabilityQuery CacheQuery::createCapabilityQuery()
+{
+  return CapabilityQuery(new CapabilityQuery::Impl(_pimpl->con));
+}
+
+CacheQuery::~CacheQuery()
+{
+}
\ No newline at end of file
diff --git a/zypp2/cache/CacheQuery.h b/zypp2/cache/CacheQuery.h
new file mode 100644 (file)
index 0000000..5e00707
--- /dev/null
@@ -0,0 +1,68 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+
+
+#ifndef ZYPP_CACHE_QUERY_H
+#define ZYPP_CACHE_QUERY_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/PtrTypes.h"
+#include "zypp/Pathname.h"
+
+#include "zypp/capability/CapabilityImpl.h"
+#include "zypp/capability/Capabilities.h"
+
+#include "zypp/data/ResolvableDataConsumer.h"
+#include "zypp/data/RecordId.h"
+
+#include "zypp/base/PtrTypes.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace cache
+  { /////////////////////////////////////////////////////////////////
+    struct CapabilityQuery
+    {
+    public:
+      class Impl;
+      CapabilityQuery( Impl * );
+      bool read();
+      bool valid() const;
+    private:
+      /** Implementation. */
+      /** Pointer to implementation. */
+      RW_pointer<Impl> _pimpl;
+    };
+    
+    /**
+     * The Cache Query API provides access to the store data
+    */
+    class CacheQuery
+    {
+    public:
+      CacheQuery( const Pathname &dbdir );
+      ~CacheQuery();
+      CapabilityQuery createCapabilityQuery();
+    private:
+      /** Implementation. */
+      class Impl;
+      /** Pointer to implementation. */
+      RW_pointer<Impl> _pimpl;
+    };
+    
+  } // ns cache
+} // ns zypp
+#endif
\ No newline at end of file
index 95c827a..a6c6ebb 100644 (file)
@@ -24,7 +24,7 @@ namespace zypp
 ///////////////////////////////////////////////////////////////////
 namespace cache
 { /////////////////////////////////////////////////////////////////
-
+    
 typedef shared_ptr<sqlite3_command> sqlite3_command_ptr;
   
 struct CacheStore::Impl
index 92c822d..48aa11c 100644 (file)
@@ -32,11 +32,11 @@ namespace zypp
   ///////////////////////////////////////////////////////////////////
   namespace cache
   { /////////////////////////////////////////////////////////////////
-
+        
     /**
      * The cache store caches resolvable data into some backend.
     */
-    class CacheStore : public data::ResolvableDataConsumer
+    class CacheStore
     {
     public:
       
diff --git a/zypp2/cache/SQLITE3X-README.txt b/zypp2/cache/SQLITE3X-README.txt
new file mode 100644 (file)
index 0000000..b9ce04f
--- /dev/null
@@ -0,0 +1,2 @@
+
+http://s11n.net/sqlite/wrapper/overview-sqlite3x-sq3-2007.01.25.pdf