add catalogsToDisable to service
authorMichael Andres <ma@suse.de>
Thu, 11 Sep 2008 15:01:48 +0000 (15:01 +0000)
committerMichael Andres <ma@suse.de>
Thu, 11 Sep 2008 15:01:48 +0000 (15:01 +0000)
devel/devel.ma/NewPool.cc
zypp/ServiceInfo.cc
zypp/ServiceInfo.h

index b20a8d5..0cebe04 100644 (file)
@@ -430,16 +430,6 @@ void testCMP( const L & lhs, const R & rhs )
 #undef OUTS
 }
 
-namespace zypp
-{
-  enum TestE {
-    TE1, TE2, TE3
-  };
-
-  inline void fromString( const std::string & str_r, TestE & cl_r )
-  { cl_r = TE1; }
-
-}
 
 /******************************************************************
 **
@@ -454,11 +444,20 @@ try {
   INT << "===[START]==========================================" << endl;
   ZConfig::instance();
 
+#if 0
+  ServiceInfo s( "STest", Url("dir:///somewhere") );
+  DBG << s << endl;
+  s.addCatalogToEnable( "foo" );
+  s.addCatalogToEnable( "ba a" );
+  s.addCatalogToEnable( "kaa" );
+
+  RepoManager repoManager( makeRepoManager( sysRoot ) );
+  RepoInfoList repos = repoManager.knownRepositories();
+  RepoInfoList services = repoManager.knownServices();
 
-#if 1
-  DBG << str::fromString<TestE>("te1") << endl;
 
 
+  DBG << s << endl;
 
   ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
index 6438006..1d5cb47 100644 (file)
@@ -46,10 +46,12 @@ namespace zypp
   struct ServiceInfo::Impl : public repo::RepoInfoBase::Impl
   {
     typedef ServiceInfo::CatalogsToEnable CatalogsToEnable;
+    typedef ServiceInfo::CatalogsToDisable CatalogsToDisable;
 
   public:
     Url url;
-    CatalogsToEnable catalogsToEnable;
+    CatalogsToEnable  catalogsToEnable;
+    CatalogsToDisable catalogsToDisable;
 
   public:
     Impl() : repo::RepoInfoBase::Impl() {}
@@ -110,11 +112,35 @@ namespace zypp
   { _pimpl->catalogsToEnable.erase( alias_r ); }
 
 
+  bool ServiceInfo::catalogsToDisableEmpty() const
+  { return _pimpl->catalogsToDisable.empty(); }
+
+  ServiceInfo::CatalogsToDisable::size_type ServiceInfo::catalogsToDisableSize() const
+  { return _pimpl->catalogsToDisable.size(); }
+
+  ServiceInfo::CatalogsToDisable::const_iterator ServiceInfo::catalogsToDisableBegin() const
+  { return _pimpl->catalogsToDisable.begin(); }
+
+  ServiceInfo::CatalogsToDisable::const_iterator ServiceInfo::catalogsToDisableEnd() const
+  { return _pimpl->catalogsToDisable.end(); }
+
+  bool ServiceInfo::catalogToDisableFind( const std::string & alias_r ) const
+  { return( _pimpl->catalogsToDisable.find( alias_r ) != _pimpl->catalogsToDisable.end() ); }
+
+  void ServiceInfo::addCatalogToDisable( const std::string & alias_r )
+  { _pimpl->catalogsToDisable.insert( alias_r ); }
+
+  void ServiceInfo::delCatalogToDisable( const std::string & alias_r )
+  { _pimpl->catalogsToDisable.erase( alias_r ); }
+
+
   std::ostream & ServiceInfo::dumpAsIniOn( std::ostream & str ) const
   {
     RepoInfoBase::dumpAsIniOn(str) << "url = " << url() << endl;
     if ( ! catalogsToEnableEmpty() )
       str << "catalogstoenable = " << str::joinEscaped( catalogsToEnableBegin(), catalogsToEnableEnd() ) << endl;
+    if ( ! catalogsToDisableEmpty() )
+      str << "catalogstodisable = " << str::joinEscaped( catalogsToDisableBegin(), catalogsToDisableEnd() ) << endl;
     return str;
   }
 
@@ -130,7 +156,7 @@ namespace zypp
       << " enabled=\"" << enabled() << "\""
       << " autorefresh=\"" << autorefresh() << "\""
       << " url=\"" << escape(url().asString()) << "\"";
-    
+
     if (content.empty())
       str << "/>" << endl;
     else
index e4a27ff..ba40818 100644 (file)
@@ -94,6 +94,28 @@ namespace zypp
     void delCatalogToEnable( const std::string & alias_r );
     //@}
 
+    /** \name Set of catalogs (repository aliases) to disable on next refresh.
+     *
+     * Repositories mentioned here will be disabled on the next refresh, in case they
+     * still exist. Afterwards they get removed from the list.
+     */
+    //@{
+    /** Container of catalogs. */
+    typedef std::set<std::string>     CatalogsToDisable;
+    bool                              catalogsToDisableEmpty() const;
+    CatalogsToDisable::size_type      catalogsToDisableSize() const;
+    CatalogsToDisable::const_iterator catalogsToDisableBegin() const;
+    CatalogsToDisable::const_iterator catalogsToDisableEnd() const;
+
+    /** Wheter \c alias_r is mentioned in CatalogsToDisable. */
+    bool catalogToDisableFind( const std::string & alias_r ) const;
+
+    /** Add \c alias_r to the set of CatalogsToDisable. */
+    void addCatalogToDisable( const std::string & alias_r );
+    /** Remove \c alias_r to the set of CatalogsToDisable. */
+    void delCatalogToDisable( const std::string & alias_r );
+    //@}
+
   public:
     /**
      * Writes ServiceInfo to stream in ".service" format
@@ -109,7 +131,7 @@ namespace zypp
 
     /**
      * Write an XML representation of this ServiceInfo object.
-     * 
+     *
      * \param str
      * \param content if not empty, produces <service ...>content</service>
      *                otherwise <service .../>