1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/Pool.h
12 #ifndef ZYPP_SAT_POOL_H
13 #define ZYPP_SAT_POOL_H
17 #include "zypp/Pathname.h"
19 #include "zypp/sat/detail/PoolMember.h"
20 #include "zypp/sat/Repo.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////////
30 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
38 * Explicitly shared singleton \ref Pool::instance.
40 class Pool : protected detail::PoolMember
43 typedef detail::SolvableIterator SolvableIterator;
44 typedef detail::RepoIterator RepoIterator;
45 typedef detail::size_type size_type;
48 /** Singleton ctor. */
49 static Pool instance()
52 /** Ctor from \ref PoolMember. */
53 Pool( const detail::PoolMember & )
57 /** Internal array size for stats only. */
58 size_type capacity() const;
60 /** Housekeeping data serial number. */
61 const SerialNumber & serial() const;
63 /** Update housekeeping data if necessary (e.g. whatprovides). */
67 /** Whether \ref Pool contains repos. */
68 bool reposEmpty() const;
70 /** Number of repos in \ref Pool. */
71 size_type reposSize() const;
73 /** Iterator to the first \ref Repo. */
74 RepoIterator reposBegin() const;
76 /** Iterator behind the last \ref Repo. */
77 RepoIterator reposEnd() const;
79 /** Return a \ref Repo named \c name_r.
80 * It a such a \ref Repo does not already exist
81 * a new empty \ref Repo is created.
83 Repo reposInsert( const std::string & name_r );
85 /** Find a \ref Repo named \c name_r.
86 * Returns \ref norepo if there is no such \ref Repo.
88 Repo reposFind( const std::string & name_r ) const;
90 /** Remove a \ref Repo named \c name_r.
91 * \see \ref Repo::eraseFromPool
93 void reposErase( const std::string & name_r )
94 { reposFind( name_r ).eraseFromPool(); }
97 /** Reserved system repo name \c @System. */
98 static const std::string & systemRepoName();
100 /** Return the system repo. */
102 { return reposInsert( systemRepoName() ); }
105 /** Load \ref Solvables from a solv-file into a \ref Repo named \c name_r.
106 * In case of an exception the \ref Repo is removed from the \ref Pool.
107 * \throws Exception if loading the solv-file fails.
108 * \see \ref Repo::EraseFromPool
110 Repo addRepoSolv( const Pathname & file_r, const std::string & name_r );
111 /** \overload Using the files basename as \ref Repo name. */
112 Repo addRepoSolv( const Pathname & file_r );
115 /** Whether \ref Pool contains solvables. */
116 bool solvablesEmpty() const;
118 /** Number of solvables in \ref Pool. */
119 size_type solvablesSize() const;
121 /** Iterator to the first \ref Solvable. */
122 SolvableIterator solvablesBegin() const;
124 /** Iterator behind the last \ref Solvable. */
125 SolvableIterator solvablesEnd() const;
128 /** Expert backdoor. */
129 ::_Pool * get() const;
134 ///////////////////////////////////////////////////////////////////
136 /** \relates Pool Stream output */
137 std::ostream & operator<<( std::ostream & str, const Pool & obj );
140 inline bool operator==( const Pool & lhs, const Pool & rhs )
141 { return lhs.get() == rhs.get(); }
144 inline bool operator!=( const Pool & lhs, const Pool & rhs )
145 { return lhs.get() != rhs.get(); }
147 /////////////////////////////////////////////////////////////////
149 ///////////////////////////////////////////////////////////////////
150 /////////////////////////////////////////////////////////////////
152 ///////////////////////////////////////////////////////////////////
153 #endif // ZYPP_SAT_POOL_H