Author: dmacvicar
Date: Fri Jul 27 13:30:43 2007
New Revision: 6249
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6249&view=rev
Log:
- Move the sqlite3x tick logic to sqlite3x iteself, allowing to set a progress data callback instead of the hack in cached::RepoImpl
Modified:
trunk/libzypp/zypp/RepoManager.cc
trunk/libzypp/zypp/cache/sqlite3x/sqlite3x.hpp
trunk/libzypp/zypp/cache/sqlite3x/sqlite3x_connection.cpp
trunk/libzypp/zypp/repo/cached/RepoImpl.cc
trunk/libzypp/zypp/repo/cached/RepoImpl.h
Modified: trunk/libzypp/zypp/RepoManager.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=6249&r1=6248&r2=6249&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoManager.cc (original)
+++ trunk/libzypp/zypp/RepoManager.cc Fri Jul 27 13:30:43 2007
@@ -646,9 +646,11 @@
MIL << "Repository " << info.alias() << " is cached" << endl;
data::RecordId id = store.lookupRepository(info.alias());
-
+
+ CombinedProgressData subprogrcv(progress);
+
repo::cached::RepoOptions opts( info, _pimpl->options.repoCachePath, id );
- opts.readingResolvablesProgress = progressrcv;
+ opts.readingResolvablesProgress = subprogrcv;
repo::cached::RepoImpl::Ptr repoimpl =
new repo::cached::RepoImpl( opts );
Modified: trunk/libzypp/zypp/cache/sqlite3x/sqlite3x.hpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/sqlite3x/sqlite3x.hpp?rev=6249&r1=6248&r2=6249&view=diff
==============================================================================
--- trunk/libzypp/zypp/cache/sqlite3x/sqlite3x.hpp (original)
+++ trunk/libzypp/zypp/cache/sqlite3x/sqlite3x.hpp Fri Jul 27 13:30:43 2007
@@ -28,6 +28,7 @@
#include <string>
#include "zypp/base/Exception.h"
+#include "zypp/ProgressData.h"
#include
#define SQLITE3X_THROW zypp::ZYPP_THROW
@@ -40,12 +41,14 @@
friend class sqlite3_command;
friend class database_error;
struct sqlite3 *db;
+ zypp::ProgressData _ticks;
public:
sqlite3_connection();
sqlite3_connection(const char *db);
sqlite3_connection(const wchar_t *db);
- void setprogresshandler( int, int(*)(void *), void* );
+ void setprogresshandler( int,
+ const zypp::ProgressData::ReceiverFnc & );
~sqlite3_connection();
@@ -92,6 +95,8 @@
std::string executeblob(const wchar_t *sql);
std::string executeblob(const std::string &sql);
std::string executeblob(const std::wstring &sql);
+
+ int _progress_handler_accessor(void* ptr);
};
class sqlite3_command;
Modified: trunk/libzypp/zypp/cache/sqlite3x/sqlite3x_connection.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/sqlite3x/sqlite3x_connection.cpp?rev=6249&r1=6248&r2=6249&view=diff
==============================================================================
--- trunk/libzypp/zypp/cache/sqlite3x/sqlite3x_connection.cpp (original)
+++ trunk/libzypp/zypp/cache/sqlite3x/sqlite3x_connection.cpp Fri Jul 27 13:30:43 2007
@@ -36,9 +36,25 @@
#include
#include "sqlite3x.hpp"
+static int global_progress_handler(void* ptr)
+{
+ //RepoImpl *r = dynamic_cast(ptr);
+ sqlite3x::sqlite3_connection *r = (sqlite3x::sqlite3_connection *)(ptr);
+ if ( r )
+ return r->_progress_handler_accessor(ptr);
+ return 0;
+}
+
namespace sqlite3x
{
+int sqlite3_connection::_progress_handler_accessor(void* ptr)
+{
+ if ( _ticks.tick() )
+ return 0;
+ return 1;
+}
+
sqlite3_connection::sqlite3_connection() : db(NULL)
{}
@@ -57,9 +73,14 @@
if (this->db) sqlite3_close(this->db);
}
-void sqlite3_connection::setprogresshandler( int n, int(*fnc)(void*), void* ptr )
+void sqlite3_connection::setprogresshandler( int n,
+ const zypp::ProgressData::ReceiverFnc &fnc )
{
- sqlite3_progress_handler(db, n, fnc, ptr);
+ _ticks.sendTo(fnc);
+ if ( fnc )
+ sqlite3_progress_handler(db, n, global_progress_handler, (void*)this);
+ else
+ sqlite3_progress_handler(db, n, NULL, (void*)this);
}
void sqlite3_connection::open(const char *db)
Modified: trunk/libzypp/zypp/repo/cached/RepoImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/RepoImpl.cc?rev=6249&r1=6248&r2=6249&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/cached/RepoImpl.cc (original)
+++ trunk/libzypp/zypp/repo/cached/RepoImpl.cc Fri Jul 27 13:30:43 2007
@@ -67,39 +67,23 @@
MIL << "Destroying repo '" << info().alias() << "'" << endl;
}
-static int global_progress_handler(void* ptr)
-{
- //RepoImpl *r = dynamic_cast(ptr);
- RepoImpl *r = (RepoImpl *)(ptr);
- if ( r )
- return r->progress_handler(ptr);
- return 0;
-}
-
void read_capabilities( sqlite3_connection &con,
map &nvras,
ProgressData &progress );
-
-int RepoImpl::progress_handler(void* ptr)
-{
- if ( _ticks.tick() )
- return 0;
- return 1;
-}
-
void RepoImpl::createResolvables()
{
_ticks = ProgressData();
_ticks.sendTo(_options.readingResolvablesProgress);
_ticks.name(str::form(_( "Reading '%s' repository cache"), info().alias().c_str()));
-
+ CombinedProgressData subprogrcv(_ticks);
+
debug::Measure m("create resolvables");
CapFactory capfactory;
try
{
sqlite3_connection con((_options.dbdir + "zypp.db").asString().c_str());
- con.setprogresshandler(100, global_progress_handler, (void*)this);
+ con.setprogresshandler(100, subprogrcv);
con.executenonquery("PRAGMA cache_size=8000;");
con.executenonquery("BEGIN;");
@@ -187,7 +171,7 @@
}
}
con.executenonquery("COMMIT;");
- con.setprogresshandler(00, NULL, NULL);
+ con.setprogresshandler(00, ProgressData::ReceiverFnc());
}
catch(exception &ex) {
cerr << "Exception Occured: " << ex.what() << endl;
@@ -213,7 +197,7 @@
_ticks = ProgressData();
_ticks.sendTo(_options.readingPatchDeltasProgress );
_ticks.name(str::form(_( "Reading patch and delta rpms from '%s' repository cache"), info().alias().c_str()));
-
+ CombinedProgressData subprogrcv(_ticks);
try
{
sqlite3_connection con((_options.dbdir + "zypp.db").asString().c_str());
@@ -316,7 +300,7 @@
_patchRpms.push_back(patch);
}
- con.setprogresshandler(0, NULL, NULL);
+ con.setprogresshandler(0, ProgressData::ReceiverFnc());
}
catch(exception &ex) {
cerr << "Exception Occured: " << ex.what() << endl;
Modified: trunk/libzypp/zypp/repo/cached/RepoImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/cached/RepoImpl.h?rev=6249&r1=6248&r2=6249&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/cached/RepoImpl.h (original)
+++ trunk/libzypp/zypp/repo/cached/RepoImpl.h Fri Jul 27 13:30:43 2007
@@ -86,7 +86,6 @@
RepoOptions _options;
ProgressData _ticks;
public:
- int progress_handler(void*);
};
///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org