- ServiceType introduced
[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   public:
55     /** Represents an empty service. */
56     static const ServiceInfo noService;
57
58   public:
59
60     /**
61      * Gets url to service
62      *
63      * \return url to service
64      */
65     Url url() const;
66
67     /**
68      * Sets url for this service
69      *
70      * \param url url to this service
71      */
72     void setUrl( const Url& url );
73
74     /**
75      * 
76      */
77     repo::ServiceType type() const;
78     
79     /**
80      * Set service type.
81      * 
82      * \param type the new type
83      */
84     void setType( const repo::ServiceType & type );
85
86     void setProbedType( const repo::ServiceType & t ) const;
87
88
89     /** \name Set of catalogs (repository aliases) to enable on next refresh.
90      *
91      * Per default new repositories are created in disabled state. But repositories
92      * mentioned here will be created in enabled state on the next refresh.
93      * Afterwards they get removed from the list.
94      */
95     //@{
96     /** Container of catalogs. */
97     typedef std::set<std::string>    CatalogsToEnable;
98     bool                             catalogsToEnableEmpty() const;
99     CatalogsToEnable::size_type      catalogsToEnableSize() const;
100     CatalogsToEnable::const_iterator catalogsToEnableBegin() const;
101     CatalogsToEnable::const_iterator catalogsToEnableEnd() const;
102
103     /** Wheter \c alias_r is mentioned in CatalogsToEnable. */
104     bool catalogToEnableFind( const std::string & alias_r ) const;
105
106     /** Add \c alias_r to the set of CatalogsToEnable. */
107     void addCatalogToEnable( const std::string & alias_r );
108     /** Remove \c alias_r to the set of CatalogsToEnable. */
109     void delCatalogToEnable( const std::string & alias_r );
110     //@}
111
112     /** \name Set of catalogs (repository aliases) to disable on next refresh.
113      *
114      * Repositories mentioned here will be disabled on the next refresh, in case they
115      * still exist. Afterwards they get removed from the list.
116      */
117     //@{
118     /** Container of catalogs. */
119     typedef std::set<std::string>     CatalogsToDisable;
120     bool                              catalogsToDisableEmpty() const;
121     CatalogsToDisable::size_type      catalogsToDisableSize() const;
122     CatalogsToDisable::const_iterator catalogsToDisableBegin() const;
123     CatalogsToDisable::const_iterator catalogsToDisableEnd() const;
124
125     /** Wheter \c alias_r is mentioned in CatalogsToDisable. */
126     bool catalogToDisableFind( const std::string & alias_r ) const;
127
128     /** Add \c alias_r to the set of CatalogsToDisable. */
129     void addCatalogToDisable( const std::string & alias_r );
130     /** Remove \c alias_r to the set of CatalogsToDisable. */
131     void delCatalogToDisable( const std::string & alias_r );
132     //@}
133
134   public:
135     /**
136      * Writes ServiceInfo to stream in ".service" format
137      *
138      * \param str stream where serialized version service is written
139      */
140     virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
141
142     /**
143      * Write an XML representation of this ServiceInfo object.
144      */
145     virtual std::ostream & dumpAsXMLOn(std::ostream & str) const;
146
147     /**
148      * Write an XML representation of this ServiceInfo object.
149      *
150      * \param str
151      * \param content if not empty, produces <service ...>content</service>
152      *                otherwise <service .../>
153      */
154     virtual std::ostream & dumpAsXMLOn(
155         std::ostream & str, const std::string & content) const;
156
157     class Impl;
158
159   private:
160       RWCOW_pointer<Impl> _pimpl;
161   };
162   ///////////////////////////////////////////////////////////////////
163
164   typedef shared_ptr<ServiceInfo> ServiceInfo_Ptr;
165
166   /** \relates ServiceInfo Stream output */
167   std::ostream & operator<<( std::ostream & str, const ServiceInfo & obj );
168
169
170     /////////////////////////////////////////////////////////////////
171 } // namespace zypp
172 ///////////////////////////////////////////////////////////////////
173 #endif // ZYPP_SAT_REPOSITORY_H