Author: lslezak
Date: Tue Dec 18 12:44:24 2007
New Revision: 43153
URL: http://svn.opensuse.org/viewcvs/yast?rev=43153&view=rev
Log:
- added RepoCont and RepoId typedefs to hide implementation
details and to make the code more understandable
Modified:
trunk/pkg-bindings/package/yast2-pkg-bindings.changes
trunk/pkg-bindings/src/Package.cc
trunk/pkg-bindings/src/PkgModuleFunctions.h
trunk/pkg-bindings/src/Source_Get.cc
trunk/pkg-bindings/src/Source_Load.cc
trunk/pkg-bindings/src/Source_Misc.cc
trunk/pkg-bindings/src/Source_Save.cc
trunk/pkg-bindings/src/Source_Set.cc
Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=43153&r1=43152&r2=43153&view=diff
==============================================================================
--- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original)
+++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Tue Dec 18 12:44:24 2007
@@ -3,6 +3,8 @@
- use ResPool::repository_iterator for searching resolvables from
a repository (much faster than iterating over all resolvables)
+- added RepoCont and RepoId typedefs to hide implementation
+ details and to make the code more understandable
-------------------------------------------------------------------
Wed Dec 12 09:21:54 CET 2007 - lslezak@suse.cz
Modified: trunk/pkg-bindings/src/Package.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Package.cc?rev=43153&r1=43152&r2=43153&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Package.cc (original)
+++ trunk/pkg-bindings/src/Package.cc Tue Dec 18 12:44:24 2007
@@ -192,9 +192,9 @@
# warning No installation order
YCPList res;
- std::vector::size_type index = 0;
+ RepoId index = 0;
// for all enabled sources
- for( std::vector::const_iterator repoit = repos.begin();
+ for( RepoCont::const_iterator repoit = repos.begin();
repoit != repos.end(); ++repoit,++index)
{
if ((*repoit)->repoInfo().enabled() && !(*repoit)->isDeleted())
@@ -266,10 +266,10 @@
# warning No installation order
// all enabled sources
- std::list::size_type> source_ids;
+ std::list<RepoId> source_ids;
- std::vector::size_type index = 0;
- for(std::vector::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index)
+ RepoId index = 0;
+ for(RepoCont::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index)
{
// ignore disabled or delted sources
if (!(*it)->repoInfo().enabled() || (*it)->isDeleted())
@@ -280,16 +280,16 @@
// map SourceId -> [ number_of_media, total_size ]
- std::map::size_type, std::vectorzypp::ByteCount > result;
+ std::mapzypp::ByteCount > result;
// map alias -> SourceID
- std::map::size_type> source_map;
+ std::map source_map;
// initialize the structures
- for( std::list::size_type>::const_iterator sit = source_ids.begin();
+ for( std::list<RepoId>::const_iterator sit = source_ids.begin();
sit != source_ids.end(); ++sit, ++index)
{
- std::vector::size_type id = *sit;
+ RepoId id = *sit;
YRepo_Ptr repo = logFindRepository(id);
if (!repo)
@@ -336,7 +336,7 @@
YCPList res;
- for(std::map::size_type, std::vectorzypp::ByteCount >::const_iterator it =
+ for(std::mapzypp::ByteCount >::const_iterator it =
result.begin(); it != result.end() ; ++it)
{
const std::vectorzypp::ByteCount &values = it->second;
Modified: trunk/pkg-bindings/src/PkgModuleFunctions.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgModuleFunctions.h?rev=43153&r1=43152&r2=43153&view=diff
==============================================================================
--- trunk/pkg-bindings/src/PkgModuleFunctions.h (original)
+++ trunk/pkg-bindings/src/PkgModuleFunctions.h Tue Dec 18 12:44:24 2007
@@ -87,10 +87,16 @@
zypp::ZYpp::Ptr zypp_ptr();
+ // container for the internal structure
+ typedef std::vector RepoCont;
+ // ID type
+ typedef RepoCont::size_type RepoId;
+
+
private: // source related
// all known installation sources
- std::vector repos;
+ RepoCont repos;
// table for converting libzypp source type to Yast type (for backward compatibility)
std::map type_conversion_table;
@@ -171,9 +177,9 @@
* search for a repository and in case of exception, log error
* and setLastError AND RETHROW
*/
- YRepo_Ptr logFindRepository(std::vector::size_type id);
+ YRepo_Ptr logFindRepository(RepoId id);
- std::vector::size_type createManagedSource(const zypp::Url & url_r,
+ RepoId createManagedSource(const zypp::Url & url_r,
const zypp::Pathname & path_r, const bool base_source, const std::string& type,
const std::string &alias_r, PkgProgress &progress, const zypp::ProgressData::ReceiverFnc & progressrcv = zypp::ProgressData::ReceiverFnc());
Modified: trunk/pkg-bindings/src/Source_Get.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source_Get.cc?rev=43153&r1=43152&r2=43153&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source_Get.cc (original)
+++ trunk/pkg-bindings/src/Source_Get.cc Tue Dec 18 12:44:24 2007
@@ -19,7 +19,7 @@
*/
/*
- File: $Id:$
+ File: $Id$
Author: Ladislav Slezák
Summary: Functions for reading repository properties
*/
@@ -51,8 +51,8 @@
{
YCPList res;
- std::vector::size_type index = 0;
- for( std::vector::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index )
+ RepoId index = 0LL;
+ for( RepoCont::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index )
{
// ignore disabled sources if requested
if (enabled->value())
@@ -345,7 +345,7 @@
YCPList ret;
unsigned long index = 0;
- for( std::vector::const_iterator it = repos.begin(); it != repos.end(); ++it, ++index)
+ for( RepoCont::const_iterator it = repos.begin(); it != repos.end(); ++it, ++index)
{
if (!(*it)->isDeleted())
{
Modified: trunk/pkg-bindings/src/Source_Load.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source_Load.cc?rev=43153&r1=43152&r2=43153&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source_Load.cc (original)
+++ trunk/pkg-bindings/src/Source_Load.cc Tue Dec 18 12:44:24 2007
@@ -139,7 +139,7 @@
bool success = true;
int repos_to_load = 0;
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
@@ -158,7 +158,7 @@
zypp::RepoManager repomanager = CreateRepoManager();
// refresh metadata
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
// load resolvables only from enabled repos which are not deleted
@@ -203,7 +203,7 @@
progress.NextStage();
// rebuild cache
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
// load resolvables only from enabled repos which are not deleted
@@ -249,7 +249,7 @@
progress.NextStage();
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
// load resolvables only from enabled repos which are not deleted
Modified: trunk/pkg-bindings/src/Source_Misc.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source_Misc.cc?rev=43153&r1=43152&r2=43153&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source_Misc.cc (original)
+++ trunk/pkg-bindings/src/Source_Misc.cc Tue Dec 18 12:44:24 2007
@@ -41,7 +41,7 @@
* call zypp::SourceManager::sourceManager()->findSource
* and in case of exception, log error and setLastError AND RETHROW
*/
-YRepo_Ptr PkgModuleFunctions::logFindRepository(std::vector::size_type id)
+YRepo_Ptr PkgModuleFunctions::logFindRepository(RepoId id)
{
try
{
@@ -78,9 +78,9 @@
long long PkgModuleFunctions::logFindAlias(const std::string &alias) const
{
- std::vector::size_type index = 0;
+ RepoId index = 0LL;
- for(std::vector::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index)
+ for(RepoCont::const_iterator it = repos.begin(); it != repos.end() ; ++it, ++index)
{
if (!(*it)->isDeleted() && (*it)->repoInfo().alias() == alias)
return index;
@@ -91,7 +91,7 @@
bool PkgModuleFunctions::aliasExists(const std::string &alias) const
{
- for(std::vector::const_iterator it = repos.begin(); it != repos.end() ; ++it)
+ for(RepoCont::const_iterator it = repos.begin(); it != repos.end() ; ++it)
{
if (!(*it)->isDeleted() && (*it)->repoInfo().alias() == alias)
return true;
Modified: trunk/pkg-bindings/src/Source_Save.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source_Save.cc?rev=43153&r1=43152&r2=43153&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source_Save.cc (original)
+++ trunk/pkg-bindings/src/Source_Save.cc Tue Dec 18 12:44:24 2007
@@ -49,7 +49,7 @@
y2milestone("Releasing all sources...");
bool ret = true;
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
try
@@ -86,7 +86,7 @@
// count removed repos
int removed_repos = 0;
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
// the repo has been removed
@@ -127,7 +127,7 @@
zypp::RepoManager repomanager = CreateRepoManager();
// remove deleted repos (the old configurations) at first
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
// the repo has been removed
@@ -180,7 +180,7 @@
}
// save all repos (the current configuration)
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
if (!(*it)->isDeleted())
@@ -234,7 +234,7 @@
try
{
bool found_enabled = false;
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
@@ -253,7 +253,7 @@
SourceSaveAll();
y2milestone( "Disabling all sources...") ;
- for (std::vector::iterator it = repos.begin();
+ for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
(*it)->repoInfo().setEnabled(false);
Modified: trunk/pkg-bindings/src/Source_Set.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source_Set.cc?rev=43153&r1=43152&r2=43153&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source_Set.cc (original)
+++ trunk/pkg-bindings/src/Source_Set.cc Tue Dec 18 12:44:24 2007
@@ -162,7 +162,7 @@
continue;
}
- std::vector::size_type id = descr->value( YCPString("SrcId") )->asInteger()->value();
+ RepoId id = descr->value( YCPString("SrcId") )->asInteger()->value();
YRepo_Ptr repo = logFindRepository(id);
if (!repo)
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org