Author: mlandres
Date: Wed May 23 22:45:51 2007
New Revision: 5621
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5621&view=rev
Log:
added ResolvableDataConsumer interface for source packages
Modified:
trunk/libzypp/zypp/data/ResolvableDataConsumer.h
trunk/libzypp/zypp2/cache/CacheStore.cpp
trunk/libzypp/zypp2/cache/CacheStore.h
trunk/libzypp/zypp2/parser/susetags/RepoParser.cc
Modified: trunk/libzypp/zypp/data/ResolvableDataConsumer.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableDataConsumer.h?rev=5621&r1=5620&r2=5621&view=diff
==============================================================================
--- trunk/libzypp/zypp/data/ResolvableDataConsumer.h (original)
+++ trunk/libzypp/zypp/data/ResolvableDataConsumer.h Wed May 23 22:45:51 2007
@@ -29,6 +29,7 @@
virtual ~ResolvableDataConsumer();
virtual void consumePackage( const data::RecordId &catalog_id, data::Package_Ptr ) = 0;
+ virtual void consumeSourcePackage( const data::RecordId &catalog_id, data::SrcPackage_Ptr ) = 0;
virtual void consumeProduct( const data::RecordId &catalog_id, data::Product_Ptr ) = 0;
virtual void consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr ) = 0;
virtual void consumePackageAtom( const data::RecordId &catalog_id, const data::PackageAtom_Ptr & ) = 0;
@@ -38,8 +39,6 @@
virtual void consumeChangelog( const data::RecordId & catalog_id, const data::Resolvable_Ptr &, const Changelog & ) = 0;
virtual void consumeFilelist( const data::RecordId & catalog_id, const data::Resolvable_Ptr &, const data::Filenames & ) = 0;
-
- //virtual void consumeSourcePackage( const data::SrcPackage_Ptr ) = 0;
};
} // namespace parser
Modified: trunk/libzypp/zypp2/cache/CacheStore.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.cpp?rev=5621&r1=5620&r2=5621&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.cpp (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.cpp Wed May 23 22:45:51 2007
@@ -39,7 +39,7 @@
{
MIL << "database " << (dbdir + "zypp.db") << " was just created" << endl;
}
-
+
try
{
con.open( (dbdir + "zypp.db").asString().c_str());
@@ -51,62 +51,62 @@
//ZYPP_CAUGHT(ex);
ZYPP_THROW(Exception(ex.what()));
}
-
-
+
+
// initialize all pre-compiled statements
-
+
insert_resolvable_in_catalog_cmd.reset( new sqlite3_command( con, "insert into resolvables_catalogs (resolvable_id, catalog_id) values (:resolvable_id, :catalog_id);" ));
-
+
update_catalog_cmd.reset( new sqlite3_command( con, "update catalogs set checksum=:checksum, timestamp=:timestamp where id=:catalog_id;" ));
-
+
select_catalog_cmd.reset( new sqlite3_command( con, "select id from catalogs where url=:url and path=:path;" ));
insert_catalog_cmd.reset( new sqlite3_command( con, "insert into catalogs (url,path,timestamp) values (:url,:path,:timestamp);" ));
-
+
select_name_cmd.reset( new sqlite3_command( con, "select id from names where name=:name;" ));
insert_name_cmd.reset( new sqlite3_command( con, "insert into names (name) values (:name);" ));
-
+
select_dirname_cmd.reset( new sqlite3_command( con, "select id from dir_names where name=:name;" ));
insert_dirname_cmd.reset( new sqlite3_command( con, "insert into dir_names (name) values (:name);" ));
-
+
select_filename_cmd.reset( new sqlite3_command( con, "select id from file_names where name=:name;" ));
insert_filename_cmd.reset( new sqlite3_command( con, "insert into file_names (name) values (:name);" ));
-
+
select_file_cmd.reset( new sqlite3_command( con, "select id from files where dir_name_id=:dir_name_id and file_name_id=:file_name_id;" ));
insert_file_cmd.reset( new sqlite3_command( con, "insert into files (dir_name_id,file_name_id) values (:dir_name_id,:file_name_id);" ));
-
+
select_type_cmd.reset( new sqlite3_command( con, "select id from types where class=:class and name=:name;" ));
insert_type_cmd.reset( new sqlite3_command( con, "insert into types (class,name) values (:class,:name);" ));
-
+
set_shared_flag_cmd.reset( new sqlite3_command( con, "update resolvables set shared_id=:shared_id where id=:resolvable_id;" ));
-
+
append_text_attribute_cmd.reset( new sqlite3_command( con, "insert into text_attributes ( weak_resolvable_id, lang_id, attr_id, text ) values ( :rid, :lang_id, :attr_id, :text );" ));
append_num_attribute_cmd.reset( new sqlite3_command( con, "insert into numeric_attributes ( weak_resolvable_id, attr_id, value ) values ( :rid, :attr_id, :value );" ));
-
+
//insert_dependency_entry_cmd.reset( new sqlite3_command( con, "insert into capabilities ( resolvable_id, dependency_type, refers_kind ) values ( :resolvable_id, :dependency_type, :refers_kind );" ));
append_file_dependency_cmd.reset( new sqlite3_command( con, "insert into file_capabilities ( resolvable_id, dependency_type, refers_kind, file_id ) values ( :resolvable_id, :dependency_type, :refers_kind, :file_id );" ));
append_named_dependency_cmd.reset( new sqlite3_command( con, "insert into named_capabilities ( resolvable_id, dependency_type, refers_kind, name_id, version, release, epoch, relation ) values ( :resolvable_id, :dependency_type, :refers_kind, :name_id, :version, :release, :epoch, :relation );" ));
-
+
append_modalias_dependency_cmd.reset( new sqlite3_command( con, "insert into modalias_capabilities ( resolvable_id, dependency_type, refers_kind, name, value, relation ) values ( :resolvable_id, :dependency_type, :refers_kind, :name, :value, :relation );" ));
-
+
append_hal_dependency_cmd.reset( new sqlite3_command( con, "insert into hal_capabilities ( resolvable_id, dependency_type, refers_kind, name, value, relation ) values ( :resolvable_id, :dependency_type, :refers_kind, :name, :value, :relation );" ));
-
+
append_other_dependency_cmd.reset( new sqlite3_command( con, "insert into other_capabilities ( resolvable_id, dependency_type, refers_kind, value ) values ( :resolvable_id, :dependency_type, :refers_kind, :value );" ));
-
+
append_resolvable_cmd.reset( new sqlite3_command( con, "insert into resolvables ( name, version, release, epoch, arch, kind, catalog_id ) values ( :name, :version, :release, :epoch, :arch, :kind, :catalog_id );" ));
-
+
count_shared_cmd.reset( new sqlite3_command( con, "select count(id) from resolvables where shared_id=:rid;" ));
-
-
-
+
+
+
// disable autocommit
con.executenonquery("BEGIN;");
}
-
+
Impl()
{
Impl( getZYpp()->homePath() );
}
-
+
~Impl()
{
MIL << "name cache hits: " << name_cache_hits << " | cache size: " << name_cache.size() << endl;
@@ -138,7 +138,7 @@
sqlite3_command_ptr select_type_cmd;
sqlite3_command_ptr insert_type_cmd;
-
+
//sqlite3_command_ptr insert_dependency_entry_cmd;
sqlite3_command_ptr append_file_dependency_cmd;
@@ -151,11 +151,11 @@
sqlite3_command_ptr append_text_attribute_cmd;
sqlite3_command_ptr append_num_attribute_cmd;
-
+
sqlite3_command_ptr set_shared_flag_cmd;
-
+
sqlite3_command_ptr count_shared_cmd;
-
+
map name_cache;
map< pair, RecordId> type_cache;
int name_cache_hits;
@@ -165,7 +165,7 @@
CacheStore::CacheStore( const Pathname &dbdir )
: _pimpl( new Impl(dbdir) )
{
-
+
}
CacheStore::CacheStore()
@@ -188,7 +188,7 @@
{
RecordId pkgid = appendResolvable( catalog_id, ResTraits<Package>::kind, NVRA( package->name, package->edition, package->arch ), package->deps );
consumeResObject( pkgid, package );
-
+
appendStringAttribute( pkgid, "Package", "checksum", package->repositoryLocation.fileChecksum.checksum() );
appendStringAttribute( pkgid, "Package", "buildhost", package->buildhost );
appendStringAttribute( pkgid, "Package", "distribution", package->distribution );
@@ -200,17 +200,22 @@
appendStringAttribute( pkgid, "Package", "postin", package->postin );
appendStringAttribute( pkgid, "Package", "preun", package->preun );
appendStringAttribute( pkgid, "Package", "postun", package->postun );
-
+
//FIXME save authors and keyword (lists) for packages
-
+
appendStringAttribute( pkgid, "Package", "location", package->repositoryLocation.filePath.asString() );
}
+void CacheStore::consumeSourcePackage( const data::RecordId &catalog_id, data::SrcPackage_Ptr srcpackage )
+{
+#warning TBD
+}
+
void CacheStore::consumePatch( const data::RecordId &catalog_id, data::Patch_Ptr patch)
{
RecordId id = appendResolvable( catalog_id, ResTraits<Patch>::kind, NVRA( patch->name, patch->edition, patch->arch ), patch->deps );
consumeResObject( id, patch );
-
+
DBG << "got patch " << patch->name << ", atoms: ";
// cosume atoms
for (setdata::ResObject_Ptr::const_iterator p = patch->atoms.begin();
@@ -588,7 +593,7 @@
//_pimpl->name_cache_hits++;
return _pimpl->type_cache[thetype];
}
-
+
_pimpl->select_type_cmd->bind(":class", klass);
_pimpl->select_type_cmd->bind(":name", name);
long long id = 0;
@@ -676,12 +681,12 @@
const data::RecordId &shared_id )
{
_pimpl->set_shared_flag_cmd->bind(":resolvable_id", resolvable_id);
-
+
if ( shared_id == data::noRecordId )
_pimpl->set_shared_flag_cmd->bind(":shared_id");
else
_pimpl->set_shared_flag_cmd->bind(":shared_id", shared_id);
-
+
_pimpl->set_shared_flag_cmd->executenonquery();
}
@@ -701,9 +706,9 @@
// weak resolvable_id
_pimpl->append_num_attribute_cmd->bind(":rid", resolvable_id );
_pimpl->append_num_attribute_cmd->bind(":attr_id", type_id );
-
+
_pimpl->append_num_attribute_cmd->bind(":value", value );
-
+
_pimpl->append_num_attribute_cmd->executenonquery();
}
@@ -758,9 +763,9 @@
_pimpl->append_text_attribute_cmd->bind(":rid", resolvable_id );
_pimpl->append_text_attribute_cmd->bind(":lang_id", lang_id );
_pimpl->append_text_attribute_cmd->bind(":attr_id", type_id );
-
+
_pimpl->append_text_attribute_cmd->bind(":text", value );
-
+
_pimpl->append_text_attribute_cmd->executenonquery();
}
Modified: trunk/libzypp/zypp2/cache/CacheStore.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.h?rev=5621&r1=5620&r2=5621&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.h (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.h Wed May 23 22:45:51 2007
@@ -38,7 +38,7 @@
*
* \code
* CacheStore store("/path");
- * RecordId catalog_id =
+ * RecordId catalog_id =
* store.lookupOrAppendCatalog("http://updates.novell.com", "/");
* store.consumePackage( catalog_id, package_ptr );
* store.commit();
@@ -68,7 +68,7 @@
* Commit the changes.
*/
void commit();
-
+
/**
* Implementation of the \ref ResolvableConsumer interface
*
@@ -77,7 +77,16 @@
* \param package Package data
*/
virtual void consumePackage( const data::RecordId &catalog_id, data::Package_Ptr package);
-
+
+ /**
+ * Implementation of the \ref ResolvableConsumer interface
+ *
+ * Consume a source package, inserting it in the cache, under
+ * \param catalog_id ownership.
+ * \param srcpackage Source package data
+ */
+ virtual void consumeSourcePackage( const data::RecordId &catalog_id, data::SrcPackage_Ptr srcpackage );
+
/**
* Implementation of the \ref ResolvableConsumer interface
*
@@ -92,12 +101,12 @@
*
* Consume a package atom, inserting it in the cache, under
* \a catalog_id ownership.
- *
+ *
* \param catalog_id record id of catalog to which to append the resolvable.
* \param atom package atom data
*
* \note this is somewhat specific to current YUM patch metadata design
- * and may change (to consumeAtom(data::RecordId,data::Atom)).
+ * and may change (to consumeAtom(data::RecordId,data::Atom)).
*/
virtual void consumePackageAtom( const data::RecordId &catalog_id, const data::PackageAtom_Ptr & atom );
@@ -109,7 +118,7 @@
* \param message Message data
*/
virtual void consumeMessage( const data::RecordId &catalog_id, data::Message_Ptr);
-
+
/**
* Implementation of the \ref ResolvableConsumer interface
*
@@ -118,7 +127,7 @@
* \param script Script data
*/
virtual void consumeScript( const data::RecordId &catalog_id, data::Script_Ptr);
-
+
/**
* Implementation of the \ref ResolvableConsumer interface
*
@@ -136,7 +145,7 @@
* \param pattern Pattern data
*/
virtual void consumeProduct( const data::RecordId &catalog_id, data::Product_Ptr product );
-
+
/**
* Implementation of the \ref ResolvableConsumer interface
*
@@ -324,7 +333,7 @@
void appendUnknownDependency( const data::RecordId &resolvable_id,
zypp::Dep deptype,
capability::CapabilityImpl::Ptr cap );
-
+
/**
* Returns the record id of a type
*
@@ -339,7 +348,7 @@
*/
data::RecordId lookupOrAppendType( const std::string &klass,
const std::string &name );
-
+
/**
* Returns the record id of a catalog (Source)
*
@@ -352,7 +361,7 @@
*/
data::RecordId lookupOrAppendCatalog( const Url &url,
const Pathname &path );
-
+
/**
* Set the resolvable shared data flag pointing to
* another resolvable.
@@ -382,7 +391,7 @@
const std::string &klass,
const std::string &name,
int value );
-
+
/**
* Append a translated string value to a resolvable
* \param resolvable_id Resovable Id, owner of the attribute
@@ -394,7 +403,7 @@
const std::string &klass,
const std::string &name,
const TranslatedText &text );
-
+
/**
* Append a string value to a resolvable
* \param resolvable_id Resovable Id, owner of the attribute
@@ -408,7 +417,7 @@
const std::string &klass,
const std::string &name,
const std::string &text );
-
+
/**
* Append a string value to a resolvable
* \param resolvable_id Resovable Id, owner of the attribute
@@ -420,7 +429,7 @@
const std::string &klass,
const std::string &name,
const std::string &value );
-
+
/**
* Append a string value to a resolvable
* \param resolvable_id Resovable Id, owner of the attribute
@@ -430,8 +439,8 @@
void appendStringAttribute( const data::RecordId &resolvable_id,
const data::RecordId &type_id,
const std::string &value );
-
-
+
+
/**
* Update a known catalog checksum and timestamp
*
@@ -490,12 +499,12 @@
*/
// data::RecordId appendDependencyEntry( const data::RecordId &,
// zypp::Dep, const Resolvable::Kind & );
-
+
void appendStringAttribute( const data::RecordId &resolvable_id,
const data::RecordId &lang_id,
const data::RecordId &type_id,
const std::string &value );
-
+
/**
* Append a numeric attribute to a resolvable
* \param resolvable_id Resovable Id, owner of the attribute
@@ -505,8 +514,8 @@
void appendNumericAttribute( const data::RecordId &resolvable_id,
const data::RecordId &type_id,
int value );
-
-
+
+
// this functions are used by ResolvableConsumer interface functions
// to avoid some duplication across types.
void consumeResObject( const data::RecordId &rid, data::ResObject_Ptr res );
Modified: trunk/libzypp/zypp2/parser/susetags/RepoParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/parser/susetags/RepoParser.cc?rev=5621&r1=5620&r2=5621&view=diff
==============================================================================
--- trunk/libzypp/zypp2/parser/susetags/RepoParser.cc (original)
+++ trunk/libzypp/zypp2/parser/susetags/RepoParser.cc Wed May 23 22:45:51 2007
@@ -70,22 +70,25 @@
{
SEC << "[Prod]" << data_r << endl;
_prodData = data_r;
- _consumer.consumeProduct( _catalogId, _prodData );
+ _consumer.consumeProduct( _catalogId, data_r );
}
void consumePkg( const data::Package_Ptr & data_r )
{
SEC << "[Package]" << data_r << endl;
+ _consumer.consumePackage( _catalogId, data_r );
}
void consumeSrcPkg( const data::SrcPackage_Ptr & data_r )
{
SEC << "[SrcPackage]" << data_r << endl;
+ _consumer.consumeSourcePackage( _catalogId, data_r );
}
void consumePat( const data::Pattern_Ptr & data_r )
{
SEC << "[Pattern]" << data_r << endl;
+ _consumer.consumePattern( _catalogId, data_r );
}
//@}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org