Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / ServiceInfo.cc
index 1242990..3ebabc7 100644 (file)
@@ -13,6 +13,7 @@
 #include <iostream>
 
 #include "zypp/base/String.h"
+#include "zypp/base/DefaultIntegral.h"
 #include "zypp/parser/xml/XmlEscape.h"
 
 #include "zypp/RepoInfo.h"
@@ -35,33 +36,32 @@ namespace zypp
     typedef ServiceInfo::ReposToDisable ReposToDisable;
 
   public:
-    RepoVariablesReplacedUrl url;
-    repo::ServiceType type;
-    ReposToEnable  reposToEnable;
-    ReposToDisable reposToDisable;
-    RepoStates     repoStates;
-
+    RepoVariablesReplacedUrl _url;
+    repo::ServiceType _type;
+    ReposToEnable _reposToEnable;
+    ReposToDisable _reposToDisable;
+    RepoStates _repoStates;
+    DefaultIntegral<Date::Duration,0> _ttl;
+    Date _lrf;
 
   public:
     Impl()
-      : type(repo::ServiceType::NONE_e)
     {}
 
-    Impl(const Url & url_)
-      : url(url_)
-      , type(repo::ServiceType::NONE_e)
+    Impl( const Url & url_r )
+    : _url( url_r )
     {}
 
     ~Impl()
     {}
 
-    void setProbedType( const repo::ServiceType & t ) const
+    void setProbedType( const repo::ServiceType & type_r ) const
     {
-      if ( type == repo::ServiceType::NONE
-           && t != repo::ServiceType::NONE )
+      if ( _type == repo::ServiceType::NONE
+           && type_r != repo::ServiceType::NONE )
       {
         // lazy init!
-        const_cast<Impl*>(this)->type = t;
+        const_cast<Impl*>(this)->_type = type_r;
       }
     }
 
@@ -97,82 +97,70 @@ namespace zypp
   {}
 
   Url ServiceInfo::url() const                 // Variables replaced
-  { return _pimpl->url.transformed(); }
+  { return _pimpl->_url.transformed(); }
 
   Url ServiceInfo::rawUrl() const              // Raw
-  { return _pimpl->url.raw(); }
+  { return _pimpl->_url.raw(); }
 
   void ServiceInfo::setUrl( const Url& url )   // Raw
-  { _pimpl->url.raw() = url; }
-
-  repo::ServiceType ServiceInfo::type() const
-  { return _pimpl->type; }
-  void ServiceInfo::setType( const repo::ServiceType & type )
-  { _pimpl->type = type; }
-
-  void ServiceInfo::setProbedType( const repo::ServiceType &t ) const
-  { _pimpl->setProbedType( t ); }
+  { _pimpl->_url.raw() = url; }
 
-  bool ServiceInfo::reposToEnableEmpty() const
-  { return _pimpl->reposToEnable.empty(); }
+  repo::ServiceType ServiceInfo::type() const                          { return _pimpl->_type; }
+  void ServiceInfo::setType( const repo::ServiceType & type )          { _pimpl->_type = type; }
+  void ServiceInfo::setProbedType( const repo::ServiceType &t ) const  { _pimpl->setProbedType( t ); }
 
-  ServiceInfo::ReposToEnable::size_type ServiceInfo::reposToEnableSize() const
-  { return _pimpl->reposToEnable.size(); }
+  Date::Duration ServiceInfo::ttl() const                      { return _pimpl->_ttl; }
+  void ServiceInfo::setTtl( Date::Duration ttl_r )             { _pimpl->_ttl = ttl_r; }
+  void ServiceInfo::setProbedTtl( Date::Duration ttl_r ) const { const_cast<ServiceInfo*>(this)->setTtl( ttl_r ); }
 
-  ServiceInfo::ReposToEnable::const_iterator ServiceInfo::reposToEnableBegin() const
-  { return _pimpl->reposToEnable.begin(); }
+  Date ServiceInfo::lrf() const                                        { return _pimpl->_lrf; }
+  void ServiceInfo::setLrf( Date lrf_r )                       { _pimpl->_lrf = lrf_r; }
 
-  ServiceInfo::ReposToEnable::const_iterator ServiceInfo::reposToEnableEnd() const
-  { return _pimpl->reposToEnable.end(); }
+  bool ServiceInfo::reposToEnableEmpty() const                                         { return _pimpl->_reposToEnable.empty(); }
+  ServiceInfo::ReposToEnable::size_type ServiceInfo::reposToEnableSize() const         { return _pimpl->_reposToEnable.size(); }
+  ServiceInfo::ReposToEnable::const_iterator ServiceInfo::reposToEnableBegin() const   { return _pimpl->_reposToEnable.begin(); }
+  ServiceInfo::ReposToEnable::const_iterator ServiceInfo::reposToEnableEnd() const     { return _pimpl->_reposToEnable.end(); }
 
   bool ServiceInfo::repoToEnableFind( const std::string & alias_r ) const
-  { return( _pimpl->reposToEnable.find( alias_r ) != _pimpl->reposToEnable.end() ); }
+  { return( _pimpl->_reposToEnable.find( alias_r ) != _pimpl->_reposToEnable.end() ); }
 
   void ServiceInfo::addRepoToEnable( const std::string & alias_r )
   {
-    _pimpl->reposToEnable.insert( alias_r );
-    _pimpl->reposToDisable.erase( alias_r );
+    _pimpl->_reposToEnable.insert( alias_r );
+    _pimpl->_reposToDisable.erase( alias_r );
   }
 
   void ServiceInfo::delRepoToEnable( const std::string & alias_r )
-  { _pimpl->reposToEnable.erase( alias_r ); }
+  { _pimpl->_reposToEnable.erase( alias_r ); }
 
   void ServiceInfo::clearReposToEnable()
-  { _pimpl->reposToEnable.clear(); }
-
-
-  bool ServiceInfo::reposToDisableEmpty() const
-  { return _pimpl->reposToDisable.empty(); }
+  { _pimpl->_reposToEnable.clear(); }
 
-  ServiceInfo::ReposToDisable::size_type ServiceInfo::reposToDisableSize() const
-  { return _pimpl->reposToDisable.size(); }
 
-  ServiceInfo::ReposToDisable::const_iterator ServiceInfo::reposToDisableBegin() const
-  { return _pimpl->reposToDisable.begin(); }
-
-  ServiceInfo::ReposToDisable::const_iterator ServiceInfo::reposToDisableEnd() const
-  { return _pimpl->reposToDisable.end(); }
+  bool ServiceInfo::reposToDisableEmpty() const                                                { return _pimpl->_reposToDisable.empty(); }
+  ServiceInfo::ReposToDisable::size_type ServiceInfo::reposToDisableSize() const       { return _pimpl->_reposToDisable.size(); }
+  ServiceInfo::ReposToDisable::const_iterator ServiceInfo::reposToDisableBegin() const { return _pimpl->_reposToDisable.begin(); }
+  ServiceInfo::ReposToDisable::const_iterator ServiceInfo::reposToDisableEnd() const   { return _pimpl->_reposToDisable.end(); }
 
   bool ServiceInfo::repoToDisableFind( const std::string & alias_r ) const
-  { return( _pimpl->reposToDisable.find( alias_r ) != _pimpl->reposToDisable.end() ); }
+  { return( _pimpl->_reposToDisable.find( alias_r ) != _pimpl->_reposToDisable.end() ); }
 
   void ServiceInfo::addRepoToDisable( const std::string & alias_r )
   {
-    _pimpl->reposToDisable.insert( alias_r );
-    _pimpl->reposToEnable.erase( alias_r );
+    _pimpl->_reposToDisable.insert( alias_r );
+    _pimpl->_reposToEnable.erase( alias_r );
   }
 
   void ServiceInfo::delRepoToDisable( const std::string & alias_r )
-  { _pimpl->reposToDisable.erase( alias_r ); }
+  { _pimpl->_reposToDisable.erase( alias_r ); }
 
   void ServiceInfo::clearReposToDisable()
-  { _pimpl->reposToDisable.clear(); }
+  { _pimpl->_reposToDisable.clear(); }
+
 
-  const ServiceInfo::RepoStates & ServiceInfo::repoStates() const
-  { return _pimpl->repoStates; }
+  const ServiceInfo::RepoStates & ServiceInfo::repoStates() const      { return _pimpl->_repoStates; }
+  void ServiceInfo::setRepoStates( RepoStates newStates_r )            { swap( _pimpl->_repoStates, newStates_r ); }
 
-  void ServiceInfo::setRepoStates( RepoStates newStates_r )
-  { swap( _pimpl->repoStates, newStates_r ); }
 
   std::ostream & operator<<( std::ostream & str, const ServiceInfo::RepoState & obj )
   {
@@ -188,6 +176,12 @@ namespace zypp
       << "url = " << rawUrl() << endl
       << "type = " << type() << endl;
 
+    if ( ttl() )
+      str << "ttl_sec = " << ttl() << endl;
+
+    if ( lrf() )
+      str << "lrf_dat = " << lrf().asSeconds() << endl;
+
     if ( ! repoStates().empty() )
     {
       unsigned cnt = 0U;
@@ -222,7 +216,8 @@ namespace zypp
       << " enabled=\"" << enabled() << "\""
       << " autorefresh=\"" << autorefresh() << "\""
       << " url=\"" << escape(url().asString()) << "\""
-      << " type=\"" << type().asString() << "\"";
+      << " type=\"" << type().asString() << "\""
+      << " ttl_sec=\"" << ttl() << "\"";
 
     if (content.empty())
       str << "/>" << endl;