- Collect logical functors and FunctorRef in zypp/base/Functional.h
authorMichael Andres <ma@suse.de>
Tue, 24 Jan 2006 21:51:29 +0000 (21:51 +0000)
committerMichael Andres <ma@suse.de>
Tue, 24 Jan 2006 21:51:29 +0000 (21:51 +0000)
- Common algorithms like invokeOnEach go into zypp/base/Algorithm.h
- New enumeration class of dependency types: class Dep
    static const Dep Dep::PROVIDES;
    static const Dep Dep::PREREQUIRES;
    static const Dep Dep::REQUIRES;
    static const Dep Dep::CONFLICTS;
    static const Dep Dep::OBSOLETES;
    static const Dep Dep::RECOMMENDS;
    static const Dep Dep::SUGGESTS;
    static const Dep Dep::FRESHENS;

12 files changed:
zypp/Dep.cc [new file with mode: 0644]
zypp/Dep.h [new file with mode: 0644]
zypp/Dependencies.h
zypp/Makefile.am
zypp/Rel.cc
zypp/Rel.h
zypp/ResFilters.h
zypp/base/Algorithm.h [new file with mode: 0644]
zypp/base/Functional.h [moved from zypp/base/LogicalFilters.h with 54% similarity]
zypp/base/FunctorRef.h [deleted file]
zypp/base/Iterator.h
zypp/base/Makefile.am

diff --git a/zypp/Dep.cc b/zypp/Dep.cc
new file mode 100644 (file)
index 0000000..44c9ef5
--- /dev/null
@@ -0,0 +1,98 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/Dep.cc
+ *
+*/
+#include <map>
+
+#include "zypp/base/Exception.h"
+#include "zypp/base/String.h"
+
+#include "zypp/Dep.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  namespace
+  {
+
+    std::map<std::string,Dep::for_use_in_switch> _table;
+
+    Dep::for_use_in_switch parse( const std::string & strval_r )
+    {
+      if ( _table.empty() )
+        {
+          // initialize it
+          _table["PROVIDES"]    = Dep::PROVIDES_e;
+          _table["PREREQUIRES"] = Dep::PREREQUIRES_e;
+          _table["REQUIRES"]    = Dep::REQUIRES_e;
+          _table["CONFLICTS"]   = Dep::CONFLICTS_e;
+          _table["OBSOLETES"]   = Dep::OBSOLETES_e;
+          _table["RECOMMENDS"]  = Dep::RECOMMENDS_e;
+          _table["SUGGESTS"]    = Dep::SUGGESTS_e;
+          _table["FRESHENS"]    = Dep::FRESHENS_e;
+        }
+
+      std::map<std::string,Dep::for_use_in_switch>::const_iterator it
+      = _table.find( str::toUpper( strval_r ) );
+      if ( it == _table.end() )
+        {
+          ZYPP_THROW( Exception("Dep parse: illegal string value '"+strval_r+"'") );
+        }
+      return it->second;
+    }
+  }
+
+  ///////////////////////////////////////////////////////////////////
+
+  const Dep Dep::PROVIDES   ( Dep::PROVIDES_e );
+  const Dep Dep::PREREQUIRES( Dep::PREREQUIRES_e );
+  const Dep Dep::REQUIRES   ( Dep::REQUIRES_e );
+  const Dep Dep::CONFLICTS  ( Dep::CONFLICTS_e );
+  const Dep Dep::OBSOLETES  ( Dep::OBSOLETES_e );
+  const Dep Dep::RECOMMENDS ( Dep::RECOMMENDS_e );
+  const Dep Dep::SUGGESTS   ( Dep::SUGGESTS_e );
+  const Dep Dep::FRESHENS   ( Dep::FRESHENS_e );
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Dep::Dep
+  //   METHOD TYPE : Ctor
+  //
+  Dep::Dep( const std::string & strval_r )
+  : _type( parse( strval_r ) )
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Dep::asString
+  //   METHOD TYPE : const std::string &
+  //
+  const std::string & Dep::asString() const
+  {
+    static std::map<for_use_in_switch,std::string> _table;
+    if ( _table.empty() )
+      {
+        // initialize it
+        _table[PROVIDES_e]    = "PROVIDES";
+        _table[PREREQUIRES_e] = "PREREQUIRES";
+        _table[REQUIRES_e]    = "REQUIRES";
+        _table[CONFLICTS_e]   = "CONFLICTS";
+        _table[OBSOLETES_e]   = "OBSOLETES";
+        _table[RECOMMENDS_e]  = "RECOMMENDS";
+        _table[SUGGESTS_e]    = "SUGGESTS";
+        _table[FRESHENS_e]    = "FRESHENS";
+      }
+    return _table[_type];
+  }
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/Dep.h b/zypp/Dep.h
new file mode 100644 (file)
index 0000000..c5c5580
--- /dev/null
@@ -0,0 +1,110 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/Dep.h
+ *
+*/
+#ifndef ZYPP_DEP_H
+#define ZYPP_DEP_H
+
+#include <iosfwd>
+#include <string>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : Dep
+  //
+  /** Enumeration class of dependency types.
+   * \ingroup g_EnumerationClass
+  */
+  struct Dep
+  {
+    friend bool operator==( const Dep & lhs, const Dep & rhs );
+    friend bool operator!=( const Dep & lhs, const Dep & rhs );
+
+    /** \name Dependency types
+     * These are the \em real dependency type contants to
+     * use. Don't mind that it's not an enum.
+     * \see \ref zypp::Dep::inSwitch
+    */
+    //@{
+    static const Dep PROVIDES;
+    static const Dep PREREQUIRES;
+    static const Dep REQUIRES;
+    static const Dep CONFLICTS;
+    static const Dep OBSOLETES;
+    static const Dep RECOMMENDS;
+    static const Dep SUGGESTS;
+    static const Dep FRESHENS;
+    //@}
+
+    /** Enumarators provided \b only for use \ref inSwitch statement.
+     * \see inSwitch
+    */
+    enum for_use_in_switch {
+      PROVIDES_e,
+      PREREQUIRES_e,
+      REQUIRES_e,
+      CONFLICTS_e,
+      OBSOLETES_e,
+      RECOMMENDS_e,
+      SUGGESTS_e,
+      FRESHENS_e,
+    };
+
+    /** Ctor from string.
+     * Legal values for \a strval_r are the constants names
+     * (case insignificant).
+     *
+     * \throw PARSE if \a strval_r is not legal.
+     * \todo refine exceptions and check throw.
+    */
+    explicit
+    Dep( const std::string & strval_r );
+
+    /** String representation of dependency type operator.
+     * \return The constants names.
+    */
+    const std::string & asString() const;
+
+    /** Enumarator provided for use in \c switch statement. */
+    for_use_in_switch inSwitch() const
+    { return _type; }
+
+  private:
+    /** Ctor to initialize the dependency type contants. */
+    Dep( for_use_in_switch type_r )
+    : _type( type_r )
+    {}
+    /** The operator. */
+    for_use_in_switch _type;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates Dep Stream output */
+  inline std::ostream & operator<<( std::ostream & str, const Dep & obj )
+  { return str << obj.asString(); }
+
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates Dep */
+  inline bool operator==( const Dep & lhs, const Dep & rhs )
+  { return lhs._type == rhs._type; }
+
+  /** \relates Dep */
+  inline bool operator!=( const Dep & lhs, const Dep & rhs )
+  { return lhs._type != rhs._type; }
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_DEP_H
index 18149bc..c85f456 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <iosfwd>
 
+#include "zypp/Dep.h"
 #include "zypp/CapSetFwd.h"
 #include "zypp/CapSet.h"
 
index 6dc59a8..36bfd7e 100644 (file)
@@ -17,6 +17,7 @@ pkginclude_HEADERS = NeedAType.h \
        CapSetFwd.h     \
        CountryCode.h   \
        Date.h          \
+       Dep.h           \
        Dependencies.h  \
        Edition.h       \
        LanguageCode.h  \
@@ -78,6 +79,7 @@ lib@PACKAGE@_la_SOURCES = \
        CapSet.cc       \
        CountryCode.cc  \
        Date.cc         \
+       Dep.cc          \
        Dependencies.cc \
        Edition.cc      \
        LanguageCode.cc \
index a9a90c8..8fc86e5 100644 (file)
 
 #include "zypp/Rel.h"
 
-using namespace std;
-
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
-namespace
-{
+  namespace
+  {
 
-  map<string,Rel::for_use_in_switch> _table;
+    std::map<std::string,Rel::for_use_in_switch> _table;
 
-  Rel::for_use_in_switch parse( const std::string & strval_r )
-  {
-    if ( _table.empty() )
-      {
-        // initialize it
-        _table["EQ"] = _table["eq"] = _table["=="] = _table["="] = Rel::EQ_e;
-        _table["NE"] = _table["ne"] = _table["!="] = Rel::NE_e;
-        _table["LT"] = _table["lt"] = _table["<"]  = Rel::LT_e;
-        _table["LE"] = _table["le"] = _table["<="] = Rel::LE_e;
-        _table["GT"] = _table["gt"] = _table[">"]  = Rel::GT_e;
-        _table["GE"] = _table["ge"] = _table[">="] = Rel::GE_e;
-        _table["ANY"]  = _table["any"] = _table["(any)"] = _table[""] = Rel::ANY_e;
-        _table["NONE"] = _table["none"]             = Rel::NONE_e;
-      }
+    Rel::for_use_in_switch parse( const std::string & strval_r )
+    {
+      if ( _table.empty() )
+        {
+          // initialize it
+          _table["EQ"]   = _table["eq"]  = _table["=="]    = _table["="] = Rel::EQ_e;
+          _table["NE"]   = _table["ne"]  = _table["!="]                  = Rel::NE_e;
+          _table["LT"]   = _table["lt"]  = _table["<"]                   = Rel::LT_e;
+          _table["LE"]   = _table["le"]  = _table["<="]                  = Rel::LE_e;
+          _table["GT"]   = _table["gt"]  = _table[">"]                   = Rel::GT_e;
+          _table["GE"]   = _table["ge"]  = _table[">="]                  = Rel::GE_e;
+          _table["ANY"]  = _table["any"] = _table["(any)"] = _table[""]  = Rel::ANY_e;
+          _table["NONE"] = _table["none"]                                = Rel::NONE_e;
+        }
 
-    map<string,Rel::for_use_in_switch>::const_iterator it
+      std::map<std::string,Rel::for_use_in_switch>::const_iterator it
       = _table.find( strval_r );
-    if ( it == _table.end() )
-      {
-        ZYPP_THROW( Exception("Rel parse: illegal string value '"+strval_r+"'") );
-      }
-    return it->second;
+      if ( it == _table.end() )
+        {
+          ZYPP_THROW( Exception("Rel parse: illegal string value '"+strval_r+"'") );
+        }
+      return it->second;
+    }
   }
-}
+
+  ///////////////////////////////////////////////////////////////////
 
   const Rel Rel::EQ( Rel::EQ_e );
   const Rel Rel::NE( Rel::NE_e );
@@ -76,7 +76,7 @@ namespace
   //
   const std::string & Rel::asString() const
   {
-    static map<for_use_in_switch,string> _table;
+    static std::map<for_use_in_switch,std::string> _table;
     if ( _table.empty() )
       {
         // initialize it
index 0b07bc1..91d3844 100644 (file)
@@ -42,6 +42,9 @@ namespace zypp
   */
   struct Rel
   {
+    friend bool operator==( const Rel & lhs, const Rel & rhs );
+    friend bool operator!=( const Rel & lhs, const Rel & rhs );
+
     /** \name Relational operators
      * These are the \em real relational operator contants to
      * use. Don't mind that it's not an enum. See also: \ref zypp::Rel::inSwitch
@@ -114,13 +117,6 @@ namespace zypp
     {}
     /** The operator. */
     for_use_in_switch _op;
-
-    friend bool operator==( const Rel & lhs, const Rel & rhs )
-    { return lhs._op == rhs._op; }
-
-    friend bool operator!=( const Rel & lhs, const Rel & rhs )
-    { return lhs._op != rhs._op; }
-
   };
   ///////////////////////////////////////////////////////////////////
 
@@ -128,6 +124,16 @@ namespace zypp
   inline std::ostream & operator<<( std::ostream & str, const Rel & obj )
   { return str << obj.asString(); }
 
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates Rel */
+  inline bool operator==( const Rel & lhs, const Rel & rhs )
+  { return lhs._op == rhs._op; }
+
+  /** \relates Rel */
+  inline bool operator!=( const Rel & lhs, const Rel & rhs )
+  { return lhs._op != rhs._op; }
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index 96d2b18..f9c8029 100644 (file)
 #ifndef ZYPP_RESFILTERS_H
 #define ZYPP_RESFILTERS_H
 
-#include <functional>
-
-#include "zypp/base/FunctorRef.h"
-#include "zypp/base/LogicalFilters.h"
+#include "zypp/base/Functional.h"
 #include "zypp/Resolvable.h"
 
 ///////////////////////////////////////////////////////////////////
@@ -137,60 +134,6 @@ namespace zypp
     //@{
     ///////////////////////////////////////////////////////////////////
     //
-    // Some tool funktions.
-    //
-    ///////////////////////////////////////////////////////////////////
-
-    /** Iterate through <tt>[begin_r,end_r)</tt> and invoke \a fnc_r
-     *  on each item that passes \filter_r.
-     *
-     * Iteration aborts if \a fnc_r returns \c false.
-     *
-     * \return Number of invokations of \a fnc_r, negative if
-     * loop was aborted by \a fnc_.
-    */
-    template <class _Iterator, class _Filter, class _Function>
-      inline int invokeOnEach( _Iterator begin_r, _Iterator end_r,
-                               _Filter filter_r,
-                               _Function fnc_r )
-      {
-        int cnt = 0;
-        for ( _Iterator it = begin_r; it != end_r; ++it )
-          {
-            if ( filter_r( *it ) )
-              {
-                ++cnt;
-                if ( ! fnc_r( *it ) )
-                  return -cnt;
-              }
-          }
-        return cnt;
-      }
-
-    /** Iterate through <tt>[begin_r,end_r)</tt> and invoke \a fnc_r
-     *  on each item.
-     *
-     * Iteration aborts if \a fnc_r returns \c false.
-     *
-     * \return Number of invokations of \a fnc_r, negative if
-     * loop was aborted by \a fnc_.
-    */
-    template <class _Iterator, class _Function>
-      inline int invokeOnEach( _Iterator begin_r, _Iterator end_r,
-                               _Function fnc_r )
-      {
-        int cnt = 0;
-        for ( _Iterator it = begin_r; it != end_r; ++it )
-          {
-            ++cnt;
-            if ( ! fnc_r( *it ) )
-              return -cnt;
-          }
-        return cnt;
-      }
-
-    ///////////////////////////////////////////////////////////////////
-    //
     // Some ResObject attributes
     //
     ///////////////////////////////////////////////////////////////////
diff --git a/zypp/base/Algorithm.h b/zypp/base/Algorithm.h
new file mode 100644 (file)
index 0000000..79e6f29
--- /dev/null
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/Algorithm.h
+ *
+*/
+#ifndef ZYPP_BASE_ALGORITHM_H
+#define ZYPP_BASE_ALGORITHM_H
+
+#include <algorithm>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  /** Iterate through <tt>[begin_r,end_r)</tt> and invoke \a fnc_r
+   *  on each item that passes \filter_r.
+   *
+   * Iteration aborts if \a fnc_r returns \c false.
+   *
+   * \return Number of invokations of \a fnc_r, negative if
+   * loop was aborted by \a fnc_.
+  */
+  template <class _Iterator, class _Filter, class _Function>
+    inline int invokeOnEach( _Iterator begin_r, _Iterator end_r,
+                             _Filter filter_r,
+                             _Function fnc_r )
+    {
+      int cnt = 0;
+      for ( _Iterator it = begin_r; it != end_r; ++it )
+        {
+          if ( filter_r( *it ) )
+            {
+              ++cnt;
+              if ( ! fnc_r( *it ) )
+                  return -cnt;
+            }
+        }
+      return cnt;
+    }
+
+  /** Iterate through <tt>[begin_r,end_r)</tt> and invoke \a fnc_r
+   *  on each item.
+   *
+   * Iteration aborts if \a fnc_r returns \c false.
+   *
+   * \return Number of invokations of \a fnc_r, negative if
+   * loop was aborted by \a fnc_.
+  */
+  template <class _Iterator, class _Function>
+    inline int invokeOnEach( _Iterator begin_r, _Iterator end_r,
+                             _Function fnc_r )
+    {
+      int cnt = 0;
+      for ( _Iterator it = begin_r; it != end_r; ++it )
+        {
+          ++cnt;
+          if ( ! fnc_r( *it ) )
+            return -cnt;
+        }
+      return cnt;
+    }
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_ALGORITHM_H
similarity index 54%
rename from zypp/base/LogicalFilters.h
rename to zypp/base/Functional.h
index 5e8d0c5..3728c7c 100644 (file)
@@ -6,11 +6,11 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file      zypp/base/LogicalFilters.h
+/** \file      zypp/base/Functional.h
  *
 */
-#ifndef ZYPP_BASE_LOGICALFILTERS_H
-#define ZYPP_BASE_LOGICALFILTERS_H
+#ifndef ZYPP_BASE_FUNCTIONAL_H
+#define ZYPP_BASE_FUNCTIONAL_H
 
 #include <functional>
 
@@ -21,18 +21,99 @@ namespace zypp
   namespace functor
   { /////////////////////////////////////////////////////////////////
 
-    /** \defgroup LOGICALFILTERS Filter functors for building compex queries.
+    /** An unary functor forwarding to some other <tt>_Functor &</tt>.
+     * \ingroup g_Functor
+     *
+     * Most algorithms take functor arguments by value. That's inconvenient
+     * if the functor wants to collect and return data. Creating and
+     * passing a \ref FunctorRef to the algorithm, may help you out of this.
+     *
+     * \code
+     *   // Counts invokations of operator().
+     *   template<class _Tp>
+     *     struct Counter : public std::unary_function<_Tp, void>
+     *     {
+     *       void operator()( _Tp )
+     *       { ++_value; }
+     *
+     *       Counter() : _value( 0 ) {}
+     *
+     *       unsigned _value;
+     *     };
+     *
+     *   std::set<SomeType> c;
+     *   Counter<SomeType> counter;
+     *   // Invokations of FunctorRef are forwarded to counter:
+     *   std::for_each( c.begin, c.end(), functorRef(counter) );
+     * \endcode
+     *
+     * \note FunctorRef must be able to deduce the signature of \c _Functor::operator().
+     * Per default the tyedefs  \c _Functor::argument_type and \c _Functor::result_type
+     * are expected. They are e.g. provided by deriving your \c _Functor from
+     * \c std::unary_function. In case these typedefs are not provided, you have to
+     * specify them as additional template arguments:
+     *
+     * \code
+     *   // Counts invokations of operator().
+     *     struct Counter
+     *     {
+     *       template<class _Tp>
+     *         void operator()( _Tp )
+     *         { ++_value; }
+     *
+     *       Counter() : _value( 0 ) {}
+     *
+     *       unsigned _value;
+     *     };
+     *
+     *   std::set<SomeType> c;
+     *   Counter counter;
+     *   // Invokations of FunctorRef are forwarded to counter:
+     *   std::for_each( c.begin, c.end(),
+     *                  functorRef<Counter, SomeType, void>(counter) );
+     * \endcode
+    */
+    template <class _Functor, class argument_type = typename _Functor::argument_type,
+                              class result_type = typename _Functor::result_type>
+      class FunctorRef : public std::unary_function<argument_type, result_type>
+      {
+      public:
+        FunctorRef( _Functor & f_r )
+        : _f( f_r )
+        {}
+
+        typename FunctorRef::result_type operator()( typename FunctorRef::argument_type a1 ) const
+        {
+          return _f( a1 );
+        }
+
+      private:
+        _Functor & _f;
+      };
+
+    /** Convenience function creating a \ref FunctorRef. */
+    template <class _Functor>
+      FunctorRef<_Functor> functorRef( _Functor & f_r )
+      { return FunctorRef<_Functor>( f_r ); }
+
+    /** Convenience function creating a \ref FunctorRef. */
+    template <class _Functor, class argument_type, class result_type>
+      FunctorRef<_Functor,argument_type,result_type> functorRef( _Functor & f_r )
+      { return FunctorRef<_Functor,argument_type,result_type>( f_r ); }
+
+    /////////////////////////////////////////////////////////////////
+
+    /** \defgroup LOGICALFILTERS Functors for building compex queries.
      * \ingroup g_Functor
      *
      * Some logical functors to build more complex queries:
      *
      * \li \ref True and \ref False. No supprise, they always return
      *     \c true or \c false.
-     * \li \ref Not\<_Condition\>. _Condition is a filter functor, and
+     * \li \ref Not\<_Condition\>. _Condition is a functor, and
      *     it's result is inverted.
      * \li \ref Chain\<_ACondition,_BCondition\>. \c _ACondition and \c _BCondition
-     *     are filter functors, and Chain evaluates
-     *     <tt>_ACondition && _BCondition</tt>
+     *     are functors, and Chain evaluates <tt>_ACondition && _BCondition</tt>.
      *
      * As it's no fun to get and write the correct template arguments,
      * convenience functions creating the correct functor are provided.
@@ -52,9 +133,9 @@ namespace zypp
      * \endcode
     */
     //@{
-    ///////////////////////////////////////////////////////////////////
 
-    /** Logical filter always \c true. */
+    /** Logical functor always \c true.
+    */
     struct True
     {
       template<class _Tp>
@@ -68,9 +149,8 @@ namespace zypp
     inline True true_c()
     { return True(); }
 
-    ///////////////////////////////////////////////////////////////////
-
-    /** Logical filter always \c false. */
+    /** Logical functor always \c false.
+    */
     struct False
     {
       template<class _Tp>
@@ -84,9 +164,8 @@ namespace zypp
     inline False false_c()
     { return False(); }
 
-    ///////////////////////////////////////////////////////////////////
-
-    /** Logical filter inverting \a _Condition. */
+    /** Logical functor inverting \a _Condition.
+    */
     template<class _Condition>
       struct Not
       {
@@ -110,9 +189,8 @@ namespace zypp
         return Not<_Condition>( cond_r );
       }
 
-    ///////////////////////////////////////////////////////////////////
-
-    /** Logical filter chaining \a _ACondition \c AND \a _BCondition. */
+    /** Logical functor chaining \a _ACondition \c AND \a _BCondition.
+    */
     template<class _ACondition, class _BCondition>
       struct Chain
       {
@@ -140,13 +218,13 @@ namespace zypp
         return Chain<_ACondition, _BCondition>( conda_r, condb_r );
       }
 
+    //@}
     ///////////////////////////////////////////////////////////////////
 
-    //@}
     /////////////////////////////////////////////////////////////////
   } // namespace functor
   ///////////////////////////////////////////////////////////////////
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_LOGICALFILTERS_H
+#endif // ZYPP_BASE_FUNCTIONAL_H
diff --git a/zypp/base/FunctorRef.h b/zypp/base/FunctorRef.h
deleted file mode 100644 (file)
index 4e0addf..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/base/FunctorRef.h
- *
-*/
-#ifndef ZYPP_BASE_FUNCTORREF_H
-#define ZYPP_BASE_FUNCTORREF_H
-
-#include <functional>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
-  namespace functor
-  { /////////////////////////////////////////////////////////////////
-
-    /** An unary functor forwarding to some other <tt>_Functor &</tt>.
-     * \ingroup g_Functor
-     *
-     * Most algorithms take functor arguments by value. That's inconvenient
-     * if the functor wants to collect and return data. Creating and
-     * passing a \ref FunctorRef to the algorithm, may help you out of this.
-     *
-     * \code
-     *   // Counts invokations of operator().
-     *   template<class _Tp>
-     *     struct Counter : public std::unary_function<_Tp, void>
-     *     {
-     *       void operator()( _Tp )
-     *       { ++_value; }
-     *
-     *       Counter() : _value( 0 ) {}
-     *
-     *       unsigned _value;
-     *     };
-     *
-     *   std::set<SomeType> c;
-     *   Counter<SomeType> counter;
-     *   // Invokations of FunctorRef are forwarded to counter:
-     *   std::for_each( c.begin, c.end(), functorRef(counter) );
-     * \endcode
-     *
-     * \note FunctorRef must be able to deduce the signature of \c _Functor::operator().
-     * Per default the tyedefs  \c _Functor::argument_type and \c _Functor::result_type
-     * are expected. They are e.g. provided by deriving your \c _Functor from
-     * \c std::unary_function. In case these typedefs are not provided, you have to
-     * specify them as additional template arguments:
-     *
-     * \code
-     *   // Counts invokations of operator().
-     *     struct Counter
-     *     {
-     *       template<class _Tp>
-     *         void operator()( _Tp )
-     *         { ++_value; }
-     *
-     *       Counter() : _value( 0 ) {}
-     *
-     *       unsigned _value;
-     *     };
-     *
-     *   std::set<SomeType> c;
-     *   Counter counter;
-     *   // Invokations of FunctorRef are forwarded to counter:
-     *   std::for_each( c.begin, c.end(),
-     *                  functorRef<Counter, SomeType, void>(counter) );
-     * \endcode
-    */
-    template <class _Functor, class argument_type = typename _Functor::argument_type,
-                              class result_type = typename _Functor::result_type>
-      class FunctorRef : public std::unary_function<argument_type, result_type>
-      {
-      public:
-        FunctorRef( _Functor & f_r )
-        : _f( f_r )
-        {}
-
-        typename FunctorRef::result_type operator()( typename FunctorRef::argument_type a1 ) const
-        {
-          return _f( a1 );
-        }
-
-      private:
-        _Functor & _f;
-      };
-
-    /** Convenience function creating a \ref FunctorRef. */
-    template <class _Functor>
-      FunctorRef<_Functor> functorRef( _Functor & f_r )
-      { return FunctorRef<_Functor>( f_r ); }
-
-    /** Convenience function creating a \ref FunctorRef. */
-    template <class _Functor, class argument_type, class result_type>
-      FunctorRef<_Functor,argument_type,result_type> functorRef( _Functor & f_r )
-      { return FunctorRef<_Functor,argument_type,result_type>( f_r ); }
-
-  /////////////////////////////////////////////////////////////////
-} // namespace functor
-  ///////////////////////////////////////////////////////////////////
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_FUNCTORREF_H
index 45a6e4f..d247864 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef ZYPP_BASE_ITERATOR_H
 #define ZYPP_BASE_ITERATOR_H
 
+#include <iterator>
+
 #include <boost/iterator/filter_iterator.hpp>
 #include <boost/iterator/transform_iterator.hpp>
 #include <boost/function_output_iterator.hpp>
index 36b15e3..264a2fb 100644 (file)
@@ -9,13 +9,17 @@ baseincludedir = $(pkgincludedir)/base
 
 baseinclude_HEADERS =  \
        Debug.h         \
+       \
+       Algorithm.h     \
+       Exception.h     \
+       Functional.h    \
+       Iterator.h      \
+       Logger.h        \
+       \
        Fd.h            \
        KindOf.h        \
-       Logger.h        \
-       Exception.h     \
        Gettext.h       \
        IOStream.h      \
-       Iterator.h      \
        NonCopyable.h   \
        PtrTypes.h      \
        ReferenceCounted.h      \