- service probing on refresh enabled
[platform/upstream/libzypp.git] / zypp / ServiceInfo.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ServiceInfo.h
10  *
11  */
12 #ifndef ZYPP_SERVICE_H
13 #define ZYPP_SERVICE_H
14
15 #include <set>
16 #include <string>
17
18 #include "zypp/Url.h"
19
20 #include "zypp/repo/ServiceType.h"
21 #include "zypp/repo/RepoInfoBase.h"
22
23
24 ///////////////////////////////////////////////////////////////////
25 namespace zypp
26 { /////////////////////////////////////////////////////////////////
27
28   ///////////////////////////////////////////////////////////////////
29   //
30   //    CLASS NAME : ServiceInfo
31   //
32   /** */
33   class ServiceInfo : public repo::RepoInfoBase
34   {
35   public:
36     /** Default ctor creates \ref noService.*/
37     ServiceInfo();
38
39     /**
40      *  Creates ServiceInfo with specified alias.
41      *
42      * \param alias unique short name of service
43      */
44     ServiceInfo( const std::string & alias );
45
46     /**
47      * ServiceInfo with alias and its URL
48      *
49      * \param alias unique shortname of service
50      * \param url url to service
51      */
52     ServiceInfo( const std::string & alias, const Url& url );
53
54     virtual ~ServiceInfo();
55
56   public:
57     /** Represents an empty service. */
58     static const ServiceInfo noService;
59
60   public:
61
62     /**
63      * Gets url to service
64      *
65      * \return url to service
66      */
67     Url url() const;
68
69     /**
70      * Sets url for this service
71      *
72      * \param url url to this service
73      */
74     void setUrl( const Url& url );
75
76     /**
77      * 
78      */
79     repo::ServiceType type() const;
80     
81     /**
82      * Set service type.
83      * 
84      * \param type the new type
85      */
86     void setType( const repo::ServiceType & type );
87
88     void setProbedType( const repo::ServiceType & t ) const;
89
90
91     /** \name Set of catalogs (repository aliases) to enable on next refresh.
92      *
93      * Per default new repositories are created in disabled state. But repositories
94      * mentioned here will be created in enabled state on the next refresh.
95      * Afterwards they get removed from the list.
96      */
97     //@{
98     /** Container of catalogs. */
99     typedef std::set<std::string>    CatalogsToEnable;
100     bool                             catalogsToEnableEmpty() const;
101     CatalogsToEnable::size_type      catalogsToEnableSize() const;
102     CatalogsToEnable::const_iterator catalogsToEnableBegin() const;
103     CatalogsToEnable::const_iterator catalogsToEnableEnd() const;
104
105     /** Wheter \c alias_r is mentioned in CatalogsToEnable. */
106     bool catalogToEnableFind( const std::string & alias_r ) const;
107
108     /** Add \c alias_r to the set of CatalogsToEnable. */
109     void addCatalogToEnable( const std::string & alias_r );
110     /** Remove \c alias_r to the set of CatalogsToEnable. */
111     void delCatalogToEnable( const std::string & alias_r );
112     //@}
113
114     /** \name Set of catalogs (repository aliases) to disable on next refresh.
115      *
116      * Repositories mentioned here will be disabled on the next refresh, in case they
117      * still exist. Afterwards they get removed from the list.
118      */
119     //@{
120     /** Container of catalogs. */
121     typedef std::set<std::string>     CatalogsToDisable;
122     bool                              catalogsToDisableEmpty() const;
123     CatalogsToDisable::size_type      catalogsToDisableSize() const;
124     CatalogsToDisable::const_iterator catalogsToDisableBegin() const;
125     CatalogsToDisable::const_iterator catalogsToDisableEnd() const;
126
127     /** Wheter \c alias_r is mentioned in CatalogsToDisable. */
128     bool catalogToDisableFind( const std::string & alias_r ) const;
129
130     /** Add \c alias_r to the set of CatalogsToDisable. */
131     void addCatalogToDisable( const std::string & alias_r );
132     /** Remove \c alias_r to the set of CatalogsToDisable. */
133     void delCatalogToDisable( const std::string & alias_r );
134     //@}
135
136   public:
137     /**
138      * Writes ServiceInfo to stream in ".service" format
139      *
140      * \param str stream where serialized version service is written
141      */
142     virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
143
144     /**
145      * Write an XML representation of this ServiceInfo object.
146      */
147     virtual std::ostream & dumpAsXMLOn(std::ostream & str) const;
148
149     /**
150      * Write an XML representation of this ServiceInfo object.
151      *
152      * \param str
153      * \param content if not empty, produces <service ...>content</service>
154      *                otherwise <service .../>
155      */
156     virtual std::ostream & dumpAsXMLOn(
157         std::ostream & str, const std::string & content) const;
158
159     class Impl;
160
161   private:
162       RWCOW_pointer<Impl> _pimpl;
163   };
164   ///////////////////////////////////////////////////////////////////
165
166   typedef shared_ptr<ServiceInfo> ServiceInfo_Ptr;
167
168   /** \relates ServiceInfo Stream output */
169   std::ostream & operator<<( std::ostream & str, const ServiceInfo & obj );
170
171
172     /////////////////////////////////////////////////////////////////
173 } // namespace zypp
174 ///////////////////////////////////////////////////////////////////
175 #endif // ZYPP_SAT_REPOSITORY_H