1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoInfo.h
12 #ifndef ZYPP2_REPOSITORYINFO_H
13 #define ZYPP2_REPOSITORYINFO_H
18 #include "zypp/base/Iterator.h"
19 #include "zypp/base/Deprecated.h"
22 #include "zypp/repo/RepoType.h"
23 #include "zypp/repo/RepoVariables.h"
25 #include "zypp/repo/RepoInfoBase.h"
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
31 DEFINE_PTR_TYPE(RepoInfo);
33 ///////////////////////////////////////////////////////////////////
35 // CLASS NAME : RepoInfo
38 * \short What is known about a repository
40 * The class RepoInfo represents everything that
41 * is known about a software repository.
43 * It can be used to store information about known
46 * This class tries to be compatible with the
47 * concept of a .repo file used by YUM and
48 * also available in the openSUSE build service.
49 * See <tt>man yum.conf</tt>.
55 * name=Ruby repository (openSUSE_10.2)
57 * baseurl=http://software.opensuse.org/download/ruby/openSUSE_10.2/
59 * gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
64 * \note A RepoInfo is a hint about how
65 * to create a Repository.
67 class RepoInfo : public repo::RepoInfoBase
69 friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
76 * Repository priority for solver.
77 * Some number between \c 1 (highest priority) and \c 99 (\ref defaultPriority).
79 unsigned priority() const;
81 * The default priority (\c 99).
83 static unsigned defaultPriority();
85 * Set repository priority for solver.
86 * A \c newval_r of \c 0 sets the default priority.
89 void setPriority( unsigned newval_r );
92 * A Url under which the metadata are located, or a set of mirrors.
94 * This can't be empty in order the repository to be valid
95 * unless the download of the mirror list succeeds and it
96 * contains a valid url.
98 * \deprecated IMO superfluous as we provide begin/end iterator.
100 ZYPP_DEPRECATED std::set<Url> baseUrls() const;
103 * \short Repository path
105 * Pathname relative to the base Url where the product/repository
108 * For medias containing more than one product, or repositories not
109 * located at the root of the media it is important to
110 * know the path of the media root relative to the product directory
111 * so a media verifier can be set for that media.
113 * It is not mandatory, and the default is /
115 * \note As a repository can have multiple Urls, the path is unique and
116 * the same for all Urls, so it is assumed all the Urls have the
120 Pathname path() const;
123 * Url of a file which contains a list of Urls
124 * If empty, the base url will be used.
126 Url mirrorListUrl() const;
128 typedef std::set<Url> url_set;
129 //typedef url_set::const_iterator urls_const_iterator;
130 typedef url_set::size_type urls_size_type;
131 typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
134 * iterator that points at begin of repository urls
136 urls_const_iterator baseUrlsBegin() const;
139 * iterator that points at end of repository urls
141 urls_const_iterator baseUrlsEnd() const;
144 * number of repository urls
146 urls_size_type baseUrlsSize() const;
149 * whether repository urls are available
151 bool baseUrlsEmpty() const;
154 * Type of repository,
157 repo::RepoType type() const;
160 * \short Path where this repo metadata was read from
162 * \note could be an empty pathname for repo
163 * infos created in memory.
165 Pathname metadataPath() const;
168 * \short Path where this repo packages are cached
170 Pathname packagesPath() const;
173 * \short Whether to check or not this repository with gpg
175 * \note This is a just a hint to the application and can
179 bool gpgCheck() const;
182 * \short Key to use for gpg checking of this repository
184 * \param url Url to the key in ASCII armored format
186 * \note This is a just a hint to the application and can
190 Url gpgKeyUrl() const;
193 * \short Whether to keep the packages downloaded from this repository will be kept in local cache
195 bool keepPackages() const;
198 * Gets name of the service to which this repository belongs or empty string
199 * if it has been added manually.
201 std::string service() const;
204 * Distribution for which is this repository meant.
206 std::string targetDistribution() const;
210 * Add a base url. \see baseUrls
211 * \param url The base url for the repository.
212 * \note can change keepPackages,so change it after this call
214 * To recreate the base URLs list, use \ref setBaseUrl(const Url &) followed
217 void addBaseUrl( const Url &url );
220 * Clears current base URL list and adds \a url.
221 * \note can change keepPackages,so change it after this call
223 void setBaseUrl( const Url &url );
226 * set the product path. \see path()
227 * \param path the path to the product
229 void setPath( const Pathname &path );
232 * Set mirror list url. \see mirrorListUrl
233 * \param url The base url for the list
235 void setMirrorListUrl( const Url &url );
238 * set the repository type \see type
241 void setType( const repo::RepoType &t );
244 * This allows to adjust the \ref RepoType lazy, from \c NONE to
245 * some probed value, even for const objects.
247 * This is a NOOP if the current type is not \c NONE.
249 void setProbedType( const repo::RepoType &t ) const;
252 * \short set the path where the local metadata is stored
254 * The path to the metadata of this repository
255 * was defined, or empty if nowhere.
257 * \param path directory path
259 void setMetadataPath( const Pathname &path );
262 * \short set the path where the local packages are stored
264 * \param path directory path
266 void setPackagesPath( const Pathname &path );
269 * \short Whether to check or not this repository with gpg
271 * \param check true (check) or false (dont'check)
273 * \note This is a just a hint to the application and can
277 void setGpgCheck( bool check );
280 * \short Key to use for gpg checking of this repository
282 * \param url Url to the key in ASCII armored format
284 * \note This is a just a hint to the application and can
288 void setGpgKeyUrl( const Url &gpgkey );
291 * \short Set if the packaqes downloaded from this repository will be kept in local cache
293 * If the setting is true, all downloaded packages from this repository will be
294 * copied to the local raw cache.
296 * \param keep true (keep the downloaded packages) or false (delete them after installation)
299 void setKeepPackages( bool keep );
302 * sets service which added this repository
304 void setService( const std::string& name );
307 * Sets the distribution for which is this repository meant. This is
308 * an in-memory value only, does not get written to the .repo file upon
311 void setTargetDistribution(const std::string & targetDistribution);
314 * Write a human-readable representation of this RepoInfo object
315 * into the \a str stream. Useful for logging.
317 virtual std::ostream & dumpOn( std::ostream & str ) const;
320 * Write this RepoInfo object into \a str in a <tr>.repo</tt> file format.
322 virtual std::ostream & dumpRepoOn( std::ostream & str ) const;
326 /** Pointer to implementation */
327 RWCOW_pointer<Impl> _pimpl;
329 ///////////////////////////////////////////////////////////////////
331 /** \relates RepoInfo Stream output */
332 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
334 inline bool operator<( const RepoInfo& lhs, const RepoInfo & rhs )
335 { return lhs.alias() < rhs.alias(); }
337 typedef std::list<RepoInfo> RepoInfoList;
339 /////////////////////////////////////////////////////////////////
341 ///////////////////////////////////////////////////////////////////
342 #endif // ZYPP2_REPOSITORYINFO_H