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 ///////////////////////////////////////////////////////////////////
29 /// \class ServiceInfo
30 /// \brief Service data
32 /// \note Name and Url are subject to repo variable replacement
33 /// (\see \ref RepoVariablesStringReplacer).
35 class ServiceInfo : public repo::RepoInfoBase
38 /** Default ctor creates \ref noService.*/
42 * Creates ServiceInfo with specified alias.
44 * \param alias unique short name of service
46 ServiceInfo( const std::string & alias );
49 * ServiceInfo with alias and its URL
51 * \param alias unique shortname of service
52 * \param url url to service
54 ServiceInfo( const std::string & alias, const Url& url );
56 virtual ~ServiceInfo();
59 /** Represents an empty service. */
60 static const ServiceInfo noService;
64 /** The service url */
67 /** The service raw url (no variables replaced) */
70 /** Set the service url (raw value) */
71 void setUrl( const Url& url );
75 repo::ServiceType type() const;
77 /** Set service type */
78 void setType( const repo::ServiceType & type );
80 /** Lazy init service type */
81 void setProbedType( const repo::ServiceType & t ) const;
84 /** \name Set of repos (repository aliases) to enable on next refresh.
86 * Per default new repositories are created in disabled state. But repositories
87 * mentioned here will be created in enabled state on the next refresh.
88 * Afterwards they get removed from the list.
91 /** Container of repos. */
92 typedef std::set<std::string> ReposToEnable;
93 bool reposToEnableEmpty() const;
94 ReposToEnable::size_type reposToEnableSize() const;
95 ReposToEnable::const_iterator reposToEnableBegin() const;
96 ReposToEnable::const_iterator reposToEnableEnd() const;
98 /** Whether \c alias_r is mentioned in ReposToEnable. */
99 bool repoToEnableFind( const std::string & alias_r ) const;
101 /** Add \c alias_r to the set of ReposToEnable. */
102 void addRepoToEnable( const std::string & alias_r );
103 /** Remove \c alias_r from the set of ReposToEnable. */
104 void delRepoToEnable( const std::string & alias_r );
105 /** Clear the set of ReposToEnable. */
106 void clearReposToEnable();
109 /** \name Set of repos (repository aliases) to disable on next refresh.
111 * Repositories mentioned here will be disabled on the next refresh, in case they
112 * still exist. Afterwards they get removed from the list.
115 /** Container of repos. */
116 typedef std::set<std::string> ReposToDisable;
117 bool reposToDisableEmpty() const;
118 ReposToDisable::size_type reposToDisableSize() const;
119 ReposToDisable::const_iterator reposToDisableBegin() const;
120 ReposToDisable::const_iterator reposToDisableEnd() const;
122 /** Whether \c alias_r is mentioned in ReposToDisable. */
123 bool repoToDisableFind( const std::string & alias_r ) const;
125 /** Add \c alias_r to the set of ReposToDisable. */
126 void addRepoToDisable( const std::string & alias_r );
127 /** Remove \c alias_r from the set of ReposToDisable. */
128 void delRepoToDisable( const std::string & alias_r );
129 /** Clear the set of ReposToDisable. */
130 void clearReposToDisable();
133 /** \name The original repo state as defined by the repoindex.xml upon last refresh.
135 * This state is remembered to detect any user modifications applied to the repos.
136 * It may not be available for all repos or in plugin services. In this case all
137 * changes requested by a service refresh are applied unconditionally.
147 : enabled( false ), autorefresh( true ), priority( RepoInfo::defaultPriority() )
149 RepoState( const RepoInfo & repo_r )
150 : enabled( repo_r.enabled() ), autorefresh( repo_r.autorefresh() ), priority( repo_r.priority() )
152 bool operator==( const RepoState & rhs ) const
153 { return( enabled==rhs.enabled && autorefresh==rhs.autorefresh && priority==rhs.priority ); }
154 bool operator!=( const RepoState & rhs ) const
155 { return ! operator==( rhs ); }
156 friend std::ostream & operator<<( std::ostream & str, const RepoState & obj );
158 typedef std::map<std::string,RepoState> RepoStates;
160 /** Access the remembered repository states. */
161 const RepoStates & repoStates() const;
163 /** Remember a new set of repository states. */
164 void setRepoStates( RepoStates newStates_r );
169 * Writes ServiceInfo to stream in ".service" format
171 * \param str stream where serialized version service is written
173 virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
176 * Write an XML representation of this ServiceInfo object.
179 * \param content if not empty, produces <service ...>content</service>
180 * otherwise <service .../>
182 virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
187 RWCOW_pointer<Impl> _pimpl;
189 ///////////////////////////////////////////////////////////////////
191 /** \relates ServiceInfo */
192 typedef shared_ptr<ServiceInfo> ServiceInfo_Ptr;
193 /** \relates ServiceInfo */
194 typedef shared_ptr<const ServiceInfo> ServiceInfo_constPtr;
195 /** \relates ServiceInfo */
196 typedef std::list<ServiceInfo> ServiceInfoList;
198 /** \relates ServiceInfo Stream output */
199 std::ostream & operator<<( std::ostream & str, const ServiceInfo & obj );
202 /////////////////////////////////////////////////////////////////
204 ///////////////////////////////////////////////////////////////////
205 #endif // ZYPP_SAT_REPOSITORY_H