1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/Pool.h
12 #ifndef ZYPP_SAT_POOL_H
13 #define ZYPP_SAT_POOL_H
17 #include "zypp/sat/detail/PoolMember.h"
19 ///////////////////////////////////////////////////////////////////
21 { /////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////
27 { /////////////////////////////////////////////////////////////////
29 ///////////////////////////////////////////////////////////////////
35 * Explicitly shared singleton \ref Pool::instance.
37 class Pool : protected detail::PoolMember
40 typedef detail::SolvableIterator SolvableIterator;
41 typedef detail::RepoIterator RepoIterator;
44 /** Singleton ctor. */
45 static Pool instance()
48 /** Ctor from \ref PoolMember. */
49 Pool( const detail::PoolMember & )
53 /** Whether \ref Pool contains repos. */
54 bool reposEmpty() const;
56 /** Number of repos in \ref Pool. */
57 unsigned reposSize() const;
59 /** Iterator to the first \ref Repo. */
60 RepoIterator reposBegin() const;
62 /** Iterator behind the last \ref Repo. */
63 RepoIterator reposEnd() const;
65 /** Return a \ref Repo named \c name_r.
66 * It a such a \ref Repo does not already exist
67 * a new empty \ref Repo is created.
69 Repo reposInsert( const std::string & name_r );
71 /** Find a \ref Repo named \c name_r.
72 * Returns \ref norepo if there is no such \ref Repo.
74 Repo reposFind( const std::string & name_r ) const;
76 /** Remove a \ref Repo named \c name_r.
77 * \see \ref Repo::eraseFromPool
79 void reposErase( const std::string & name_r );
82 /** Load \ref Solvables from a solv-file into a \ref Repo named \c name_r.
83 * In case of an exception the \ref Repo is removed from the \ref Pool.
84 * \throws Exception if loading the solv-file fails.
85 * \see \ref Repo::EraseFromPool
87 Repo addRepoSolv( const Pathname & file_r, const std::string & name_r );
88 /** \overload Using the files basename as \ref Repo name. */
89 Repo addRepoSolv( const Pathname & file_r );
92 /** Whether \ref Pool contains solvables. */
93 bool solvablesEmpty() const;
95 /** Number of solvables in \ref Pool. */
96 unsigned solvablesSize() const;
98 /** Iterator to the first \ref Solvable. */
99 SolvableIterator solvablesBegin() const;
101 /** Iterator behind the last \ref Solvable. */
102 SolvableIterator solvablesEnd() const;
105 /** Expert backdoor. */
106 ::_Pool * get() const;
111 ///////////////////////////////////////////////////////////////////
113 /** \relates Pool Stream output */
114 std::ostream & operator<<( std::ostream & str, const Pool & obj );
117 inline bool operator==( const Pool & lhs, const Pool & rhs )
118 { return lhs.get() == rhs.get(); }
121 inline bool operator!=( const Pool & lhs, const Pool & rhs )
122 { return lhs.get() != rhs.get(); }
124 /////////////////////////////////////////////////////////////////
126 ///////////////////////////////////////////////////////////////////
127 /////////////////////////////////////////////////////////////////
129 ///////////////////////////////////////////////////////////////////
130 #endif // ZYPP_SAT_POOL_H