libzypp  14.29.1
ServiceInfo.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
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/RepoInfo.h"
22 
23 
25 namespace zypp
26 {
27 
29  //
30  // CLASS NAME : ServiceInfo
31  //
34  {
35  public:
37  ServiceInfo();
38 
44  ServiceInfo( const std::string & alias );
45 
52  ServiceInfo( const std::string & alias, const Url& url );
53 
54  virtual ~ServiceInfo();
55 
56  public:
58  static const ServiceInfo noService;
59 
60  public:
61 
67  Url url() const;
68 
74  void setUrl( const Url& url );
75 
79  repo::ServiceType type() const;
80 
86  void setType( const repo::ServiceType & type );
87 
88  void setProbedType( const repo::ServiceType & t ) const;
89 
90 
99  typedef std::set<std::string> ReposToEnable;
100  bool reposToEnableEmpty() const;
102  ReposToEnable::const_iterator reposToEnableBegin() const;
103  ReposToEnable::const_iterator reposToEnableEnd() const;
104 
106  bool repoToEnableFind( const std::string & alias_r ) const;
107 
109  void addRepoToEnable( const std::string & alias_r );
111  void delRepoToEnable( const std::string & alias_r );
113  void clearReposToEnable();
115 
123  typedef std::set<std::string> ReposToDisable;
124  bool reposToDisableEmpty() const;
126  ReposToDisable::const_iterator reposToDisableBegin() const;
127  ReposToDisable::const_iterator reposToDisableEnd() const;
128 
130  bool repoToDisableFind( const std::string & alias_r ) const;
131 
133  void addRepoToDisable( const std::string & alias_r );
135  void delRepoToDisable( const std::string & alias_r );
137  void clearReposToDisable();
139 
147  struct RepoState
148  {
149  bool enabled;
151  unsigned priority;
152 
154  : enabled( false ), autorefresh( true ), priority( RepoInfo::defaultPriority() )
155  {}
156  RepoState( const RepoInfo & repo_r )
157  : enabled( repo_r.enabled() ), autorefresh( repo_r.autorefresh() ), priority( repo_r.priority() )
158  {}
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 );
164  };
165  typedef std::map<std::string,RepoState> RepoStates;
166 
168  const RepoStates & repoStates() const;
169 
171  void setRepoStates( RepoStates newStates_r );
173 
174  public:
180  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
181 
189  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
190 
192  ZYPP_DEPRECATED std::ostream & dumpAsXMLOn( std::ostream & str, const std::string & content = "" ) const { return dumpAsXmlOn( str, content ); }
193 
194  class Impl;
195 
196  private:
198  };
200 
202  typedef shared_ptr<ServiceInfo> ServiceInfo_Ptr;
204  typedef shared_ptr<const ServiceInfo> ServiceInfo_constPtr;
206  typedef std::list<ServiceInfo> ServiceInfoList;
207 
209  std::ostream & operator<<( std::ostream & str, const ServiceInfo & obj );
210 
211 
213 } // namespace zypp
215 #endif // ZYPP_SAT_REPOSITORY_H
std::string alias() const
unique identifier for this source.
std::set< std::string > ReposToEnable
Container of repos.
Definition: ServiceInfo.h:99
ReposToDisable::size_type reposToDisableSize() const
Definition: ServiceInfo.cc:141
ReposToEnable::const_iterator reposToEnableBegin() const
Definition: ServiceInfo.cc:116
void clearReposToEnable()
Clear the set of ReposToEnable.
Definition: ServiceInfo.cc:134
String related utilities and Regular expression matching.
void addRepoToEnable(const std::string &alias_r)
Add alias_r to the set of ReposToEnable.
Definition: ServiceInfo.cc:125
What is known about a repository.
Definition: RepoInfo.h:66
const RepoStates & repoStates() const
Access the remembered repository states.
Definition: ServiceInfo.cc:165
ReposToDisable::const_iterator reposToDisableEnd() const
Definition: ServiceInfo.cc:147
void setType(const repo::ServiceType &type)
Set service type.
Definition: ServiceInfo.cc:104
RWCOW_pointer< Impl > _pimpl
Definition: ServiceInfo.h:194
ReposToDisable::const_iterator reposToDisableBegin() const
Definition: ServiceInfo.cc:144
std::map< std::string, RepoState > RepoStates
Definition: ServiceInfo.h:165
shared_ptr< const ServiceInfo > ServiceInfo_constPtr
Definition: ServiceInfo.h:204
void clearReposToDisable()
Clear the set of ReposToDisable.
Definition: ServiceInfo.cc:162
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
Service type enumeration.
Definition: ServiceType.h:26
void setRepoStates(RepoStates newStates_r)
Remember a new set of repository states.
Definition: ServiceInfo.cc:168
bool reposToEnableEmpty() const
Definition: ServiceInfo.cc:110
ServiceInfo()
Default ctor creates noService.
Definition: ServiceInfo.cc:86
void delRepoToEnable(const std::string &alias_r)
Remove alias_r from the set of ReposToEnable.
Definition: ServiceInfo.cc:131
bool reposToDisableEmpty() const
Definition: ServiceInfo.cc:138
bool operator!=(const RepoState &rhs) const
Definition: ServiceInfo.h:161
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this ServiceInfo object.
Definition: ServiceInfo.cc:210
virtual ~ServiceInfo()
Definition: ServiceInfo.cc:96
SolvableIdType size_type
Definition: PoolMember.h:99
friend std::ostream & operator<<(std::ostream &str, const RepoState &obj)
Definition: ServiceInfo.cc:171
void setUrl(const Url &url)
Sets url for this service.
Definition: ServiceInfo.cc:100
RepoState(const RepoInfo &repo_r)
Definition: ServiceInfo.h:156
std::set< std::string > ReposToDisable
Container of repos.
Definition: ServiceInfo.h:123
std::list< ServiceInfo > ServiceInfoList
Definition: ServiceInfo.h:206
ZYPP_DEPRECATED std::ostream & dumpAsXMLOn(std::ostream &str, const std::string &content="") const
Definition: ServiceInfo.h:192
bool operator==(const RepoState &rhs) const
Definition: ServiceInfo.h:159
static const ServiceInfo noService
Represents an empty service.
Definition: ServiceInfo.h:58
bool repoToDisableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToDisable.
Definition: ServiceInfo.cc:150
void delRepoToDisable(const std::string &alias_r)
Remove alias_r from the set of ReposToDisable.
Definition: ServiceInfo.cc:159
void addRepoToDisable(const std::string &alias_r)
Add alias_r to the set of ReposToDisable.
Definition: ServiceInfo.cc:153
Base class implementing common features of RepoInfo and ServiceInfo.
Definition: RepoInfoBase.h:36
bool repoToEnableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToEnable.
Definition: ServiceInfo.cc:122
ReposToEnable::const_iterator reposToEnableEnd() const
Definition: ServiceInfo.cc:119
ReposToEnable::size_type reposToEnableSize() const
Definition: ServiceInfo.cc:113
shared_ptr< ServiceInfo > ServiceInfo_Ptr
Definition: ServiceInfo.h:202
Url url() const
Gets url to service.
Definition: ServiceInfo.cc:99
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3...
Definition: APIConfig.h:86
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
void setProbedType(const repo::ServiceType &t) const
Definition: ServiceInfo.cc:107
Url manipulation class.
Definition: Url.h:87
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Writes ServiceInfo to stream in ".service" format.
Definition: ServiceInfo.cc:179
repo::ServiceType type() const
Definition: ServiceInfo.cc:102