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