a05eb31a0b13dd0c3f5f82b210eff8dd6ce46b4e
[platform/upstream/libzypp.git] / zypp2 / RepoInfo.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp2/RepoInfo.h
10  *
11 */
12 #ifndef ZYPP2_REPOSITORYINFO_H
13 #define ZYPP2_REPOSITORYINFO_H
14
15 #include <iosfwd>
16 #include <list>
17 #include <set>
18 #include "zypp/base/PtrTypes.h"
19
20 #include <boost/logic/tribool.hpp>
21 #include "zypp/Pathname.h"
22 #include "zypp/Url.h"
23 #include "zypp/CheckSum.h"
24 #include "zypp/Date.h"
25
26 ///////////////////////////////////////////////////////////////////
27 namespace zypp
28 { /////////////////////////////////////////////////////////////////
29
30   ///////////////////////////////////////////////////////////////////
31   //
32   //    CLASS NAME : RepoInfo
33   //
34   /**
35    * \short What is known about a repository
36    *
37    * The class RepoInfo represents everything that
38    * is known about a software repository.
39    *
40    * It can be used to store information about known
41    * sources.
42    *
43    * This class tries to be compatible with the
44    * concept of a .repo file used by YUM and
45    * also available in the openSUSE build service.
46    *
47    * Example file
48    *
49    * \code
50    * [ruby]
51    * name=Ruby repository (openSUSE_10.2)
52    * type=rpm-md
53    * baseurl=http://software.opensuse.org/download/ruby/openSUSE_10.2/
54    * gpgcheck=1
55    * gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
56    * enabled=1
57    * \endcode
58    *
59    * \note A Repository info is a hint about how
60    * to create a repository.
61    */
62   class RepoInfo
63   {
64     friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
65     
66     public:
67     RepoInfo();
68     ~RepoInfo();
69     //RepoInfo( const Url & url, const Pathname & path, const std::string & alias = "", boost::tribool autorefresh = boost::indeterminate );
70     
71     /**
72      * unique identifier for this source. If not specified
73      * It should be generated from the base url.
74      *
75      * Normally, in a .repo file the section name is used
76      * ( [somerepo] )
77      */
78     std::string alias() const;
79     
80     /**
81      * The base Url is the Url of the repository that generates
82      * the authoritative metadata this repository provides.
83      *
84      * For example for the url http://updates.novell.com/10.2
85      * the base url is http://updates.novell.com/10.2.
86      * For the url http://host.com/mirror/update.novell.com/10.2
87      * the base url is http://updates.novell.com/10.2
88      *
89      * This can't be empty in order the repository to be valid
90      */
91     Url baseUrl() const;
92
93     /**
94      * Urls is a list of Urls where this repository
95      * is located.
96      * If empty, the base url will be used.
97      */
98     std::set<Url> urls() const;
99     
100     typedef std::set<Url>::const_iterator urls_const_iterator;
101     
102     /**
103      * iterator that points at begin of repository urls
104      */
105     urls_const_iterator urlsBegin() const;
106     
107     /**
108      * iterator that points at end of repository urls
109      */
110     urls_const_iterator urlsEnd() const;
111     
112     /**
113      * Path on the url where the repository root
114      * is located.
115      */
116     Pathname path() const;
117     
118     /**
119      * If enabled is false, then this repository must be ignored as if does
120      * not exists, except when checking for duplicate alias.
121      */
122     boost::tribool enabled() const;
123     
124     /**
125      * If true, the repostory must be refreshed before creating resolvables
126      * from it
127      */
128     boost::tribool autorefresh() const;
129     
130     /**
131      * Type of repository,
132      * FIXME should be an enum?
133      */
134     std::string type() const;
135     
136     /**
137      * \short Repository short label
138      *
139      * Short label or description of the repository, to be used on
140      * the user interface.
141      * ie: "SUSE Linux 10.2 updates"
142      */
143     std::string name() const;
144     
145     /**
146      * Checksum of the repository.
147      * Usually the checksum of the index, but any
148      * checksum that changes when the repository changes
149      * in any way is sufficient.
150      */
151     CheckSum checksum() const;
152     
153     /**
154      * timestamp of the repository. If the repository
155      * changes, it has to be updated as well with the
156      * new timestamp.
157      */
158     Date timestamp() const;
159     
160     /**
161      * Set the base url. \see baseUrl
162      * \param url The base url for the repository.
163      */
164     RepoInfo & setBaseUrl( const Url &url );
165     
166     /**
167      * enable or disable the repository \see enabled
168      * \param enabled
169      */
170     RepoInfo & setEnabled( boost::tribool enabled );
171     
172     /**
173      * enable or disable autorefresh \see autorefresh
174      * \param enabled
175      */
176     RepoInfo & setAutorefresh( boost::tribool autorefresh );
177     
178     /**
179      * set the repository path \see path
180      * \param p
181      */
182     RepoInfo & setPath( const Pathname &p );
183     
184     /**
185      * set the repository alias \see alias
186      * \param alias
187      */
188     RepoInfo & setAlias( const std::string &alias );
189     
190     /**
191      * set the repository type \see type
192      * \param t
193      */
194     RepoInfo & setType( const std::string &t );
195     
196     /**
197      * set the repository name \see name
198      * \param name
199      */
200     RepoInfo & setName( const std::string &name );
201     
202     /**
203      * set the repository checksum \see checksum
204      * \param checksum
205      */
206     RepoInfo & setChecksum( const CheckSum &checksum );
207     
208     /**
209      * set the repository timestamp \see timestamp
210      * \param timestamp
211      */
212     RepoInfo & setTimestamp( const Date &timestamp );
213     
214     std::ostream & dumpOn( std::ostream & str ) const;
215     
216     class Impl;
217   private:
218     /** Pointer to implementation */
219     RWCOW_pointer<Impl> _pimpl;
220   };
221   ///////////////////////////////////////////////////////////////////
222
223   /** \relates RepoInfo Stream output */
224   std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
225
226   typedef std::list<RepoInfo> RepoInfoList;
227   
228   /////////////////////////////////////////////////////////////////
229 } // namespace zypp2
230 ///////////////////////////////////////////////////////////////////
231 #endif // ZYPP2_REPOSITORYINFO_H