1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ServiceInfo.h
12 #ifndef ZYPP_SERVICE_H
13 #define ZYPP_SERVICE_H
20 #include "zypp/repo/ServiceType.h"
21 #include "zypp/RepoInfo.h"
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////////
30 // CLASS NAME : ServiceInfo
33 class ServiceInfo : public repo::RepoInfoBase
36 /** Default ctor creates \ref noService.*/
40 * Creates ServiceInfo with specified alias.
42 * \param alias unique short name of service
44 ServiceInfo( const std::string & alias );
47 * ServiceInfo with alias and its URL
49 * \param alias unique shortname of service
50 * \param url url to service
52 ServiceInfo( const std::string & alias, const Url& url );
54 virtual ~ServiceInfo();
57 /** Represents an empty service. */
58 static const ServiceInfo noService;
65 * \return url to service
70 * Sets url for this service
72 * \param url url to this service
74 void setUrl( const Url& url );
79 repo::ServiceType type() const;
84 * \param type the new type
86 void setType( const repo::ServiceType & type );
88 void setProbedType( const repo::ServiceType & t ) const;
91 /** \name Set of repos (repository aliases) to enable on next refresh.
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.
98 /** Container of repos. */
99 typedef std::set<std::string> ReposToEnable;
100 bool reposToEnableEmpty() const;
101 ReposToEnable::size_type reposToEnableSize() const;
102 ReposToEnable::const_iterator reposToEnableBegin() const;
103 ReposToEnable::const_iterator reposToEnableEnd() const;
105 /** Whether \c alias_r is mentioned in ReposToEnable. */
106 bool repoToEnableFind( const std::string & alias_r ) const;
108 /** Add \c alias_r to the set of ReposToEnable. */
109 void addRepoToEnable( const std::string & alias_r );
110 /** Remove \c alias_r from the set of ReposToEnable. */
111 void delRepoToEnable( const std::string & alias_r );
112 /** Clear the set of ReposToEnable. */
113 void clearReposToEnable();
116 /** \name Set of repos (repository aliases) to disable on next refresh.
118 * Repositories mentioned here will be disabled on the next refresh, in case they
119 * still exist. Afterwards they get removed from the list.
122 /** Container of repos. */
123 typedef std::set<std::string> ReposToDisable;
124 bool reposToDisableEmpty() const;
125 ReposToDisable::size_type reposToDisableSize() const;
126 ReposToDisable::const_iterator reposToDisableBegin() const;
127 ReposToDisable::const_iterator reposToDisableEnd() const;
129 /** Whether \c alias_r is mentioned in ReposToDisable. */
130 bool repoToDisableFind( const std::string & alias_r ) const;
132 /** Add \c alias_r to the set of ReposToDisable. */
133 void addRepoToDisable( const std::string & alias_r );
134 /** Remove \c alias_r from the set of ReposToDisable. */
135 void delRepoToDisable( const std::string & alias_r );
136 /** Clear the set of ReposToDisable. */
137 void clearReposToDisable();
140 /** \name The original repo state as defined by the repoindex.xml upon last refresh.
142 * This state is remembered to detect any user modifications applied to the repos.
143 * It may not be available for all repos or in plugin services. In this case all
144 * changes requested by a service refresh are applied unconditionally.
154 : enabled( false ), autorefresh( true ), priority( RepoInfo::defaultPriority() )
156 RepoState( const RepoInfo & repo_r )
157 : enabled( repo_r.enabled() ), autorefresh( repo_r.autorefresh() ), priority( repo_r.priority() )
159 bool operator==( const RepoState & rhs ) const
160 { return( enabled==rhs.enabled && autorefresh==rhs.autorefresh && priority==rhs.priority ); }
161 bool operator!=( const RepoState & rhs ) const
162 { return ! operator==( rhs ); }
163 friend std::ostream & operator<<( std::ostream & str, const RepoState & obj );
165 typedef std::map<std::string,RepoState> RepoStates;
167 /** Access the remembered repository states. */
168 const RepoStates & repoStates() const;
170 /** Remember a new set of repository states. */
171 void setRepoStates( RepoStates newStates_r );
176 * Writes ServiceInfo to stream in ".service" format
178 * \param str stream where serialized version service is written
180 virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
183 * Write an XML representation of this ServiceInfo object.
186 * \param content if not empty, produces <service ...>content</service>
187 * otherwise <service .../>
189 virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
194 RWCOW_pointer<Impl> _pimpl;
196 ///////////////////////////////////////////////////////////////////
198 /** \relates ServiceInfo */
199 typedef shared_ptr<ServiceInfo> ServiceInfo_Ptr;
200 /** \relates ServiceInfo */
201 typedef shared_ptr<const ServiceInfo> ServiceInfo_constPtr;
202 /** \relates ServiceInfo */
203 typedef std::list<ServiceInfo> ServiceInfoList;
205 /** \relates ServiceInfo Stream output */
206 std::ostream & operator<<( std::ostream & str, const ServiceInfo & obj );
209 /////////////////////////////////////////////////////////////////
211 ///////////////////////////////////////////////////////////////////
212 #endif // ZYPP_SAT_REPOSITORY_H