libzypp  14.48.5
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 
36  {
37  public:
39  ServiceInfo();
40 
46  ServiceInfo( const std::string & alias );
47 
54  ServiceInfo( const std::string & alias, const Url& url );
55 
56  virtual ~ServiceInfo();
57 
58  public:
60  static const ServiceInfo noService;
61 
62  public:
63 
65  Url url() const;
66 
68  Url rawUrl() const;
69 
71  void setUrl( const Url& url );
72 
73 
75  repo::ServiceType type() const;
76 
78  void setType( const repo::ServiceType & type );
79 
81  void setProbedType( const repo::ServiceType & t ) const;
82 
83 
92  typedef std::set<std::string> ReposToEnable;
93  bool reposToEnableEmpty() const;
95  ReposToEnable::const_iterator reposToEnableBegin() const;
96  ReposToEnable::const_iterator reposToEnableEnd() const;
97 
99  bool repoToEnableFind( const std::string & alias_r ) const;
100 
102  void addRepoToEnable( const std::string & alias_r );
104  void delRepoToEnable( const std::string & alias_r );
106  void clearReposToEnable();
108 
116  typedef std::set<std::string> ReposToDisable;
117  bool reposToDisableEmpty() const;
119  ReposToDisable::const_iterator reposToDisableBegin() const;
120  ReposToDisable::const_iterator reposToDisableEnd() const;
121 
123  bool repoToDisableFind( const std::string & alias_r ) const;
124 
126  void addRepoToDisable( const std::string & alias_r );
128  void delRepoToDisable( const std::string & alias_r );
130  void clearReposToDisable();
132 
140  struct RepoState
141  {
142  bool enabled;
144  unsigned priority;
145 
147  : enabled( false ), autorefresh( true ), priority( RepoInfo::defaultPriority() )
148  {}
149  RepoState( const RepoInfo & repo_r )
150  : enabled( repo_r.enabled() ), autorefresh( repo_r.autorefresh() ), priority( repo_r.priority() )
151  {}
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 );
157  };
158  typedef std::map<std::string,RepoState> RepoStates;
159 
161  const RepoStates & repoStates() const;
162 
164  void setRepoStates( RepoStates newStates_r );
166 
167  public:
173  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
174 
182  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
183 
184  class Impl;
185 
186  private:
188  };
190 
192  typedef shared_ptr<ServiceInfo> ServiceInfo_Ptr;
194  typedef shared_ptr<const ServiceInfo> ServiceInfo_constPtr;
196  typedef std::list<ServiceInfo> ServiceInfoList;
197 
199  std::ostream & operator<<( std::ostream & str, const ServiceInfo & obj );
200 
201 
203 } // namespace zypp
205 #endif // ZYPP_SAT_REPOSITORY_H
Service data.
Definition: ServiceInfo.h:35
std::string alias() const
unique identifier for this source.
std::set< std::string > ReposToEnable
Container of repos.
Definition: ServiceInfo.h:92
ReposToDisable::size_type reposToDisableSize() const
Definition: ServiceInfo.cc:147
ReposToEnable::const_iterator reposToEnableBegin() const
Definition: ServiceInfo.cc:122
void clearReposToEnable()
Clear the set of ReposToEnable.
Definition: ServiceInfo.cc:140
void addRepoToEnable(const std::string &alias_r)
Add alias_r to the set of ReposToEnable.
Definition: ServiceInfo.cc:131
What is known about a repository.
Definition: RepoInfo.h:72
const RepoStates & repoStates() const
Access the remembered repository states.
Definition: ServiceInfo.cc:171
ReposToDisable::const_iterator reposToDisableEnd() const
Definition: ServiceInfo.cc:153
void setType(const repo::ServiceType &type)
Set service type.
Definition: ServiceInfo.cc:110
RWCOW_pointer< Impl > _pimpl
Definition: ServiceInfo.h:184
ReposToDisable::const_iterator reposToDisableBegin() const
Definition: ServiceInfo.cc:150
std::map< std::string, RepoState > RepoStates
Definition: ServiceInfo.h:158
shared_ptr< const ServiceInfo > ServiceInfo_constPtr
Definition: ServiceInfo.h:194
void clearReposToDisable()
Clear the set of ReposToDisable.
Definition: ServiceInfo.cc:168
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:174
bool reposToEnableEmpty() const
Definition: ServiceInfo.cc:116
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:137
bool reposToDisableEmpty() const
Definition: ServiceInfo.cc:144
bool operator!=(const RepoState &rhs) const
Definition: ServiceInfo.h:154
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this ServiceInfo object.
Definition: ServiceInfo.cc:216
virtual ~ServiceInfo()
Definition: ServiceInfo.cc:96
SolvableIdType size_type
Definition: PoolMember.h:147
friend std::ostream & operator<<(std::ostream &str, const RepoState &obj)
Definition: ServiceInfo.cc:177
void setUrl(const Url &url)
Set the service url (raw value)
Definition: ServiceInfo.cc:105
RepoState(const RepoInfo &repo_r)
Definition: ServiceInfo.h:149
std::set< std::string > ReposToDisable
Container of repos.
Definition: ServiceInfo.h:116
Url rawUrl() const
The service raw url (no variables replaced)
Definition: ServiceInfo.cc:102
std::list< ServiceInfo > ServiceInfoList
Definition: ServiceInfo.h:196
bool operator==(const RepoState &rhs) const
Definition: ServiceInfo.h:152
static const ServiceInfo noService
Represents an empty service.
Definition: ServiceInfo.h:60
bool repoToDisableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToDisable.
Definition: ServiceInfo.cc:156
void delRepoToDisable(const std::string &alias_r)
Remove alias_r from the set of ReposToDisable.
Definition: ServiceInfo.cc:165
void addRepoToDisable(const std::string &alias_r)
Add alias_r to the set of ReposToDisable.
Definition: ServiceInfo.cc:159
Base class implementing common features of RepoInfo and ServiceInfo.
Definition: RepoInfoBase.h:39
bool repoToEnableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToEnable.
Definition: ServiceInfo.cc:128
ReposToEnable::const_iterator reposToEnableEnd() const
Definition: ServiceInfo.cc:125
ReposToEnable::size_type reposToEnableSize() const
Definition: ServiceInfo.cc:119
shared_ptr< ServiceInfo > ServiceInfo_Ptr
Definition: ServiceInfo.h:192
Url url() const
The service url.
Definition: ServiceInfo.cc:99
void setProbedType(const repo::ServiceType &t) const
Lazy init service type.
Definition: ServiceInfo.cc:113
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:185
repo::ServiceType type() const
Service type.
Definition: ServiceInfo.cc:108