Author: mlandres
Date: Wed Nov 14 08:47:19 2007
New Revision: 7802
URL: http://svn.opensuse.org/viewcvs/zypp?rev=7802&view=rev
Log:
adapt to changed satsolver api
Modified:
trunk/libzypp/zypp/sat/Pool.cc
trunk/libzypp/zypp/sat/Pool.h
trunk/libzypp/zypp/sat/Repo.cc
trunk/libzypp/zypp/sat/Repo.h
Modified: trunk/libzypp/zypp/sat/Pool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.cc?rev=7802&r1=7801&r2=7802&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Pool.cc (original)
+++ trunk/libzypp/zypp/sat/Pool.cc Wed Nov 14 08:47:19 2007
@@ -12,13 +12,9 @@
extern "C"
{
-#include
-#include
#include
}
-#include <cstdio>
#include <iostream>
-#include <set>
#include "zypp/base/Logger.h"
#include "zypp/base/Gettext.h"
@@ -36,12 +32,6 @@
///////////////////////////////////////////////////////////////////
//
- // CLASS NAME : Pool
- //
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
// METHOD NAME : Pool::Pool
// METHOD TYPE : Ctor
//
@@ -84,32 +74,26 @@
{ return SolvableIterator( _pool.solvables+_pool.nsolvables ); }
- void Pool::t() const
+ Repo Pool::addRepo( const std::string & name_r )
{
- if ( _pool.nrepos )
- {
- SEC << (void*)(*_pool.repos)<< Repo( *_pool.repos ) << " " << (*_pool.repos)->name << std::endl;
- }
- else
- {
- SEC << "NOREPO" << std::endl;
- }
-
+#warning Implement name check
+ return ::repo_create( &_pool, name_r.c_str() );
}
- Repo Pool::addRepoSolv( const Pathname & file_r )
+ Repo Pool::addRepoSolv( const Pathname & file_r, const std::string & name_r )
{
- AutoDispose file( ::fopen( file_r.c_str(), "r" ), ::fclose );
- if ( file == NULL )
+ Repo repo( addRepo( name_r.empty() ? file_r.basename() : name_r ) );
+ try
{
- file.resetDispose();
- return Repo();
+ repo.addSolv( file_r );
}
-
-#warning Workaround sat-repo not doing strdup on name.
- // simply spend a static array of reponames
- static std::setstd::string _reponames;
- return ::pool_addrepo_solv( &_pool, file, _reponames.insert( file_r.asString() ).first->c_str() );
+ catch ( ... )
+ {
+#warning use RAII to avoid cleanup catch
+ ::repo_free( repo.get() );
+ throw;
+ }
+ return repo;
}
/******************************************************************
@@ -122,7 +106,6 @@
return str << "sat::pool(){"
<< obj.reposSize() << "repos|"
<< obj.solvablesSize() << "slov}";
-
}
/////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/sat/Pool.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.h?rev=7802&r1=7801&r2=7802&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Pool.h (original)
+++ trunk/libzypp/zypp/sat/Pool.h Wed Nov 14 08:47:19 2007
@@ -18,7 +18,6 @@
#include "zypp/base/Iterator.h"
#include "zypp/AutoDispose.h"
-#include "zypp/Pathname.h"
#include "zypp/sat/Repo.h"
@@ -56,12 +55,19 @@
SolvableIterator solvablesBegin() const;
SolvableIterator solvablesEnd() const;
- void t() const;
-
public:
- Repo addRepoSolv( const Pathname & file_r );
+ /** Add new empty \ref Repo named \c name_r.
+ * \throws Exception if \ref Repo with named \c name_r exists.
+ */
+ Repo addRepo( const std::string & name_r );
+
+ /** Add new \ref Repo from solv-file.
+ * \c name_r defaults to the solvfiles basename.
+ * \throws Exception from \ref Pool::addRepo or \ref Repo::addSolv
+ */
+ Repo addRepoSolv( const Pathname & file_r, const std::string & name_r = std::string() );
- private:
+ private:
/** Explicitly shared sat-pool. */
AutoDispose< ::_Pool *> _raii;
/** Convenient access. */
@@ -71,7 +77,50 @@
/** \relates Pool Stream output */
std::ostream & operator<<( std::ostream & str, const Pool & obj );
+#if 0
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : TempRepo
+ //
+ /** Maintain a temporary \ref Repo.
+ * Any included temporary \ref Repo is removed from the \ref Prool
+ * upon destruction. This may ease convenient and exception safe
+ * creation of repos.
+ * \code
+ * {
+ * TempRepo tmp( pool.addRepo( "newrepo" ) );
+ *
+ * // Exceptions when loading Solvables into "newrepo"
+ * // may bypass, and "newrepo" will be removed from
+ * // the pool.
+ *
+ * if ( keep )
+ * {
+ * // If you decide to keep "newrepo", simply
+ * // clear TempRepo to prevent removal.
+ * tmp.reset();
+ * }
+ * }
+ * \endcode
+ */
+ class TempRepo : private base::NonCopyable
+ {
+ public:
+ TempRepo( const Repo & repo_r )
+ : _repo( repo_r )
+ {}
+
+ ~TempRepo()
+ {
+ if ( _repo )
+ _repo.
+ }
+ private:
+ Repo _repo;
+ };
+ ///////////////////////////////////////////////////////////////////
+#endif
/////////////////////////////////////////////////////////////////
} // namespace sat
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/sat/Repo.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Repo.cc?rev=7802&r1=7801&r2=7802&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Repo.cc (original)
+++ trunk/libzypp/zypp/sat/Repo.cc Wed Nov 14 08:47:19 2007
@@ -13,6 +13,7 @@
{
#include
#include
+#include
}
#include <iostream>
@@ -20,6 +21,8 @@
#include "zypp/base/Gettext.h"
#include "zypp/base/Exception.h"
+#include "zypp/AutoDispose.h"
+
#include "zypp/sat/Repo.h"
using std::endl;
@@ -57,6 +60,20 @@
return SolvableIterator( _repo->pool->solvables+_repo->start+_repo->nsolvables );
}
+ void Repo::addSolv( const Pathname & file_r )
+ {
+#warning add ecxception in repo_add_solv
+ AutoDispose file( ::fopen( file_r.c_str(), "r" ), ::fclose );
+ if ( file == NULL )
+ {
+ file.resetDispose();
+ throw;
+ //return Repo();
+ }
+
+ ::repo_add_solv( _repo, file );
+ }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
Modified: trunk/libzypp/zypp/sat/Repo.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Repo.h?rev=7802&r1=7801&r2=7802&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Repo.h (original)
+++ trunk/libzypp/zypp/sat/Repo.h Wed Nov 14 08:47:19 2007
@@ -16,6 +16,8 @@
#include "zypp/base/SafeBool.h"
+#include "zypp/Pathname.h"
+
#include "zypp/sat/Solvable.h"
///////////////////////////////////////////////////////////////////
@@ -59,6 +61,12 @@
SolvableIterator solvablesEnd() const;
public:
+ /** Load Solvables from a solv-file.
+ * \throws Exception if loading the solv-file fails.
+ */
+ void addSolv( const Pathname & file_r );
+
+ public:
/** Expert backdoor. */
::_Repo * get() const { return _repo; }
private:
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org