Author: mlandres
Date: Tue Feb 19 16:08:17 2008
New Revision: 8813
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8813&view=rev
Log:
added Collector: functor writing elements to an output iterator.
Added:
trunk/libzypp/zypp/base/Collector.h
Modified:
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/base/Functional.h
trunk/libzypp/zypp/base/Iterator.h
trunk/libzypp/zypp/sat/Pool.h
trunk/libzypp/zypp/sat/Solvable.cc
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=8813&r1=8812&r2=8813&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Tue Feb 19 16:08:17 2008
@@ -205,6 +205,7 @@
)
SET( zypp_base_HEADERS
+ base/Collector.h
base/SerialNumber.h
base/Easy.h
base/Random.h
Added: trunk/libzypp/zypp/base/Collector.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Collector.h?rev=8813&view=auto
==============================================================================
--- trunk/libzypp/zypp/base/Collector.h (added)
+++ trunk/libzypp/zypp/base/Collector.h Tue Feb 19 16:08:17 2008
@@ -0,0 +1,66 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/Collector.h
+ *
+*/
+#ifndef ZYPP_BASE_COLLECTOR_H
+#define ZYPP_BASE_COLLECTOR_H
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace functor
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : _Collector<_OutputIterator>
+ //
+ /** Functor feeding values to an output_iterator.
+ *
+ * \code
+ * LocaleSet locales;
+ * for_each( begin(), end(),
+ * Collector( std::inserter( locales_r, locales_r.begin() ) ) );
+ * \endcode
+ *
+ * \see Convenience constructor \ref Collector.
+ */
+ template<class _OutputIterator>
+ struct _Collector
+ {
+ _Collector( _OutputIterator iter_r ) : _iter( iter_r ) {}
+
+ template<class _Tp>
+ bool operator()( const _Tp & value_r ) const
+ {
+ *_iter++ = value_r;
+ return true;
+ }
+
+ private:
+ mutable _OutputIterator _iter;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates _Collector Convenience constructor. */
+ template<class _OutputIterator>
+ inline _Collector<_OutputIterator> Collector( _OutputIterator iter_r )
+ { return _Collector<_OutputIterator>( iter_r ); }
+
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+} // namespace functor
+///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_COLLECTOR_H
Modified: trunk/libzypp/zypp/base/Functional.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Functional.h?rev=8813&r1=8812&r2=8813&view=diff
==============================================================================
--- trunk/libzypp/zypp/base/Functional.h (original)
+++ trunk/libzypp/zypp/base/Functional.h Tue Feb 19 16:08:17 2008
@@ -12,9 +12,10 @@
#ifndef ZYPP_BASE_FUNCTIONAL_H
#define ZYPP_BASE_FUNCTIONAL_H
-//#include <functional>
#include