backup
authorMichael Andres <ma@suse.de>
Fri, 14 Oct 2005 18:31:06 +0000 (18:31 +0000)
committerMichael Andres <ma@suse.de>
Fri, 14 Oct 2005 18:31:06 +0000 (18:31 +0000)
19 files changed:
test/Main.cc
zypp/Makefile.am
zypp/Package.cc [new file with mode: 0644]
zypp/Package.h [new file with mode: 0644]
zypp/Resolvable.cc
zypp/Resolvable.h
zypp/Selection.cc [new file with mode: 0644]
zypp/Selection.h [new file with mode: 0644]
zypp/base/Makefile.am
zypp/base/NonCopyable.h [new file with mode: 0644]
zypp/base/PtrTypes.h
zypp/base/ReferenceCounted.h [new file with mode: 0644]
zypp/detail/Makefile.am
zypp/detail/PackageImpl.cc [new file with mode: 0644]
zypp/detail/PackageImpl.h [new file with mode: 0644]
zypp/detail/ResolvableImpl.cc
zypp/detail/ResolvableImpl.h
zypp/detail/SelectionImpl.cc [new file with mode: 0644]
zypp/detail/SelectionImpl.h [new file with mode: 0644]

index 644f06f..76a1b0d 100644 (file)
@@ -1,80 +1,12 @@
 #include <iostream>
-#include <fstream>
-#include <iterator>
-#include <algorithm>
-#include <set>
-#include <map>
-#include <list>
-#include <vector>
-#include <ext/hash_set>
-#include <ext/hash_map>
-#include <ext/rope>
-
+#include <string>
 #include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-
-///////////////////////////////////////////////////////////////////
-
-#include <zypp/Resolvable.h>
-
-namespace zypp
-{
-  namespace detail
-  {
-    class PackageImpl;
-    typedef base::shared_ptr<PackageImpl> PackageImplPtr;
-  }
-
-  class Package : public Resolvable
-  {
-  public:
-    Package();
-    Package( detail::PackageImplPtr impl_r );
-    ~Package();
-    const std::string & label() const;
-  private:
-    /** Pointer to implementation */
-    detail::PackageImplPtr _pimpl;
-  };
-}
-
-///////////////////////////////////////////////////////////////////
-
-#include <zypp/detail/ResolvableImpl.h>
-
-namespace zypp
-{
-  namespace detail
-  {
-    class PackageImpl
-    {
-    public:
-      PackageImpl()
-      {}
-
-      ResolvableImplPtr _resolvable;
-      std::string       _label;
-    };
-  }
-
-  Package::Package()
-  : _pimpl( new detail::PackageImpl )
-  {}
-  Package::Package( detail::PackageImplPtr impl_r )
-  : Resolvable( impl_r->_resolvable )
-  , _pimpl( impl_r )
-  {}
-  Package::~Package()
-  {}
-  const std::string & Package::label() const
-  { return _pimpl->_label; }
-
-}
-
-///////////////////////////////////////////////////////////////////
+#include <zypp/detail/PackageImpl.h>
+#include <zypp/Package.h>
 
 using namespace std;
 using namespace zypp;
+using namespace base;
 
 /******************************************************************
 **
@@ -88,17 +20,22 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  detail::PackageImplPtr pi( new detail::PackageImpl );
-  pi->_resolvable.reset( new detail::ResolvableImpl( ResKind("PKG"),
-                                                     ResName("foo"),
-                                                     ResEdition("1.0","42"),
-                                                     ResArch("noarch") ) );
-  pi->_label = "label for foo";
+  ResName    _name( "foo" );
+  ResEdition _edition( "1.0", "42" );
+  ResArch    _arch( "i386" );
+
+
+  detail::PackageImplPtr pi( new detail::PackageImpl(_name,_edition,_arch) );
+  DBG << pi << endl;
+  DBG << *pi << endl;
+  constPackagePtr foo( new Package( pi ) );
+  DBG << foo << endl;
+  DBG << *foo << endl;
+
 
-  Package p( pi );
+  detail::constPackageImplPtr c( pi );
+  detail::PackageImplPtr cc( const_pointer_cast<detail::PackageImpl>(c) );
 
-  DBG << p << endl;
-  DBG << "  \"" << p.label() << "\"" << endl;
 
   INT << "===[END]============================================" << endl;
   return 0;
index 1e5c2a7..a7f87c8 100644 (file)
@@ -10,7 +10,9 @@ include_HEADERS = \
        ResName.h       \
        ResArch.h       \
        ResEdition.h    \
-       Resolvable.h
+       Resolvable.h    \
+       Package.h       \
+       Selection.h
 
 ## ##################################################
 
@@ -23,7 +25,9 @@ lib@PACKAGE@_la_SOURCES = \
        ResName.cc      \
        ResArch.cc      \
        ResEdition.cc   \
-       Resolvable.cc
+       Resolvable.cc   \
+       Package.cc      \
+       Selection.cc
 
 lib@PACKAGE@_la_LDFLAGS =      @LIB_VERSION_INFO@
 
diff --git a/zypp/Package.cc b/zypp/Package.cc
new file mode 100644 (file)
index 0000000..9134bf4
--- /dev/null
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/Package.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/Package.h"
+#include "zypp/detail/PackageImpl.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Package::Package
+  //   METHOD TYPE : Ctor
+  //
+  Package::Package( detail::PackageImplPtr impl_r )
+  :  Resolvable( impl_r )
+  , _pimpl( impl_r )
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Package::~Package
+  //   METHOD TYPE : Dtor
+  //
+  Package::~Package()
+  {}
+
+  std::string Package::summary() const
+  { return _pimpl->summary(); }
+
+  std::list<std::string> Package::description() const
+  { return _pimpl->description(); }
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/Package.h b/zypp/Package.h
new file mode 100644 (file)
index 0000000..048f80e
--- /dev/null
@@ -0,0 +1,63 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/Package.h
+ *
+*/
+#ifndef ZYPP_PACKAGE_H
+#define ZYPP_PACKAGE_H
+
+#include <list>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+
+#include "zypp/Resolvable.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace detail
+  { /////////////////////////////////////////////////////////////////
+    DEFINE_PTR_TYPE(PackageImpl)
+    /////////////////////////////////////////////////////////////////
+  } // namespace detail
+  ///////////////////////////////////////////////////////////////////
+  DEFINE_PTR_TYPE(Package)
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : Package
+  //
+  /** */
+  class Package : public Resolvable
+  {
+  public:
+    /** Default ctor */
+    Package( detail::PackageImplPtr impl_r );
+    /** Dtor */
+    virtual ~Package();
+
+  public:
+
+    /** */
+    std::string summary() const;
+    /** */
+    std::list<std::string> description() const;
+
+  private:
+    /** Pointer to implementation */
+    detail::PackageImplPtr _pimpl;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PACKAGE_H
index 81bc4e2..0832a83 100644 (file)
@@ -11,7 +11,6 @@
 */
 #include <iostream>
 
-#include "zypp/base/Logger.h"
 #include "zypp/Resolvable.h"
 #include "zypp/detail/ResolvableImpl.h"
 
@@ -26,15 +25,6 @@ namespace zypp
   //   METHOD NAME : Resolvable::Resolvable
   //   METHOD TYPE : Ctor
   //
-  Resolvable::Resolvable()
-  : _pimpl( new detail::ResolvableImpl )
-  {}
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   METHOD NAME : Resolvable::Resolvable
-  //   METHOD TYPE : Ctor
-  //
   Resolvable::Resolvable( detail::ResolvableImplPtr impl_r )
   : _pimpl( impl_r )
   {}
@@ -59,6 +49,14 @@ namespace zypp
   const ResArch & Resolvable::arch() const
   { return _pimpl->arch(); }
 
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Resolvable::~Resolvable
+  //   METHOD TYPE : Dtor
+  //
+  detail::constResolvableImplPtr Resolvable::sayFriend() const
+  { return _pimpl; }
+
   /******************************************************************
   **
   **   FUNCTION NAME : operator<<
@@ -66,8 +64,7 @@ namespace zypp
   */
   std::ostream & operator<<( std::ostream & str, const Resolvable & obj )
   {
-    str << '[' << obj.kind() << ']' << obj.name() << '-' << obj.edition() << '.' << obj.arch();
-    return str;
+    return str << *obj.sayFriend();
   }
 
   /////////////////////////////////////////////////////////////////
index dd9487f..4e0b5e9 100644 (file)
 
 #include <iosfwd>
 
-#include "zypp/base/PtrTypes.h"
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
-
-  class ResKind;
-  class ResName;
-  class ResEdition;
-  class ResArch;
-
   ///////////////////////////////////////////////////////////////////
   namespace detail
   { /////////////////////////////////////////////////////////////////
-    /** Hides implementation */
-    class ResolvableImpl;
-    typedef base::shared_ptr<ResolvableImpl> ResolvableImplPtr;
+    DEFINE_PTR_TYPE(ResolvableImpl)
     /////////////////////////////////////////////////////////////////
   } // namespace detail
   ///////////////////////////////////////////////////////////////////
+  DEFINE_PTR_TYPE(Resolvable)
+
+  class ResKind;
+  class ResName;
+  class ResEdition;
+  class ResArch;
 
   ///////////////////////////////////////////////////////////////////
   //
   //   CLASS NAME : Resolvable
   //
   /** */
-  class Resolvable
+  class Resolvable : public base::ReferenceCounted, private base::NonCopyable
   {
   public:
-    /** Default ctor */
-    Resolvable();
     /** ctor */
     Resolvable( detail::ResolvableImplPtr impl_r );
     /** Dtor */
-    ~Resolvable();
+    virtual ~Resolvable();
+
   public:
     /**  */
     const ResKind & kind() const;
@@ -58,9 +56,13 @@ namespace zypp
     const ResEdition & edition() const;
     /**  */
     const ResArch & arch() const;
+
   private:
     /** Pointer to implementation */
     detail::ResolvableImplPtr _pimpl;
+  public:
+    /** Avoid a bunch of friend decl. */
+    detail::constResolvableImplPtr sayFriend() const;
   };
   ///////////////////////////////////////////////////////////////////
 
diff --git a/zypp/Selection.cc b/zypp/Selection.cc
new file mode 100644 (file)
index 0000000..3ebe1a8
--- /dev/null
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/Selection.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/Selection.h"
+#include "zypp/detail/SelectionImpl.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Selection::Selection
+  //   METHOD TYPE : Ctor
+  //
+  Selection::Selection( detail::SelectionImplPtr impl_r )
+  :  Resolvable( impl_r )
+  , _pimpl( impl_r )
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Selection::~Selection
+  //   METHOD TYPE : Dtor
+  //
+  Selection::~Selection()
+  {}
+
+  std::string Selection::summary() const
+  { return _pimpl->summary(); }
+
+  std::list<std::string> Selection::description() const
+  { return _pimpl->description(); }
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/Selection.h b/zypp/Selection.h
new file mode 100644 (file)
index 0000000..9004804
--- /dev/null
@@ -0,0 +1,63 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/Selection.h
+ *
+*/
+#ifndef ZYPP_SELECTION_H
+#define ZYPP_SELECTION_H
+
+#include <list>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+
+#include "zypp/Resolvable.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace detail
+  { /////////////////////////////////////////////////////////////////
+    DEFINE_PTR_TYPE(SelectionImpl)
+    /////////////////////////////////////////////////////////////////
+  } // namespace detail
+  ///////////////////////////////////////////////////////////////////
+  DEFINE_PTR_TYPE(Selection)
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : Selection
+  //
+  /** */
+  class Selection : public Resolvable
+  {
+  public:
+    /** Default ctor */
+    Selection( detail::SelectionImplPtr impl_r );
+    /** Dtor */
+    virtual ~Selection();
+
+  public:
+
+    /** */
+    std::string summary() const;
+    /** */
+    std::list<std::string> description() const;
+
+  private:
+    /** Pointer to implementation */
+    detail::SelectionImplPtr _pimpl;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SELECTION_H
index da74ac2..fbcb8b7 100644 (file)
@@ -6,9 +6,11 @@ SUBDIRS =
 ## ##################################################
 
 include_HEADERS =      \
+       Logger.h        \
+       NonCopyable.h   \
        PtrTypes.h      \
+       ReferenceCounted.h      \
        String.h        \
-       Logger.h        \
        StringVal.h
 
 
@@ -17,8 +19,8 @@ noinst_LTLIBRARIES =  lib@PACKAGE@_base.la
 ## ##################################################
 
 lib@PACKAGE@_base_la_SOURCES = \
-       String.cc       \
        Logger.cc       \
+       String.cc       \
        StringVal.cc
 
 
diff --git a/zypp/base/NonCopyable.h b/zypp/base/NonCopyable.h
new file mode 100644 (file)
index 0000000..78d2cfb
--- /dev/null
@@ -0,0 +1,34 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/NonCopyable.h
+*/
+#ifndef ZYPP_BASE_NONCOPYABLE_H
+#define ZYPP_BASE_NONCOPYABLE_H
+
+#include <boost/noncopyable.hpp>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace base
+  { /////////////////////////////////////////////////////////////////
+
+    /** Ensure derived classes cannot be copied.
+     * Use private inheritance.
+    */
+    typedef boost::noncopyable NonCopyable;
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace base
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_NONCOPYABLE_H
index b881588..8f339ec 100644 (file)
@@ -7,7 +7,8 @@
 |                                                                      |
 \---------------------------------------------------------------------*/
 /** \file zypp/base/PtrTypes.h
- *
+ *  \ingroup ZYPP_BASE_SMART_PTR
+ *  \see ZYPP_BASE_SMART_PTR
 */
 #ifndef ZYPP_BASE_PTRTYPES_H
 #define ZYPP_BASE_PTRTYPES_H
@@ -23,6 +24,20 @@ namespace zypp
   namespace base
   { /////////////////////////////////////////////////////////////////
 
+    /** \defgroup ZYPP_BASE_SMART_PTR ZYPP_BASE_SMART_PTR
+     *  Smart pointer types.
+     *
+     * Namespace zypp::base provides 3 smart pointer types \b using the
+     * boostsmart pointer library.
+     *
+     * \li \c scoped_ptr Simple sole ownership of single objects. Noncopyable.
+     *
+     * \li \c shared_ptr Object ownership shared among multiple pointers
+     *
+     * \li \c weak_ptr Non-owning observers of an object owned by shared_ptr.
+    */
+    /*@{*/
+
     /** */
     using boost::scoped_ptr;
 
@@ -32,6 +47,8 @@ namespace zypp
     /** */
     using boost::weak_ptr;
 
+    /*@}*/
+
     /////////////////////////////////////////////////////////////////
   } // namespace base
   ///////////////////////////////////////////////////////////////////
diff --git a/zypp/base/ReferenceCounted.h b/zypp/base/ReferenceCounted.h
new file mode 100644 (file)
index 0000000..6eec4b5
--- /dev/null
@@ -0,0 +1,120 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/ReferenceCounted.h
+ *
+*/
+#ifndef ZYPP_BASE_REFERENCECOUNTED_H
+#define ZYPP_BASE_REFERENCECOUNTED_H
+
+#include <iosfwd>
+#include <boost/intrusive_ptr.hpp>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace base
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : ReferenceCounted
+    //
+    /** Base class for reference counted objects.
+     * \todo Define exceptions.
+     * \todo Make counter thread safe.
+     * \todo get rid of base namesapace.
+    */
+    class ReferenceCounted
+    {
+    public:
+      /** Default ctor.
+       * Initial reference count is zero.
+      */
+      ReferenceCounted()
+      : _counter( 0 )
+      {}
+
+      /** Copy ctor.
+       * Initial reference count is zero.
+      */
+      ReferenceCounted( const ReferenceCounted & rhs )
+      : _counter( 0 )
+      {}
+
+      /** Dtor.
+       * \throw INTERNAL if reference count is not zero.
+      */
+      virtual ~ReferenceCounted()
+      { if ( _counter ) throw( "~ReferenceCounted: nonzero reference count" ); }
+
+      /** Assignment.
+       * Reference count remains untouched.
+      */
+      ReferenceCounted & operator=( const ReferenceCounted & )
+      { return *this; }
+
+    public:
+      /** Add a reference. */
+      void ref() const
+      { ++_counter; }
+
+      /** Release a reference.
+       * Deletes the object if reference count gets zero.
+       * \throw INTERNAL if reference count is zero.
+      */
+      void unref() const
+      {
+        if ( !_counter )
+          throw( "ReferenceCounted::unref: zero reference count" );
+        if ( --_counter == 0 )
+          delete this;
+      }
+
+    private:
+      /** The reference counter. */
+      mutable unsigned _counter;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /** Use boost::intrusive_ptr as Ptr type*/
+    using boost::intrusive_ptr;
+    using boost::static_pointer_cast;
+    using boost::const_pointer_cast;
+    using boost::dynamic_pointer_cast;
+
+    /** Called by zypp::base::intrusive_ptr to add a reference.
+     * \relates ReferenceCounted
+     * \see ZYPP_BASE_SMART_PTR
+    */
+    inline void intrusive_ptr_add_ref( const ReferenceCounted * ptr_r )
+    { if( ptr_r ) ptr_r->ref(); }
+
+    /** Called by zypp::base::intrusive_ptr to add a reference.
+     * \relates ReferenceCounted
+     * \see ZYPP_BASE_SMART_PTR
+    */
+    inline void intrusive_ptr_release( const ReferenceCounted * ptr_r  )
+    { if( ptr_r ) ptr_r->unref(); }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace base
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+/** Forward declaration of Ptr types */
+#define DEFINE_PTR_TYPE(NAME) \
+class NAME;                                                      \
+typedef zypp::base::intrusive_ptr<NAME>       NAME##Ptr;         \
+typedef zypp::base::intrusive_ptr<const NAME> const##NAME##Ptr;
+
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_REFERENCECOUNTED_H
index 487169f..085f424 100644 (file)
@@ -5,15 +5,19 @@ SUBDIRS =
 
 ## ##################################################
 
-include_HEADERS =      \
-       ResolvableImpl.h
+include_HEADERS = \
+       ResolvableImpl.h        \
+       PackageImpl.h           \
+       SelectionImpl.h
 
 
 noinst_LTLIBRARIES =   lib@PACKAGE@_detail.la
 
 ## ##################################################
 
-lib@PACKAGE@_detail_la_SOURCES =       \
-       ResolvableImpl.cc
+lib@PACKAGE@_detail_la_SOURCES = \
+       ResolvableImpl.cc       \
+       PackageImpl.cc          \
+       SelectionImpl.cc
 
 ## ##################################################
diff --git a/zypp/detail/PackageImpl.cc b/zypp/detail/PackageImpl.cc
new file mode 100644 (file)
index 0000000..d73e2a7
--- /dev/null
@@ -0,0 +1,55 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/detail/PackageImpl.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/detail/PackageImpl.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace detail
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : PackageImpl::PackageImpl
+    // METHOD TYPE : Ctor
+    //
+    PackageImpl::PackageImpl( const ResName & name_r,
+                              const ResEdition & edition_r,
+                              const ResArch & arch_r )
+    : ResolvableImpl( ResKind("package"), name_r, edition_r, arch_r )
+    {}
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : PackageImpl::~PackageImpl
+    // METHOD TYPE : Dtor
+    //
+    PackageImpl::~PackageImpl()
+    {}
+
+    std::string PackageImpl::summary() const
+    { return std::string(); }
+
+    std::list<std::string> PackageImpl::description() const
+    { return std::list<std::string>(); }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace detail
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/detail/PackageImpl.h b/zypp/detail/PackageImpl.h
new file mode 100644 (file)
index 0000000..e644fe7
--- /dev/null
@@ -0,0 +1,154 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/detail/PackageImpl.h
+ *
+*/
+#ifndef ZYPP_DETAIL_PACKAGEIMPL_H
+#define ZYPP_DETAIL_PACKAGEIMPL_H
+
+#include <list>
+
+#include "zypp/detail/ResolvableImpl.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace detail
+  { /////////////////////////////////////////////////////////////////
+    DEFINE_PTR_TYPE(PackageImpl)
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : PackageImpl
+    //
+    /** */
+    class PackageImpl : public ResolvableImpl
+    {
+    public:
+      /** */
+      PackageImpl( const ResName & name_r,
+                   const ResEdition & edition_r,
+                   const ResArch & arch_r );
+      /** Dtor */
+      virtual ~PackageImpl();
+
+    public:
+      /** */
+      virtual std::string summary() const;
+      /** */
+      virtual std::list<std::string> description() const;
+#if 0
+      /** */
+      virtual std::list<std::string> insnotify() const;
+      /** */
+      virtual std::list<std::string> delnotify() const;
+      /** */
+      virtual FSize size() const;
+      /** */
+      virtual bool providesSources() const;
+      /** */
+      virtual std::string instSrcLabel() const;
+      /** */
+      virtual Vendor instSrcVendor() const;
+      /** */
+      virtual unsigned instSrcRank() const;
+      /** */
+      virtual PkgSplitSet splitprovides() const;
+      /** */
+      virtual Date buildtime() const;
+      /** */
+      virtual std::string buildhost() const;
+      /** */
+      virtual Date installtime() const;
+      /** */
+      virtual std::string distribution() const;
+      /** */
+      virtual Vendor vendor() const;
+      /** */
+      virtual std::string license() const;
+      /** */
+      virtual std::list<std::string> licenseToConfirm() const;
+      /** */
+      virtual std::string packager() const;
+      /** */
+      virtual std::string group() const;
+      /** */
+      virtual YStringTreeItem * group_ptr() const;
+      /** */
+      virtual std::list<std::string> changelog() const;
+      /** */
+      virtual std::string url() const;
+      /** */
+      virtual std::string os() const;
+      /** */
+      virtual std::list<std::string> prein() const;
+      /** */
+      virtual std::list<std::string> postin() const;
+      /** */
+      virtual std::list<std::string> preun() const;
+      /** */
+      virtual std::list<std::string> postun() const;
+      /** */
+      virtual std::string sourceloc() const;
+      /** */
+      virtual FSize sourcesize() const;
+      /** */
+      virtual FSize archivesize() const;
+      /** */
+      virtual std::list<std::string> authors() const;
+      /** */
+      virtual std::list<std::string> filenames() const;
+      /** */
+      virtual std::list<std::string> recommends() const;
+      /** */
+      virtual std::list<std::string> suggests() const;
+      /** */
+      virtual std::string location() const;
+      /** */
+      virtual unsigned int medianr() const;
+      /** */
+      virtual std::list<std::string> keywords() const;
+      /** */
+      virtual std::string md5sum() const;
+      /** */
+      virtual std::string externalUrl() const;
+      /** */
+      virtual std::list<PkgEdition> patchRpmBaseVersions() const;
+      /** */
+      virtual FSize patchRpmSize() const;
+      /** */
+      virtual bool forceInstall() const;
+      /** */
+      virtual std::string patchRpmMD5() const;
+      /** */
+      virtual bool isRemote() const;
+      /** */
+      virtual PMError providePkgToInstall( Pathname& path_r ) const;
+      /** */
+      virtual PMError provideSrcPkgToInstall( Pathname& path_r ) const;
+      /** */
+      virtual constInstSrcPtr source() const;
+      /** */
+      virtual bool prefererCandidate() const;
+      /** */
+      virtual void du( PkgDu & dudata_r ) const;
+      /** */
+      virtual std::list<PMPackageDelta> deltas() const;
+#endif
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace detail
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_DETAIL_PACKAGEIMPL_H
index 24cddc7..1452369 100644 (file)
@@ -11,7 +11,6 @@
 */
 #include <iostream>
 
-#include "zypp/base/Logger.h"
 #include "zypp/detail/ResolvableImpl.h"
 
 using namespace std;
@@ -25,9 +24,37 @@ namespace zypp
 
     ///////////////////////////////////////////////////////////////////
     //
-    // CLASS NAME : ResolvableImpl
+    // METHOD NAME : ResolvableImpl::ResolvableImpl
+    // METHOD TYPE : Ctor
     //
+    ResolvableImpl::ResolvableImpl( const ResKind & kind_r,
+                                    const ResName & name_r,
+                                    const ResEdition & edition_r,
+                                    const ResArch & arch_r )
+    : _kind( kind_r )
+    , _name( name_r )
+    , _edition( edition_r )
+    , _arch( arch_r )
+    {}
+
     ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : ResolvableImpl::~ResolvableImpl
+    // METHOD TYPE : Dtor
+    //
+    ResolvableImpl::~ResolvableImpl()
+    {}
+
+    /******************************************************************
+     **
+     **        FUNCTION NAME : operator<<
+     **        FUNCTION TYPE : std::ostream &
+    */
+    std::ostream & operator<<( std::ostream & str, const ResolvableImpl & obj )
+    {
+      str << '[' << obj.kind() << ']' << obj.name() << '-' << obj.edition() << '.' << obj.arch();
+      return str;
+    }
 
     /////////////////////////////////////////////////////////////////
   } // namespace detail
index b28d2bd..de1f76a 100644 (file)
@@ -12,7 +12,8 @@
 #ifndef ZYPP_DETAIL_RESOLVABLEIMPL_H
 #define ZYPP_DETAIL_RESOLVABLEIMPL_H
 
-#include <iosfwd>
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
 
 #include "zypp/ResKind.h"
 #include "zypp/ResName.h"
@@ -25,31 +26,24 @@ namespace zypp
   ///////////////////////////////////////////////////////////////////
   namespace detail
   { /////////////////////////////////////////////////////////////////
+    DEFINE_PTR_TYPE(ResolvableImpl)
 
     ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : ResolvableImpl
     //
     /** */
-    class ResolvableImpl
+    class ResolvableImpl : public base::ReferenceCounted, private base::NonCopyable
     {
     public:
-      /** Default ctor */
-      ResolvableImpl()
-      {}
       /** ctor */
       ResolvableImpl( const ResKind & kind_r,
                       const ResName & name_r,
                       const ResEdition & edition_r,
-                      const ResArch & arch_r )
-      : _kind( kind_r )
-      , _name( name_r )
-      , _edition( edition_r )
-      , _arch( arch_r )
-      {}
+                      const ResArch & arch_r );
       /** Dtor */
-      ~ResolvableImpl()
-      {}
+      virtual ~ResolvableImpl();
+
     public:
       /**  */
       const ResKind & kind() const
@@ -63,14 +57,22 @@ namespace zypp
       /**  */
       const ResArch & arch() const
       { return _arch; }
+
     private:
+      /**  */
       ResKind    _kind;
+      /**  */
       ResName    _name;
+      /**  */
       ResEdition _edition;
+      /**  */
       ResArch    _arch;
     };
     ///////////////////////////////////////////////////////////////////
 
+    /** \relates ResolvableImpl Stream output */
+    extern std::ostream & operator<<( std::ostream & str, const ResolvableImpl & obj );
+
     /////////////////////////////////////////////////////////////////
   } // namespace detail
   ///////////////////////////////////////////////////////////////////
diff --git a/zypp/detail/SelectionImpl.cc b/zypp/detail/SelectionImpl.cc
new file mode 100644 (file)
index 0000000..73dc0e9
--- /dev/null
@@ -0,0 +1,55 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/detail/SelectionImpl.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/detail/SelectionImpl.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace detail
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : SelectionImpl::SelectionImpl
+    // METHOD TYPE : Ctor
+    //
+    SelectionImpl::SelectionImpl( const ResName & name_r,
+                                  const ResEdition & edition_r,
+                                  const ResArch & arch_r )
+    : ResolvableImpl( ResKind("selection"), name_r, edition_r, arch_r )
+    {}
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : SelectionImpl::~SelectionImpl
+    // METHOD TYPE : Dtor
+    //
+    SelectionImpl::~SelectionImpl()
+    {}
+
+    std::string SelectionImpl::summary() const
+    { return std::string(); }
+
+    std::list<std::string> SelectionImpl::description() const
+    { return std::list<std::string>(); }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace detail
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/detail/SelectionImpl.h b/zypp/detail/SelectionImpl.h
new file mode 100644 (file)
index 0000000..d2b4838
--- /dev/null
@@ -0,0 +1,83 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/detail/SelectionImpl.h
+ *
+*/
+#ifndef ZYPP_DETAIL_SELECTIONIMPL_H
+#define ZYPP_DETAIL_SELECTIONIMPL_H
+
+#include <list>
+
+#include "zypp/detail/ResolvableImpl.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace detail
+  { /////////////////////////////////////////////////////////////////
+    DEFINE_PTR_TYPE(SelectionImpl)
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : SelectionImpl
+    //
+    /** */
+    class SelectionImpl : public ResolvableImpl
+    {
+    public:
+      /** */
+      SelectionImpl( const ResName & name_r,
+                     const ResEdition & edition_r,
+                     const ResArch & arch_r );
+      /** Dtor */
+      virtual ~SelectionImpl();
+
+    public:
+      /** */
+      virtual std::string summary() const;
+      /** */
+      virtual std::list<std::string> description() const;
+#if 0
+      virtual std::string summary( const LangCode & lang = LangCode("") ) const;
+      virtual std::list<std::string> description( const LangCode & lang = LangCode("") ) const;
+      virtual std::list<std::string> insnotify( const LangCode & lang = LangCode("") ) const;
+      virtual std::list<std::string> delnotify( const LangCode & lang = LangCode("") ) const;
+      virtual FSize size() const;
+      virtual bool providesSources() const;
+      virtual std::string instSrcLabel() const;
+      virtual Vendor instSrcVendor() const;
+      virtual unsigned instSrcRank() const;
+      virtual std::string category() const;
+      virtual bool visible() const;
+      virtual std::list<std::string> suggests() const;
+      virtual std::list<PMSelectionPtr> suggests_ptrs() const;
+      virtual std::list<std::string> recommends() const;
+      virtual std::list<PMSelectionPtr> recommends_ptrs() const;
+      virtual std::list<std::string> inspacks( const LangCode & lang = LangCode("") ) const;
+      virtual std::list<std::string> delpacks( const LangCode & lang = LangCode("") ) const;
+      virtual PM::LocaleSet supportedLocales() const;
+      virtual std::set<PMSelectablePtr> pureInspacks_ptrs( const LangCode & lang ) const;
+      virtual std::set<PMSelectablePtr> inspacks_ptrs( const LangCode & lang ) const;
+      virtual std::set<PMSelectablePtr> delpacks_ptrs( const LangCode & lang ) const;
+      virtual FSize archivesize() const;
+      virtual std::string order() const;
+      virtual bool isBase() const;
+      virtual PMError provideSelToInstall( Pathname & path_r ) const;
+#endif
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace detail
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_DETAIL_SELECTIONIMPL_H