- Added template class base::KindOf<Type>
authorMichael Andres <ma@suse.de>
Mon, 21 Nov 2005 00:05:57 +0000 (00:05 +0000)
committerMichael Andres <ma@suse.de>
Mon, 21 Nov 2005 00:05:57 +0000 (00:05 +0000)
Currently string based representation of a Kind. Used as
Resolvable::Kind (package, patch, etc.), Capability::Kind
(named, versioned, conditional etc.; toto) and other kinds.

- Removed ResKind; A Resolvables Kind is now defined by
ResTraits<Resolvable>::KindType. Resolvable provides it as
Resolvable::Kind. Implemented as base::KindOf<Resolvable>.
(simply use Resolvable::Kind where you would have used ResKind)

35 files changed:
devel/devel.ma/Main.cc
devel/devel.ma/Makefile.am
devel/devel.ma/ma_test
zypp/CapFactory.cc
zypp/CapFactory.h
zypp/Capability.cc
zypp/Capability.h
zypp/Makefile.am
zypp/Message.cc
zypp/Message.h
zypp/Package.cc
zypp/Package.h
zypp/Patch.cc
zypp/Patch.h
zypp/Product.cc
zypp/Product.h
zypp/ResKind.cc [deleted file]
zypp/ResKind.h [deleted file]
zypp/ResObject.cc
zypp/ResObject.h
zypp/ResTraits.cc
zypp/ResTraits.h
zypp/Resolvable.cc
zypp/Resolvable.h
zypp/Script.cc
zypp/Script.h
zypp/Selection.cc
zypp/Selection.h
zypp/base/KindOf.h [new file with mode: 0644]
zypp/base/Makefile.am
zypp/capability/CapabilityImpl.cc
zypp/capability/CapabilityImpl.h
zypp/capability/NamedCap.h
zypp/detail/ResObjectFactory.h
zypp/detail/ResolvableImpl.h

index 2c7351f..d5cb1c1 100644 (file)
@@ -3,8 +3,8 @@
 #include <functional>
 #include <algorithm>
 #include <zypp/base/Logger.h>
-#include <zypp/Message.h>
 #include <zypp/Package.h>
+#include <zypp/detail/PackageImpl.h>
 
 #define TAG INT << __PRETTY_FUNCTION__ << std::endl
 
@@ -18,6 +18,7 @@ inline void OUT( zypp::Resolvable::constPtr p )
     MIL << "NULL" << endl;
 }
 
+#if 0
 struct PI : public zypp::detail::MessageImplIf
 {
   virtual std::string text() const { return "message text"; }
@@ -34,8 +35,23 @@ template<class _Impl>
                                                 zypp::Arch(),
                                                 impl_r );
   }
+{
+  zypp::base::shared_ptr<PI> pi;
+  OUT( makeResolvable( pi ) );
+}
+#endif
 
+template<class _Impl>
+  typename _Impl::ResType::Ptr
+  makeResolvable( zypp::base::shared_ptr<_Impl> & impl_r )
+  {
+    return zypp::detail::makeResolvableAndImpl( "n",
+                                                zypp::Edition("v","r"),
+                                                zypp::Arch(),
+                                                impl_r );
+  }
 
+using namespace zypp;
 /******************************************************************
 **
 **
@@ -48,21 +64,9 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  zypp::base::shared_ptr<PI> pi;
+  base::shared_ptr<detail::PackageImpl> pi;
   OUT( makeResolvable( pi ) );
 
-
-
-#if 0
-  /* NVRA */
-  zypp::base::shared_ptr<PI> pi;
-  Package::Ptr p( makeResolvable( /*NVRA*/ pi ) );
-  OUT( p );
-
-  p = makeResolvable( /*NVRA*/ pi );
-  OUT( p );
-#endif
-
   INT << "===[END]============================================" << endl;
   return 0;
 }
index 45abf23..a889df7 100644 (file)
@@ -9,7 +9,8 @@ INCLUDES =
 
 AM_LDFLAGS =
 
-AM_CXXFLAGS =  -pg
+AM_CXXFLAGS =
+# gperf:       -pg
 
 LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la
 
index 021e155..fc44c2f 100755 (executable)
@@ -24,9 +24,9 @@ if ! fuser $LPIPE >/dev/null; then
 fi
 
 if ps axl | grep -q '[/]usr/sbin/iceczc'; then
-       MAKE=make
-else
        MAKE="make -j 15"
+else
+       MAKE=make
 fi
 
 $MAKE -C ../../zypp || exit 1
index 57d9df5..4bd6052 100644 (file)
@@ -123,7 +123,7 @@ namespace zypp
   //
   Capability CapFactory::parse( const std::string & strval_r ) const
   {
-    return parse( strval_r, ResKind() );
+    return parse( strval_r, Resolvable::Kind() );
   }
 
   ///////////////////////////////////////////////////////////////////
@@ -132,12 +132,14 @@ namespace zypp
   //   METHOD TYPE : Capability
   //
   /** \todo fix it */
-  Capability CapFactory::parse( const std::string & strval_r, const ResKind & defaultRefers_r ) const
+  Capability CapFactory::parse( const std::string & strval_r,
+                                const Resolvable::Kind & defaultRefers_r ) const
   {
-    // (defaultRefers_r==ResKind()) ==> throw on missing ResKind in strval
-    // fix
+    // (defaultRefers_r==Resolvable::Kind()) ==> throw on
+    // missing Resolvable::Kind in strval
+    // fix it!
     if ( strval_r.empty() )
-      throw "no ResKind";
+      throw "no Resolvable::Kind";
     CapabilityImplPtr newcap( new capability::NamedCap( defaultRefers_r, strval_r ) );
     USet::iterator in( _uset.insert( newcap ).first );
     return Capability( *in );
index a4684ea..893b0d2 100644 (file)
@@ -48,18 +48,18 @@ namespace zypp
     ~CapFactory();
 
   public:
-    /** Parse Capability from string (incl. ResKind).
+    /** Parse Capability from string (incl. Resolvable::Kind).
      * \c strval_r is expected to define a valid Capability \em including
-     * the ResKind.
+     * the Resolvable::Kind.
      * \throw EXCEPTION on parse error.
     */
     Capability parse( const std::string & strval_r ) const;
-    /** Parse Capability from string (default ResKind).
+    /** Parse Capability from string (default Resolvable::Kind).
      * \c strval_r is expected to define a valid Capability. If it does
-     * not define the ResKind, \c defaultRefers_r is used instead.
+     * not define the Resolvable::Kind, \c defaultRefers_r is used instead.
      * \throw EXCEPTION on parse error.
     */
-    Capability parse( const std::string & strval_r, const ResKind & defaultRefers_r ) const;
+    Capability parse( const std::string & strval_r, const Resolvable::Kind & defaultRefers_r ) const;
 
   private:
     /** Pointer to implementation */
index 2813488..90f91a1 100644 (file)
@@ -47,7 +47,7 @@ namespace zypp
   Capability::constImplPtr Capability::sayFriend() const
   { return _pimpl; }
 
-  const ResKind & Capability::refers() const
+  const Resolvable::Kind & Capability::refers() const
   { return _pimpl->refers(); }
 
   std::string Capability::asString() const
index 8d1f92e..3c56efd 100644 (file)
@@ -62,7 +62,7 @@ namespace zypp
 
   public:
     /**  */
-    const ResKind & refers() const;
+    const Resolvable::Kind & refers() const;
     /**  */
     std::string asString() const;
     /**  */
index 8ae9cfa..8e6bffb 100644 (file)
@@ -12,7 +12,6 @@ include_HEADERS = \
        CapSet.h        \
        Dependencies.h  \
        Edition.h       \
-       ResKind.h       \
        ResObject.h     \
        Resolvable.h    \
        ResTraits.h     \
@@ -37,7 +36,6 @@ lib@PACKAGE@_la_SOURCES = \
        CapSet.cc       \
        Dependencies.cc \
        Edition.cc      \
-       ResKind.cc      \
        ResObject.cc    \
        Resolvable.cc   \
        ResTraits.cc    \
index c9aec36..55b92f5 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   Message::Message( const std::string & name_r,
                     const Edition & edition_r,
                     const Arch & arch_r )
-  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
+  : ResObject( TraitsType::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index b0cf9d6..231acf8 100644 (file)
@@ -28,10 +28,11 @@ namespace zypp
   class Message : public ResObject
   {
   public:
-    typedef Message                         Self;
     typedef detail::MessageImplIf           Impl;
-    typedef base::intrusive_ptr<Self>       Ptr;
-    typedef base::intrusive_ptr<const Self> constPtr;
+    typedef Message                         Self;
+    typedef ResTraits<Self>          TraitsType;
+    typedef TraitsType::PtrType      Ptr;
+    typedef TraitsType::constPtrType constPtr;
 
   public:
     /** Get the text of the message */
index 1d298db..eba3352 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   Package::Package( const std::string & name_r,
                     const Edition & edition_r,
                     const Arch & arch_r )
-  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
+  : ResObject( TraitsType::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index ff48aa9..abc689b 100644 (file)
@@ -28,10 +28,11 @@ namespace zypp
   class Package : public ResObject
   {
   public:
-    typedef Package                         Self;
-    typedef detail::PackageImplIf           Impl;
-    typedef base::intrusive_ptr<Self>       Ptr;
-    typedef base::intrusive_ptr<const Self> constPtr;
+    typedef detail::PackageImplIf    Impl;
+    typedef Package                  Self;
+    typedef ResTraits<Self>          TraitsType;
+    typedef TraitsType::PtrType      Ptr;
+    typedef TraitsType::constPtrType constPtr;
 
   public:
     /** */
index 71cc2e2..b411871 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   Patch::Patch( const std::string & name_r,
                 const Edition & edition_r,
                 const Arch & arch_r )
-  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
+  : ResObject( TraitsType::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 19ea0e2..40d25f0 100644 (file)
@@ -30,10 +30,11 @@ namespace zypp
   class Patch : public ResObject
   {
   public:
-    typedef Patch                           Self;
-    typedef detail::PatchImplIf             Impl;
-    typedef base::intrusive_ptr<Self>       Ptr;
-    typedef base::intrusive_ptr<const Self> constPtr;
+    typedef detail::PatchImplIf      Impl;
+    typedef Patch                    Self;
+    typedef ResTraits<Self>          TraitsType;
+    typedef TraitsType::PtrType      Ptr;
+    typedef TraitsType::constPtrType constPtr;
 
   public:
     typedef Impl::AtomList AtomList;
index 8cb18d2..31860be 100644 (file)
@@ -27,7 +27,7 @@ namespace zypp
   Product::Product( const std::string & name_r,
                     const Edition & edition_r,
                     const Arch & arch_r )
-  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
+  : ResObject( TraitsType::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 72c0ef5..93d73e0 100644 (file)
@@ -28,10 +28,11 @@ namespace zypp
   class Product : public ResObject
   {
   public:
-    typedef Product                         Self;
-    typedef detail::ProductImplIf           Impl;
-    typedef base::intrusive_ptr<Self>       Ptr;
-    typedef base::intrusive_ptr<const Self> constPtr;
+    typedef detail::ProductImplIf    Impl;
+    typedef Product                  Self;
+    typedef ResTraits<Self>          TraitsType;
+    typedef TraitsType::PtrType      Ptr;
+    typedef TraitsType::constPtrType constPtr;
 
   public:
     /** Get the product categoty (base, add-on) */
diff --git a/zypp/ResKind.cc b/zypp/ResKind.cc
deleted file mode 100644 (file)
index ea52751..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/ResKind.cc
- *
-*/
-#include <iostream>
-
-#include "zypp/ResKind.h"
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   METHOD NAME : ResKind::ResKind
-  //   METHOD TYPE : Ctor
-  //
-  ResKind::ResKind()
-  {}
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   METHOD NAME : ResKind::ResKind
-  //   METHOD TYPE : Ctor
-  //
-  ResKind::ResKind( const std::string & rhs )
-  : base::StringVal( rhs )
-  {}
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   METHOD NAME : ResKind::ResKind
-  //   METHOD TYPE : Ctor
-  //
-  ResKind::ResKind( const ResKind & rhs )
-  : base::StringVal( rhs )
-  {}
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   METHOD NAME : ResKind::~ResKind
-  //   METHOD TYPE : Dtor
-  //
-  ResKind::~ResKind()
-  {}
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
diff --git a/zypp/ResKind.h b/zypp/ResKind.h
deleted file mode 100644 (file)
index 222f866..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/ResKind.h
- *
-*/
-#ifndef ZYPP_RESKIND_H
-#define ZYPP_RESKIND_H
-
-#include <iosfwd>
-
-#include "zypp/base/StringVal.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : ResKind
-  //
-  /** */
-  class ResKind : public base::StringVal
-  {
-  public:
-    /** Default ctor */
-    ResKind();
-    /** */
-    explicit
-    ResKind( const std::string & rhs );
-    /** */
-    ResKind( const ResKind & rhs );
-    /** Dtor */
-    ~ResKind();
-  };
-  ///////////////////////////////////////////////////////////////////
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_RESKIND_H
index 947ee2a..8970a45 100644 (file)
@@ -22,7 +22,7 @@ namespace zypp
   //   METHOD NAME : ResObject::ResObject
   //   METHOD TYPE : Ctor
   //
-  ResObject::ResObject( const ResKind & kind_r,
+  ResObject::ResObject( const Kind & kind_r,
                         const std::string & name_r,
                         const Edition & edition_r,
                         const Arch & arch_r )
index d8ab863..6c7face 100644 (file)
@@ -28,10 +28,11 @@ namespace zypp
   class ResObject : public Resolvable
   {
   public:
-    typedef ResObject                       Self;
-    typedef detail::ResObjectImplIf         Impl;
-    typedef base::intrusive_ptr<Self>       Ptr;
-    typedef base::intrusive_ptr<const Self> constPtr;
+    typedef detail::ResObjectImplIf  Impl;
+    typedef ResObject                Self;
+    typedef ResTraits<Self>          TraitsType;
+    typedef TraitsType::PtrType      Ptr;
+    typedef TraitsType::constPtrType constPtr;
 
   public:
     /** */
@@ -41,7 +42,7 @@ namespace zypp
 
   protected:
     /** Ctor */
-    ResObject( const ResKind & kind_r,
+    ResObject( const Kind & kind_r,
                const std::string & name_r,
                const Edition & edition_r,
                const Arch & arch_r );
index bd2fc9e..edfb3f0 100644 (file)
 */
 
 #include "zypp/ResTraits.h"
-#include "zypp/ResKind.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
-  const ResKind ResTraits<Package>  ::_kind( "Package" );
-  const ResKind ResTraits<Selection>::_kind( "Selection" );
-  const ResKind ResTraits<Product>  ::_kind( "Product" );
-  const ResKind ResTraits<Patch>    ::_kind( "Patch" );
-  const ResKind ResTraits<Script>   ::_kind( "Script" );
-  const ResKind ResTraits<Message>  ::_kind( "Message" );
+  const ResolvableTraits::KindType ResTraits<Package>  ::_kind( "Package" );
+  const ResolvableTraits::KindType ResTraits<Selection>::_kind( "Selection" );
+  const ResolvableTraits::KindType ResTraits<Product>  ::_kind( "Product" );
+  const ResolvableTraits::KindType ResTraits<Patch>    ::_kind( "Patch" );
+  const ResolvableTraits::KindType ResTraits<Script>   ::_kind( "Script" );
+  const ResolvableTraits::KindType ResTraits<Message>  ::_kind( "Message" );
 
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
index 4590672..e26c3b7 100644 (file)
 #ifndef ZYPP_RESTRAITS_H
 #define ZYPP_RESTRAITS_H
 
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/KindOf.h"
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
-  class ResKind;
-
-  template<typename _Res>
-    class ResTraits {};
+  class Resolvable;
+  class ResObject;
 
   class Package;
-  template<>
-    class ResTraits<Package>
-    {
-    public:
-      static const ResKind _kind;
-    };
-
   class Selection;
-  template<>
-    class ResTraits<Selection>
-    {
-    public:
-      static const ResKind _kind;
-    };
-
   class Product;
-  template<>
-    class ResTraits<Product>
-    {
-    public:
-      static const ResKind _kind;
-    };
-
   class Patch;
-  template<>
-    class ResTraits<Patch>
+  class Script;
+  class Message;
+
+  /** Base of ResTraits. Defines the Resolvable::Kind type. */
+  struct ResolvableTraits
+  {
+    typedef base::KindOf<Resolvable>  KindType;
+  };
+
+  /** ResTraits. Defines common types and the Kind value. */
+  template<typename _Res>
+    struct ResTraits : public ResolvableTraits
     {
-    public:
-      static const ResKind _kind;
+      typedef base::intrusive_ptr<_Res>       PtrType;
+      typedef base::intrusive_ptr<const _Res> constPtrType;
+
+      static const KindType _kind;
     };
 
-  class Script;
+  /** ResTraits specialisation for Resolvable.
+   * Resolvable is common base and has no Kind value.
+  */
   template<>
-    class ResTraits<Script>
+    struct ResTraits<Resolvable> : public ResolvableTraits
     {
-    public:
-      static const ResKind _kind;
+      typedef base::intrusive_ptr<Resolvable>       PtrType;
+      typedef base::intrusive_ptr<const Resolvable> constPtrType;
     };
 
-  class Message;
+  /** ResTraits specialisation for ResObject.
+   * ResObject is common base and has no Kind value.
+  */
   template<>
-    class ResTraits<Message>
+    struct ResTraits<ResObject> : public ResolvableTraits
     {
-    public:
-      static const ResKind _kind;
+      typedef base::intrusive_ptr<Resolvable>       PtrType;
+      typedef base::intrusive_ptr<const Resolvable> constPtrType;
     };
 
   /////////////////////////////////////////////////////////////////
index 549b9be..113f648 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   //   METHOD NAME : Resolvable::Resolvable
   //   METHOD TYPE : Ctor
   //
-  Resolvable::Resolvable( const ResKind & kind_r,
+  Resolvable::Resolvable( const Kind & kind_r,
                           const std::string & name_r,
                           const Edition & edition_r,
                           const Arch & arch_r )
@@ -57,7 +57,7 @@ namespace zypp
   //
   ///////////////////////////////////////////////////////////////////
 
-  const ResKind & Resolvable::kind() const
+  const Resolvable::Kind & Resolvable::kind() const
   { return _pimpl->kind(); }
 
   const std::string & Resolvable::name() const
index 67fb81b..a76714e 100644 (file)
@@ -20,7 +20,6 @@
 #include "zypp/base/PtrTypes.h"
 #include "zypp/ResTraits.h"
 
-#include "zypp/ResKind.h"
 #include "zypp/Edition.h"
 #include "zypp/Arch.h"
 #include "zypp/Dependencies.h"
@@ -34,19 +33,20 @@ namespace zypp
   //   CLASS NAME : Resolvable
   //
   /** Interface base for resolvable objects (identification and dependencies).
-   * \todo Solve ResKind problems via traits template?
   */
   class Resolvable : public base::ReferenceCounted, private base::NonCopyable
   {
   public:
-    typedef Resolvable                      Self;
-    typedef base::intrusive_ptr<Self>       Ptr;
-    typedef base::intrusive_ptr<const Self> constPtr;
+    typedef Resolvable               Self;
+    typedef ResTraits<Self>          TraitsType;
+    typedef TraitsType::KindType     Kind;
+    typedef TraitsType::PtrType      Ptr;
+    typedef TraitsType::constPtrType constPtr;
     friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
 
   public:
     /**  */
-    const ResKind & kind() const;
+    const Kind & kind() const;
     /**  */
     const std::string & name() const;
     /**  */
@@ -60,7 +60,7 @@ namespace zypp
 
   protected:
     /** Ctor */
-    Resolvable( const ResKind & kind_r,
+    Resolvable( const Kind & kind_r,
                 const std::string & name_r,
                 const Edition & edition_r,
                 const Arch & arch_r );
index d8ead2c..ac1743b 100644 (file)
@@ -25,7 +25,7 @@ namespace zypp
   Script::Script( const std::string & name_r,
                   const Edition & edition_r,
                   const Arch & arch_r )
-  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
+  : ResObject( TraitsType::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index f07dd2b..50b350d 100644 (file)
@@ -28,10 +28,11 @@ namespace zypp
   class Script : public ResObject
   {
   public:
-    typedef Script                          Self;
-    typedef detail::ScriptImplIf            Impl;
-    typedef base::intrusive_ptr<Self>       Ptr;
-    typedef base::intrusive_ptr<const Self> constPtr;
+    typedef detail::ScriptImplIf     Impl;
+    typedef Script                   Self;
+    typedef ResTraits<Self>          TraitsType;
+    typedef TraitsType::PtrType      Ptr;
+    typedef TraitsType::constPtrType constPtr;
 
   public:
     /** Get the script to perform the change */
index fb95c98..c056c14 100644 (file)
@@ -27,7 +27,7 @@ namespace zypp
   Selection::Selection( const std::string & name_r,
                         const Edition & edition_r,
                         const Arch & arch_r )
-  : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
+  : ResObject( TraitsType::_kind, name_r, edition_r, arch_r )
   {}
 
   ///////////////////////////////////////////////////////////////////
index 39c0d64..733ba72 100644 (file)
@@ -28,10 +28,11 @@ namespace zypp
   class Selection : public ResObject
   {
   public:
-    typedef Selection                       Self;
-    typedef detail::SelectionImplIf         Impl;
-    typedef base::intrusive_ptr<Self>       Ptr;
-    typedef base::intrusive_ptr<const Self> constPtr;
+    typedef detail::SelectionImplIf  Impl;
+    typedef Selection                Self;
+    typedef ResTraits<Self>          TraitsType;
+    typedef TraitsType::PtrType      Ptr;
+    typedef TraitsType::constPtrType constPtr;
 
   public:
     /** */
diff --git a/zypp/base/KindOf.h b/zypp/base/KindOf.h
new file mode 100644 (file)
index 0000000..fc0e097
--- /dev/null
@@ -0,0 +1,97 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/KindOf.h
+ *
+*/
+#ifndef ZYPP_BASE_KINDOF_H
+#define ZYPP_BASE_KINDOF_H
+
+#include <iosfwd>
+#include <string>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace base
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : KindOf<_Tp>
+    //
+    /**
+    */
+    template<class _Tp>
+      class KindOf
+      {
+      public:
+        /** Ctor */
+        KindOf()
+        {}
+        /** Ctor */
+        explicit
+        KindOf( const std::string & value_r )
+        : _value( value_r )
+        {}
+        /** Dtor */
+        ~KindOf()
+        {}
+      public:
+        /** */
+        const std::string & asString() const
+        { return _value; }
+      private:
+        std::string _value;
+      };
+    ///////////////////////////////////////////////////////////////////
+
+    template<class _Tp>
+      inline std::ostream & operator<<( std::ostream & str, const KindOf<_Tp> & obj )
+      { return str << obj.asString(); }
+
+    ///////////////////////////////////////////////////////////////////
+
+    template<class _Tp>
+      inline bool operator==( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
+      { return lhs.asString() == rhs.asString(); }
+
+    template<class _Tp>
+      inline bool operator==( const KindOf<_Tp> & lhs, const std::string & rhs )
+      { return lhs.asString() == rhs; }
+
+    template<class _Tp>
+      inline bool operator==( const std::string & lhs, const KindOf<_Tp> & rhs )
+      { return lhs == rhs.asString(); }
+
+
+    template<class _Tp>
+      inline bool operator!=( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
+      { return !( lhs == rhs ); }
+
+    template<class _Tp>
+      inline bool operator!=( const KindOf<_Tp> & lhs, const std::string & rhs )
+      { return !( lhs == rhs ); }
+
+    template<class _Tp>
+      inline bool operator!=( const std::string & lhs, const KindOf<_Tp> & rhs )
+      { return !( lhs == rhs ); }
+
+
+    template<class _Tp>
+      inline bool operator<( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
+      { return lhs.asString() < rhs.asString(); }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace base
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_KINDOF_H
index fbcb8b7..a4cf911 100644 (file)
@@ -6,6 +6,7 @@ SUBDIRS =
 ## ##################################################
 
 include_HEADERS =      \
+       KindOf.h        \
        Logger.h        \
        NonCopyable.h   \
        PtrTypes.h      \
index cd04c9f..3102667 100644 (file)
@@ -28,7 +28,7 @@ namespace zypp
     // METHOD NAME : CapabilityImpl::CapabilityImpl
     // METHOD TYPE : Ctor
     //
-    CapabilityImpl::CapabilityImpl( const ResKind & refers_r )
+    CapabilityImpl::CapabilityImpl( const Resolvable::Kind & refers_r )
     : _refers( refers_r )
     {}
 
index c9d3471..2446b6e 100644 (file)
@@ -15,9 +15,8 @@
 #include "zypp/base/ReferenceCounted.h"
 #include "zypp/base/NonCopyable.h"
 
-#include "zypp/Resolvable.h"
+#include "zypp/Resolvable.h" // maybe ResTraits are sufficient?
 #include "zypp/SolverContextFwd.h"
-#include "zypp/ResKind.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -27,7 +26,7 @@ namespace zypp
   { /////////////////////////////////////////////////////////////////
     DEFINE_PTR_TYPE(CapabilityImpl)
 
-    /** \todo Check implementation */
+    /** \todo Check implementation, use base::KindOf */
     typedef std::string CapKind;
 
     ///////////////////////////////////////////////////////////////////
@@ -39,13 +38,13 @@ namespace zypp
     {
     public:
       /** Ctor */
-      CapabilityImpl( const ResKind & refers_r );
+      CapabilityImpl( const Resolvable::Kind & refers_r );
 
     public:
       /**  */
       virtual const CapKind & kind() const = 0;
       /**  */
-      const ResKind & refers() const
+      const Resolvable::Kind & refers() const
       { return _refers; }
       /**  */
       virtual std::string asString() const = 0;
@@ -55,7 +54,7 @@ namespace zypp
 
     private:
       /**  */
-      ResKind _refers;
+      Resolvable::Kind _refers;
     };
     ///////////////////////////////////////////////////////////////////
 
index 72c7c17..036ba67 100644 (file)
@@ -30,7 +30,7 @@ namespace zypp
     {
     public:
       /** Ctor */
-      NamedCap( const ResKind & refers_r, const std::string & name_r )
+      NamedCap( const Resolvable::Kind & refers_r, const std::string & name_r )
       : CapabilityImpl( refers_r )
       , _name( name_r )
       {}
index 2ccce3f..1226afc 100644 (file)
@@ -35,8 +35,9 @@ namespace zypp
           typedef ResImplConnect                  Self;
           typedef typename _Res::Impl             Impl;
           typedef base::shared_ptr<Impl>          ImplPtr;
-          typedef base::intrusive_ptr<Self>       Ptr;
-          typedef base::intrusive_ptr<const Self> constPtr;
+          // Ptr typed not needed
+          // typedef base::intrusive_ptr<Self>       Ptr;
+          // typedef base::intrusive_ptr<const Self> constPtr;
         public:
           /** \todo protect against NULL Impl. */
           ResImplConnect( const std::string & name_r,
index 27eb8a2..bff6a2e 100644 (file)
@@ -28,7 +28,7 @@ namespace zypp
   struct Resolvable::Impl
   {
     /** Ctor */
-    Impl( const ResKind & kind_r,
+    Impl( const Kind & kind_r,
           const std::string & name_r,
           const Edition & edition_r,
           const Arch & arch_r )
@@ -40,7 +40,7 @@ namespace zypp
 
   public:
     /**  */
-    const ResKind & kind() const
+    const Kind & kind() const
     { return _kind; }
     /**  */
     const std::string & name() const
@@ -63,7 +63,7 @@ namespace zypp
 
   private:
     /**  */
-    ResKind _kind;
+    Kind _kind;
     /**  */
     std::string _name;
     /**  */