1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoInfo.h
12 #ifndef ZYPP2_REPOSITORYINFO_H
13 #define ZYPP2_REPOSITORYINFO_H
18 #include "zypp/base/PtrTypes.h"
19 #include "zypp/base/Iterator.h"
20 #include "zypp/base/Deprecated.h"
22 #include "zypp/Pathname.h"
24 #include "zypp/repo/RepoType.h"
25 #include "zypp/repo/RepoVariables.h"
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////
33 // CLASS NAME : RepoInfo
36 * \short What is known about a repository
38 * The class RepoInfo represents everything that
39 * is known about a software repository.
41 * It can be used to store information about known
44 * This class tries to be compatible with the
45 * concept of a .repo file used by YUM and
46 * also available in the openSUSE build service.
47 * See <tt>man yum.conf</tt>.
53 * name=Ruby repository (openSUSE_10.2)
55 * baseurl=http://software.opensuse.org/download/ruby/openSUSE_10.2/
57 * gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
61 * \note A RepoInfo is a hint about how
62 * to create a Repository.
66 friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
72 typedef unsigned long NumericId;
75 * unique identifier for this source. If not specified
76 * It should be generated from the base url.
78 * Normally, in a .repo file the section name is used
81 std::string alias() const;
84 * A Url under which the metadata are located, or a set of mirrors.
86 * This can't be empty in order the repository to be valid
87 * unless the download of the mirror list succeeds and it
88 * contains a valid url.
90 * \deprecated IMO superfluous as we provide begin/end iterator.
92 ZYPP_DEPRECATED std::set<Url> baseUrls() const;
95 * \short Repository path
97 * Pathname relative to the base Url where the product/repository
100 * For medias containing more than one product, or repositories not
101 * located at the root of the media it is important to
102 * know the path of the media root relative to the product directory
103 * so a media verifier can be set for that media.
105 * It is not mandatory, and the default is /
107 * \note As a repository can have multiple Urls, the path is unique and
108 * the same for all Urls, so it is assumed all the Urls have the
112 Pathname path() const;
115 * Url of a file which contains a list of Urls
116 * If empty, the base url will be used.
118 Url mirrorListUrl() const;
120 typedef std::set<Url> url_set;
121 //typedef url_set::const_iterator urls_const_iterator;
122 typedef url_set::size_type urls_size_type;
123 typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
126 * iterator that points at begin of repository urls
128 urls_const_iterator baseUrlsBegin() const;
131 * iterator that points at end of repository urls
133 urls_const_iterator baseUrlsEnd() const;
136 * number of repository urls
138 urls_size_type baseUrlsSize() const;
141 * whether repository urls are available
143 bool baseUrlsEmpty() const;
146 * If enabled is false, then this repository must be ignored as if does
147 * not exists, except when checking for duplicate alias.
149 bool enabled() const;
152 * If true, the repostory must be refreshed before creating resolvables
155 bool autorefresh() const;
158 * Type of repository,
161 repo::RepoType type() const;
164 * \short Repository short label
166 * Short label or description of the repository, to be used on
167 * the user interface.
168 * ie: "SUSE Linux 10.2 updates"
170 std::string name() const;
173 * \short File where this repo was read from
175 * \note could be an empty pathname for repo
176 * infos created in memory.
178 Pathname filepath() const;
181 * \short Path where this repo metadata was read from
183 * \note could be an empty pathname for repo
184 * infos created in memory.
186 Pathname metadataPath() const;
189 * \short Whether to check or not this repository with gpg
191 * \note This is a just a hint to the application and can
195 bool gpgCheck() const;
198 * \short Key to use for gpg checking of this repository
200 * \param url Url to the key in ASCII armored format
202 * \note This is a just a hint to the application and can
206 Url gpgKeyUrl() const;
209 * Add a base url. \see baseUrls
210 * \param url The base url for the repository.
212 * To recreate the base URLs list, use \ref setBaseUrl(const Url &) followed
215 RepoInfo & addBaseUrl( const Url &url );
218 * Clears current base URL list and adds \a url.
220 RepoInfo & setBaseUrl( const Url &url );
223 * set the product path. \see path()
224 * \param path the path to the product
226 RepoInfo & setPath( const Pathname &path );
229 * Set mirror list url. \see mirrorListUrl
230 * \param url The base url for the list
232 RepoInfo & setMirrorListUrl( const Url &url );
235 * enable or disable the repository \see enabled
238 RepoInfo & setEnabled( bool enabled );
241 * enable or disable autorefresh \see autorefresh
244 RepoInfo & setAutorefresh( bool autorefresh );
247 * set the repository alias \see alias
250 RepoInfo & setAlias( const std::string &alias );
253 * set the repository type \see type
256 RepoInfo & setType( const repo::RepoType &t );
259 * set the repository name \see name
262 RepoInfo & setName( const std::string &name );
265 * \short set the path to the .repo file
267 * The path to the .repo file where this repository
268 * was defined, or empty if nowhere.
270 * \param path File path
272 RepoInfo & setFilepath( const Pathname &filename );
275 * \short set the path where the local metadata is stored
277 * The path to the metadata of this repository
278 * was defined, or empty if nowhere.
280 * \param path directory path
282 RepoInfo & setMetadataPath( const Pathname &path );
285 * \short Whether to check or not this repository with gpg
287 * \param check true (check) or false (dont'check)
289 * \note This is a just a hint to the application and can
293 RepoInfo & setGpgCheck( bool check );
296 * \short Key to use for gpg checking of this repository
298 * \param url Url to the key in ASCII armored format
300 * \note This is a just a hint to the application and can
304 RepoInfo & setGpgKeyUrl( const Url &gpgkey );
307 * Write a human-readable representation of this RepoInfo object
308 * into the \a str stream. Useful for logging.
310 std::ostream & dumpOn( std::ostream & str ) const;
313 * Write this RepoInfo object into \a str in a <tr>.repo</tt> file format.
315 std::ostream & dumpRepoOn( std::ostream & str ) const;
319 /** Pointer to implementation */
320 RWCOW_pointer<Impl> _pimpl;
322 ///////////////////////////////////////////////////////////////////
324 /** \relates RepoInfo Stream output */
325 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
327 typedef std::list<RepoInfo> RepoInfoList;
329 /////////////////////////////////////////////////////////////////
331 ///////////////////////////////////////////////////////////////////
332 #endif // ZYPP2_REPOSITORYINFO_H