libzypp  17.25.3
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/base/Iterable.h>
21 #include <zypp/repo/ServiceType.h>
22 #include <zypp/RepoInfo.h>
23 #include <zypp/Date.h>
24 
26 namespace zypp
27 {
28 
37  {
38  public:
40  ServiceInfo();
41 
47  ServiceInfo( const std::string & alias );
48 
55  ServiceInfo( const std::string & alias, const Url& url );
56 
57  virtual ~ServiceInfo();
58 
59  public:
61  static const ServiceInfo noService;
62 
63  public:
64 
66  Url url() const;
67 
69  Url rawUrl() const;
70 
72  void setUrl( const Url& url );
73 
74 
76  repo::ServiceType type() const;
77 
79  void setType( const repo::ServiceType & type );
80 
82  void setProbedType( const repo::ServiceType & t ) const;
83 
92  Date::Duration ttl() const;
93 
95  void setTtl( Date::Duration ttl_r );
96 
98  void setProbedTtl( Date::Duration ttl_r ) const;
99 
101  Date lrf() const;
102 
104  void setLrf( Date lrf_r );
106  //
115  typedef std::set<std::string> ReposToEnable;
116  bool reposToEnableEmpty() const;
118  ReposToEnable::const_iterator reposToEnableBegin() const;
119  ReposToEnable::const_iterator reposToEnableEnd() const;
121  { return makeIterable( reposToEnableBegin(), reposToEnableEnd() ); }
122 
124  bool repoToEnableFind( const std::string & alias_r ) const;
125 
127  void addRepoToEnable( const std::string & alias_r );
129  void delRepoToEnable( const std::string & alias_r );
131  void clearReposToEnable();
133 
141  typedef std::set<std::string> ReposToDisable;
142  bool reposToDisableEmpty() const;
144  ReposToDisable::const_iterator reposToDisableBegin() const;
145  ReposToDisable::const_iterator reposToDisableEnd() const;
147  { return makeIterable( reposToDisableBegin(), reposToDisableEnd() ); }
148 
150  bool repoToDisableFind( const std::string & alias_r ) const;
151 
153  void addRepoToDisable( const std::string & alias_r );
155  void delRepoToDisable( const std::string & alias_r );
157  void clearReposToDisable();
159 
167  struct RepoState
168  {
169  bool enabled;
171  unsigned priority;
172 
174  : enabled( false ), autorefresh( true ), priority( RepoInfo::defaultPriority() )
175  {}
176  RepoState( const RepoInfo & repo_r )
177  : enabled( repo_r.enabled() ), autorefresh( repo_r.autorefresh() ), priority( repo_r.priority() )
178  {}
179  bool operator==( const RepoState & rhs ) const
180  { return( enabled==rhs.enabled && autorefresh==rhs.autorefresh && priority==rhs.priority ); }
181  bool operator!=( const RepoState & rhs ) const
182  { return ! operator==( rhs ); }
183  friend std::ostream & operator<<( std::ostream & str, const RepoState & obj );
184  };
185  typedef std::map<std::string,RepoState> RepoStates;
186 
188  const RepoStates & repoStates() const;
189 
191  void setRepoStates( RepoStates newStates_r );
193 
194  public:
200  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
201 
209  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
210 
211  struct Impl;
212 
213  private:
215  };
217 
219  typedef shared_ptr<ServiceInfo> ServiceInfo_Ptr;
221  typedef shared_ptr<const ServiceInfo> ServiceInfo_constPtr;
223  typedef std::list<ServiceInfo> ServiceInfoList;
224 
226  std::ostream & operator<<( std::ostream & str, const ServiceInfo & obj );
227 
228 
230 } // namespace zypp
232 #endif // ZYPP_SAT_REPOSITORY_H
zypp::ServiceInfo::reposToEnableEnd
ReposToEnable::const_iterator reposToEnableEnd() const
Definition: ServiceInfo.cc:122
zypp::repo::ServiceType
Service type enumeration.
Definition: ServiceType.h:27
zypp::ServiceInfo::noService
static const ServiceInfo noService
Represents an empty service.
Definition: ServiceInfo.h:61
zypp::ServiceInfo::url
Url url() const
The service url.
Definition: ServiceInfo.cc:99
zypp::ServiceInfo::reposToEnableBegin
ReposToEnable::const_iterator reposToEnableBegin() const
Definition: ServiceInfo.cc:121
zypp::ServiceInfo::RepoState
Definition: ServiceInfo.h:168
zypp::ServiceInfo::setLrf
void setLrf(Date lrf_r)
Set date of last refresh.
Definition: ServiceInfo.cc:117
zypp::ServiceInfo::ReposToDisable
std::set< std::string > ReposToDisable
Container of repos.
Definition: ServiceInfo.h:141
zypp::ServiceInfo::reposToEnable
Iterable< ReposToEnable::const_iterator > reposToEnable() const
Definition: ServiceInfo.h:120
zypp::ServiceInfo::repoStates
const RepoStates & repoStates() const
Access the remembered repository states.
Definition: ServiceInfo.cc:161
zypp::ServiceInfo
Service data.
Definition: ServiceInfo.h:37
zypp::ServiceInfo::clearReposToEnable
void clearReposToEnable()
Clear the set of ReposToEnable.
Definition: ServiceInfo.cc:136
zypp::ServiceInfo::ServiceInfo
ServiceInfo()
Default ctor creates noService.
Definition: ServiceInfo.cc:86
zypp::RepoInfo
What is known about a repository.
Definition: RepoInfo.h:72
zypp::ServiceInfo::repoToDisableFind
bool repoToDisableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToDisable.
Definition: ServiceInfo.cc:145
zypp::ServiceInfo::RepoState::autorefresh
bool autorefresh
Definition: ServiceInfo.h:170
zypp::ServiceInfo::addRepoToEnable
void addRepoToEnable(const std::string &alias_r)
Add alias_r to the set of ReposToEnable.
Definition: ServiceInfo.cc:127
zypp::ServiceInfo::dumpAsXmlOn
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this ServiceInfo object.
Definition: ServiceInfo.cc:210
zypp::ServiceInfo::addRepoToDisable
void addRepoToDisable(const std::string &alias_r)
Add alias_r to the set of ReposToDisable.
Definition: ServiceInfo.cc:148
zypp::ServiceInfo::RepoStates
std::map< std::string, RepoState > RepoStates
Definition: ServiceInfo.h:185
zypp::ServiceInfo::reposToDisableBegin
ReposToDisable::const_iterator reposToDisableBegin() const
Definition: ServiceInfo.cc:142
zypp::ServiceInfo::dumpAsIniOn
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Writes ServiceInfo to stream in ".service" format.
Definition: ServiceInfo.cc:173
zypp::ServiceInfo::RepoState::operator!=
bool operator!=(const RepoState &rhs) const
Definition: ServiceInfo.h:181
zypp::ServiceInfo::lrf
Date lrf() const
Date of last refresh (if known).
Definition: ServiceInfo.cc:116
zypp::ServiceInfo::reposToEnableSize
ReposToEnable::size_type reposToEnableSize() const
Definition: ServiceInfo.cc:120
zypp::ServiceInfo::ttl
Date::Duration ttl() const
Sugested TTL between two metadata auto-refreshs.
Definition: ServiceInfo.cc:112
zypp::ServiceInfo::~ServiceInfo
virtual ~ServiceInfo()
Definition: ServiceInfo.cc:96
zypp::ServiceInfo::delRepoToDisable
void delRepoToDisable(const std::string &alias_r)
Remove alias_r from the set of ReposToDisable.
Definition: ServiceInfo.cc:154
zypp::ServiceInfo::reposToEnableEmpty
bool reposToEnableEmpty() const
Definition: ServiceInfo.cc:119
Url.h
zypp::ServiceInfo::setType
void setType(const repo::ServiceType &type)
Set service type.
Definition: ServiceInfo.cc:109
zypp::ServiceInfo::repoToEnableFind
bool repoToEnableFind(const std::string &alias_r) const
Whether alias_r is mentioned in ReposToEnable.
Definition: ServiceInfo.cc:124
zypp::ServiceInfo::reposToDisableEmpty
bool reposToDisableEmpty() const
Definition: ServiceInfo.cc:140
zypp::ServiceInfo::ServiceInfo_constPtr
shared_ptr< const ServiceInfo > ServiceInfo_constPtr
Definition: ServiceInfo.h:221
RepoInfo.h
zypp::ServiceInfo::ServiceInfo_Ptr
shared_ptr< ServiceInfo > ServiceInfo_Ptr
Definition: ServiceInfo.h:219
zypp::repo::RepoInfoBase::alias
std::string alias() const
unique identifier for this source.
Definition: RepoInfoBase.cc:111
zypp::Date::Duration
time_t Duration
Definition: Date.h:39
zypp::ServiceInfo::reposToDisable
Iterable< ReposToDisable::const_iterator > reposToDisable() const
Definition: ServiceInfo.h:146
zypp::ServiceInfo::delRepoToEnable
void delRepoToEnable(const std::string &alias_r)
Remove alias_r from the set of ReposToEnable.
Definition: ServiceInfo.cc:133
Date.h
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::ServiceInfo::rawUrl
Url rawUrl() const
The service raw url (no variables replaced)
Definition: ServiceInfo.cc:102
zypp::ServiceInfo::reposToDisableSize
ReposToDisable::size_type reposToDisableSize() const
Definition: ServiceInfo.cc:141
zypp::ServiceInfo::setProbedTtl
void setProbedTtl(Date::Duration ttl_r) const
Lazy init sugested TTL.
Definition: ServiceInfo.cc:114
Iterable.h
zypp::repo::RepoInfoBase
Base class implementing common features of RepoInfo and ServiceInfo.
Definition: RepoInfoBase.h:40
zypp::ServiceInfo::setTtl
void setTtl(Date::Duration ttl_r)
Set sugested TTL.
Definition: ServiceInfo.cc:113
zypp::ServiceInfo::RepoState::priority
unsigned priority
Definition: ServiceInfo.h:171
zypp::ServiceInfo::type
repo::ServiceType type() const
Service type.
Definition: ServiceInfo.cc:108
zypp::ServiceInfo::setProbedType
void setProbedType(const repo::ServiceType &t) const
Lazy init service type.
Definition: ServiceInfo.cc:110
zypp::ServiceInfo::reposToDisableEnd
ReposToDisable::const_iterator reposToDisableEnd() const
Definition: ServiceInfo.cc:143
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::Date
Store and operate on date (time_t).
Definition: Date.h:33
zypp::ServiceInfo::clearReposToDisable
void clearReposToDisable()
Clear the set of ReposToDisable.
Definition: ServiceInfo.cc:157
zypp::ServiceInfo::RepoState::RepoState
RepoState(const RepoInfo &repo_r)
Definition: ServiceInfo.h:176
zypp::sat::detail::size_type
SolvableIdType size_type
Definition: PoolMember.h:126
zypp::ServiceInfo::RepoState::RepoState
RepoState()
Definition: ServiceInfo.h:173
zypp::RWCOW_pointer< Impl >
str
String related utilities and Regular expression matching.
ServiceType.h
zypp::ServiceInfo::setUrl
void setUrl(const Url &url)
Set the service url (raw value)
Definition: ServiceInfo.cc:105
zypp::ServiceInfo::setRepoStates
void setRepoStates(RepoStates newStates_r)
Remember a new set of repository states.
Definition: ServiceInfo.cc:162
zypp::ServiceInfo::ServiceInfoList
std::list< ServiceInfo > ServiceInfoList
Definition: ServiceInfo.h:223
zypp::Url
Url manipulation class.
Definition: Url.h:92
zypp::ServiceInfo::RepoState::operator==
bool operator==(const RepoState &rhs) const
Definition: ServiceInfo.h:179
zypp::ServiceInfo::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition: ServiceInfo.h:211
zypp::ServiceInfo::RepoState::operator<<
friend std::ostream & operator<<(std::ostream &str, const RepoState &obj)
Definition: ServiceInfo.cc:165
zypp::ServiceInfo::Impl
Definition: ServiceInfo.cc:34
zypp::Iterable
Definition: Iterable.h:37
zypp::ServiceInfo::ReposToEnable
std::set< std::string > ReposToEnable
Container of repos.
Definition: ServiceInfo.h:115
zypp::ServiceInfo::RepoState::enabled
bool enabled
Definition: ServiceInfo.h:169