SET( zypp2_cache_SRCS
cache/CacheInitializer.cpp
+ cache/CacheQuery.cc
cache/CacheStore.cpp
cache/Utils.cpp
)
cache/CacheCommon.h
cache/CacheInitializer.h
cache/CacheStore.h
+ cache/CacheQuery.h
cache/Utils.h
)
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
${zypp2_SRCS}
${zypp2_cache_SRCS}
#${zypp2_source_sqlite-source_SRCS}
+${zypp2_source_cached_SRCS}
${zypp2_cache_sqlite3x_SRCS}
)
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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
///////////////////////////////////////////////////////////////////
namespace cache
{ /////////////////////////////////////////////////////////////////
-
+
typedef shared_ptr<sqlite3_command> sqlite3_command_ptr;
struct CacheStore::Impl
///////////////////////////////////////////////////////////////////
namespace cache
{ /////////////////////////////////////////////////////////////////
-
+
/**
* The cache store caches resolvable data into some backend.
*/
- class CacheStore : public data::ResolvableDataConsumer
+ class CacheStore
{
public:
--- /dev/null
+
+http://s11n.net/sqlite/wrapper/overview-sqlite3x-sq3-2007.01.25.pdf