clean more class names
[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
24 ///////////////////////////////////////////////////////////////////
25 namespace zypp
26 { /////////////////////////////////////////////////////////////////
27
28   ///////////////////////////////////////////////////////////////////
29   //
30   //    CLASS NAME : RepoInfo
31   //
32   /**
33    * \short What is known about a repository
34    *
35    * The class RepoInfo represents everything that
36    * is known about a software repository.
37    *
38    * It can be used to store information about known
39    * sources.
40    *
41    * This class tries to be compatible with the
42    * concept of a .repo file used by YUM and
43    * also available in the openSUSE build service.
44    *
45    * Example file
46    *
47    * \code
48    * [ruby]
49    * name=Ruby repository (openSUSE_10.2)
50    * type=rpm-md
51    * baseurl=http://software.opensuse.org/download/ruby/openSUSE_10.2/
52    * gpgcheck=1
53    * gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
54    * enabled=1
55    * \endcode
56    *
57    * \note A Repository info is a hint about how
58    * to create a repository.
59    */
60   class RepoInfo
61   {
62     friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
63     
64     public:
65     RepoInfo();
66     ~RepoInfo();
67     //RepoInfo( const Url & url, const Pathname & path, const std::string & alias = "", boost::tribool autorefresh = boost::indeterminate );
68     
69     /**
70      * unique identifier for this source. If not specified
71      * It should be generated from the base url.
72      *
73      * Normally, in a .repo file the section name is used
74      * ( [somerepo] )
75      */
76     std::string alias() const;
77     
78     /**
79      * The base Url is the Url of the repository that generates
80      * the authoritative metadata this repository provides.
81      *
82      * For example for the url http://updates.novell.com/10.2
83      * the base url is http://updates.novell.com/10.2.
84      * For the url http://host.com/mirror/update.novell.com/10.2
85      * the base url is http://updates.novell.com/10.2
86      *
87      * This can't be empty in order the repository to be valid
88      * unless the download of the mirror list succeeds and it
89      * contains a valid url.
90      */
91     std::set<Url> urls() const;
92
93     /**
94      * Url of a file which contains a list of Urls
95      * If empty, the base url will be used.
96      */
97      Url mirrorListUrl() const;
98     
99     typedef std::set<Url>::const_iterator urls_const_iterator;
100     
101     /**
102      * iterator that points at begin of repository urls
103      */
104     urls_const_iterator urlsBegin() const;
105     
106     /**
107      * iterator that points at end of repository urls
108      */
109     urls_const_iterator urlsEnd() const;
110     
111     /**
112      * If enabled is false, then this repository must be ignored as if does
113      * not exists, except when checking for duplicate alias.
114      */
115     boost::tribool enabled() const;
116     
117     /**
118      * If true, the repostory must be refreshed before creating resolvables
119      * from it
120      */
121     boost::tribool autorefresh() const;
122     
123     /**
124      * Type of repository,
125      * FIXME should be an enum?
126      */
127     std::string type() const;
128     
129     /**
130      * \short Repository short label
131      *
132      * Short label or description of the repository, to be used on
133      * the user interface.
134      * ie: "SUSE Linux 10.2 updates"
135      */
136     std::string name() const;
137
138     /**
139      * Add a base url. \see baseUrl
140      * \param url The base url for the repository.
141      */
142     RepoInfo & addBaseUrl( const Url &url );
143     
144     /**
145      * Set mirror list url. \see mirrorListUrl
146      * \param url The base url for the list
147      */
148     RepoInfo & setMirrorListUrl( const Url &url );
149     
150     /**
151      * enable or disable the repository \see enabled
152      * \param enabled
153      */
154     RepoInfo & setEnabled( boost::tribool enabled );
155     
156     /**
157      * enable or disable autorefresh \see autorefresh
158      * \param enabled
159      */
160     RepoInfo & setAutorefresh( boost::tribool autorefresh );
161     
162     /**
163      * set the repository alias \see alias
164      * \param alias
165      */
166     RepoInfo & setAlias( const std::string &alias );
167     
168     /**
169      * set the repository type \see type
170      * \param t
171      */
172     RepoInfo & setType( const std::string &t );
173     
174     /**
175      * set the repository name \see name
176      * \param name
177      */
178     RepoInfo & setName( const std::string &name );
179
180     std::ostream & dumpOn( std::ostream & str ) const;
181     
182     class Impl;
183   private:
184     /** Pointer to implementation */
185     RWCOW_pointer<Impl> _pimpl;
186   };
187   ///////////////////////////////////////////////////////////////////
188
189   /** \relates RepoInfo Stream output */
190   std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
191
192   typedef std::list<RepoInfo> RepoInfoList;
193   
194   /////////////////////////////////////////////////////////////////
195 } // namespace zypp2
196 ///////////////////////////////////////////////////////////////////
197 #endif // ZYPP2_REPOSITORYINFO_H