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