1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/Pool.cc
15 #include <satsolver/pool.h>
16 #include <satsolver/repo.h>
20 #include "zypp/base/Easy.h"
21 #include "zypp/base/Logger.h"
22 #include "zypp/base/Gettext.h"
23 #include "zypp/base/Exception.h"
25 #include "zypp/AutoDispose.h"
27 #include "zypp/sat/detail/PoolImpl.h"
28 #include "zypp/sat/Pool.h"
30 ///////////////////////////////////////////////////////////////////
32 { /////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////
35 { /////////////////////////////////////////////////////////////////
37 const std::string & Pool::systemRepoName()
39 static const std::string _val( "@System" );
43 ::_Pool * Pool::get() const
44 { return myPool().getPool(); }
46 const SerialNumber & Pool::serial() const
47 { return myPool().serial(); }
50 { return myPool().setDirty(); }
53 { return myPool().prepare(); }
55 bool Pool::reposEmpty() const
56 { return myPool()->nrepos; }
58 unsigned Pool::reposSize() const
59 { return myPool()->nrepos; }
61 Pool::RepoIterator Pool::reposBegin() const
62 { return RepoIterator( myPool()->repos ); }
64 Pool::RepoIterator Pool::reposEnd() const
65 { return RepoIterator( myPool()->repos+myPool()->nrepos ); }
67 bool Pool::solvablesEmpty() const
69 // return myPool()->nsolvables;
70 // nsolvables is the array size including
72 for_( it, reposBegin(), reposEnd() )
74 if ( ! it->solvablesEmpty() )
80 unsigned Pool::solvablesSize() const
82 // return myPool()->nsolvables;
83 // nsolvables is the array size including
86 for_( it, reposBegin(), reposEnd() )
88 ret += it->solvablesSize();
93 Pool::SolvableIterator Pool::solvablesBegin() const
94 { return SolvableIterator( myPool().getFirstId() ); }
96 Pool::SolvableIterator Pool::solvablesEnd() const
97 { return SolvableIterator(); }
99 Repo Pool::reposInsert( const std::string & name_r )
101 Repo ret( reposFind( name_r ) );
105 return Repo( ::repo_create( get(), name_r.c_str() ) );
108 Repo Pool::reposFind( const std::string & name_r ) const
110 for_( it, reposBegin(), reposEnd() )
112 if ( name_r == it->name() )
118 Repo Pool::addRepoSolv( const Pathname & file_r, const std::string & name_r )
120 // Using a temporay repo! (The additional parenthesis are required.)
121 AutoDispose<Repo> tmprepo( (Repo::EraseFromPool()) );
122 *tmprepo = reposInsert( name_r );
123 tmprepo->addSolv( file_r );
125 // no exceptions so we keep it:
126 tmprepo.resetDispose();
130 Repo Pool::addRepoSolv( const Pathname & file_r )
131 { return addRepoSolv( file_r, file_r.basename() ); }
133 /******************************************************************
135 ** FUNCTION NAME : operator<<
136 ** FUNCTION TYPE : std::ostream &
138 std::ostream & operator<<( std::ostream & str, const Pool & obj )
140 return str << "sat::pool(" << obj.serial() << "){"
141 << obj.reposSize() << "repos|"
142 << obj.solvablesSize() << "slov}";
145 /////////////////////////////////////////////////////////////////
147 ///////////////////////////////////////////////////////////////////
148 /////////////////////////////////////////////////////////////////
150 ///////////////////////////////////////////////////////////////////