MIL << "Deleted SourceManager Singleton." << endl;
}
+ SourceManager::const_iterator SourceManager::begin() const
+ { return _sources.begin(); }
+
+ SourceManager::const_iterator SourceManager::end() const
+ { return _sources.end(); }
+
+ SourceManager::SourceId_const_iterator SourceManager::SourceId_begin() const
+ { return make_map_key_begin( _sources ); }
+
+ SourceManager::SourceId_const_iterator SourceManager::SourceId_end() const
+ { return make_map_key_end( _sources ); }
+
+ SourceManager::Source_const_iterator SourceManager::Source_begin() const
+ { return make_map_value_begin( _sources ); }
+
+ SourceManager::Source_const_iterator SourceManager::Source_end() const
+ { return make_map_value_end( _sources ); }
+
void SourceManager::reset()
{
MIL << "SourceManager reset (forget all sources)" << endl;
id = 0;
ZYPP_CAUGHT(e2);
}
-
+
if( id == 0)
{
report.append( it->url + it->product_dir, expt );
dumpSourceTableOn( DBG );
return true;
}
-
+
void SourceManager::disableSourcesAt( const Pathname & root_r )
{
storage::PersistentStorage store;
std::list<storage::PersistentStorage::SourceData> new_sources = store.storedSources();
MIL << "Disabling all sources in store at " << root_r << endl;
-
+
for( std::list<storage::PersistentStorage::SourceData>::iterator it = new_sources.begin();
it != new_sources.end(); ++it)
{
#include <iosfwd>
#include <list>
+#include <map>
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
-#include "zypp/base/Gettext.h"
+//#include "zypp/base/Iterator.h"
+
+#include "zypp/base/Gettext.h" // move with FailedSourcesRestoreException
#include "zypp/Source.h"
#include "zypp/Url.h"
{ /////////////////////////////////////////////////////////////////
DEFINE_PTR_TYPE(SourceManager)
-
+ /** \todo move to separate header file.*/
class FailedSourcesRestoreException : public Exception
{
public:
{
friend std::ostream & operator<<( std::ostream & str, const SourceManager & obj );
-
public:
/** Singleton access */
static SourceManager_Ptr sourceManager();
/** Runtime unique numeric Source Id. */
typedef Source_Ref::NumericId SourceId;
+ private:
+ /** exposition only */
+ typedef std::map<SourceId, Source_Ref> SourceMap;
+
+ /** \name Iterate over all (SourceId,Source_Ref) pairs. */
+ //@{
+ typedef SourceMap::const_iterator const_iterator;
+
+ const_iterator begin() const;
+
+ const_iterator end() const;
+ //@}
+
+ public:
+ /** \name Iterate over all known SourceIds. */
+ //@{
+ typedef MapKVIteratorTraits<SourceMap>::Key_const_iterator SourceId_const_iterator;
+
+ SourceId_const_iterator SourceId_begin() const;
+
+ SourceId_const_iterator SourceId_end() const;
+ //@}
+
+ public:
+ /** \name Iterate over all known Sources. */
+ //@{
+ typedef MapKVIteratorTraits<SourceMap>::Value_const_iterator Source_const_iterator;
+
+ Source_const_iterator Source_begin() const;
+
+ Source_const_iterator Source_end() const;
+ //@}
+
public:
/**
* Disable all registered sources
*/
void disableAllSources();
-
+
/**
* Helper function to disable all sources in the persistent
* store on the given location. Does not manipulate with
* \see MapKVIteratorTraits
*/
template<class _Pair>
- struct GetPairFirst : public std::unary_function<_Pair, typename _Pair::first_type>
+ struct GetPairFirst : public std::unary_function<_Pair, const typename _Pair::first_type &>
{
- const typename _Pair::first_type & operator()( const _Pair pair_r ) const
+ const typename _Pair::first_type & operator()( const _Pair & pair_r ) const
{ return pair_r.first; }
};
* \see MapKVIteratorTraits
*/
template<class _Pair>
- struct GetPairSecond : public std::unary_function<_Pair, typename _Pair::second_type>
+ struct GetPairSecond : public std::unary_function<_Pair, const typename _Pair::second_type &>
{
- const typename _Pair::second_type & operator()( const _Pair pair_r ) const
+ const typename _Pair::second_type & operator()( const _Pair & pair_r ) const
{ return pair_r.second; }
};
* typedef std::map<K,V> MapType;
*
* // transform_iterator<GetPairFirst<MapType::value_type>, MapType::const_iterator>
- * typedef MapKVIteratorTraits<MapType>::Key_iterator MapTypeKey_iterator;
+ * typedef MapKVIteratorTraits<MapType>::Key_const_iterator MapTypeKey_iterator;
* // transform_iterator<GetPairSecond<MapType::value_type>, MapType::const_iterator>
- * typedef MapKVIteratorTraits<MapType>::Value_iterator MapTypeValue_iterator;
+ * typedef MapKVIteratorTraits<MapType>::Value_const_iterator MapTypeValue_iterator;
*
* // usage
* MapType mymap;
*
- * MapTypeKey_iterator keyBegin( make_map_key_begin( mymap ) );
- * MapTypeKey_iterator keyEnd ( make_map_key_end( mymap ) );
+ * MapTypeKey_const_iterator keyBegin( make_map_key_begin( mymap ) );
+ * MapTypeKey_const_iterator keyEnd ( make_map_key_end( mymap ) );
*
- * MapTypeKey_iterator valBegin( make_map_value_begin( mymap ) );
- * MapTypeKey_iterator valEnd ( make_map_value_end( mymap ) );
+ * MapTypeKey_const_iterator valBegin( make_map_value_begin( mymap ) );
+ * MapTypeKey_const_iterator valEnd ( make_map_value_end( mymap ) );
*
* std::for_each( keyBegin, keyEnd, DoSomething() );
* std::for_each( valBegin, valEnd, DoSomething() );
typedef typename _Map::key_type KeyType;
/** The key iterator type */
typedef transform_iterator<GetPairFirst<typename MapType::value_type>,
- typename MapType::const_iterator> Key_iterator;
+ typename MapType::const_iterator> Key_const_iterator;
/** The maps value (mapped) type */
typedef typename _Map::mapped_type ValueType;
/** The value iterator type */
typedef transform_iterator<GetPairSecond<typename MapType::value_type>,
- typename MapType::const_iterator> Value_iterator;
+ typename MapType::const_iterator> Value_const_iterator;
};
/** Convenience to create the key iterator from container::begin() */
template<class _Map>
- inline typename MapKVIteratorTraits<_Map>::Key_iterator make_map_key_begin( const _Map & map_r )
+ inline typename MapKVIteratorTraits<_Map>::Key_const_iterator make_map_key_begin( const _Map & map_r )
{ return make_transform_iterator( map_r.begin(), GetPairFirst<typename _Map::value_type>() ); }
/** Convenience to create the key iterator from container::end() */
template<class _Map>
- inline typename MapKVIteratorTraits<_Map>::Key_iterator make_map_key_end( const _Map & map_r )
+ inline typename MapKVIteratorTraits<_Map>::Key_const_iterator make_map_key_end( const _Map & map_r )
{ return make_transform_iterator( map_r.end(), GetPairFirst<typename _Map::value_type>() ); }
/** Convenience to create the value iterator from container::begin() */
template<class _Map>
- inline typename MapKVIteratorTraits<_Map>::Value_iterator make_map_value_begin( const _Map & map_r )
+ inline typename MapKVIteratorTraits<_Map>::Value_const_iterator make_map_value_begin( const _Map & map_r )
{ return make_transform_iterator( map_r.begin(), GetPairSecond<typename _Map::value_type>() ); }
/** Convenience to create the value iterator from container::end() */
template<class _Map>
- inline typename MapKVIteratorTraits<_Map>::Value_iterator make_map_value_end( const _Map & map_r )
+ inline typename MapKVIteratorTraits<_Map>::Value_const_iterator make_map_value_end( const _Map & map_r )
{ return make_transform_iterator( map_r.end(), GetPairSecond<typename _Map::value_type>() ); }
/** \class function_output_iterator