Resolvables ResKind() value.
#include <functional>
#include <algorithm>
#include <zypp/base/Logger.h>
-#include <zypp/base/PtrTypes.h>
-#include "main.h"
-//#include "main2.h"
+#include <zypp/Message.h>
+#include <zypp/Package.h>
#define TAG INT << __PRETTY_FUNCTION__ << std::endl
using namespace std;
-inline void OUT( Resolvable::constPtr p )
+inline void OUT( zypp::Resolvable::constPtr p )
{
if ( p )
MIL << *p << endl;
MIL << "NULL" << endl;
}
-inline void OUT( Package::constPtr p )
+
+namespace zypp
{
- if ( p ) {
- MIL << *p << ' ' << p->packagedata() << endl;
+ namespace detail {
+ ResObjectImplIf::~ResObjectImplIf()
+ {}
}
- else
- MIL << "NULL" << endl;
-}
-inline void OUT( Package::Ptr p )
-{
- OUT( Package::constPtr( p ) );
-}
-struct PI : public PackageImpl
+// connect resolvables interface and implementation.
+template<class _Res>
+ class ResImplConnect : public _Res
+ {
+ public:
+ 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;
+ public:
+ /** \todo protect against NULL Impl. */
+ ResImplConnect( const std::string & name_r,
+ const Edition & edition_r,
+ const Arch & arch_r,
+ ImplPtr impl_r )
+ : _Res( name_r, edition_r, arch_r )
+ , _impl( impl_r )
+ { _impl->_backRef = this; }
+ virtual ~ResImplConnect() {}
+ private:
+ ImplPtr _impl;
+ virtual Impl & pimpl() { return *_impl; }
+ virtual const Impl & pimpl() const { return *_impl; }
+ };
+
+
+template<class _Impl>
+ typename _Impl::ResType::Ptr
+ makeResolvable( const std::string & name_r,
+ const Edition & edition_r,
+ const Arch & arch_r,
+ base::shared_ptr<_Impl> & impl_r )
+ {
+ impl_r.reset( new _Impl );
+ return new ResImplConnect<typename _Impl::ResType>( name_r,
+ edition_r,
+ arch_r,
+ impl_r );
+ }
+template<class _Impl>
+ typename _Impl::ResType::Ptr
+ makeResolvable( base::shared_ptr<_Impl> & impl_r )
+ {
+ impl_r.reset( new _Impl );
+ return new ResImplConnect<typename _Impl::ResType>( "n",
+ Edition("v","r"),
+ Arch(),
+ impl_r );
+ }
+
+}//ns
+
+struct PI : public zypp::detail::MessageImplIf
{
- virtual string packagedata() const { return "PI::packagedata"; }
+ virtual std::string text() const { return "message text"; }
+ virtual std::string type() const { return "message type"; }
+ virtual ~PI(){}
};
{
INT << "===[START]==========================================" << endl;
+ zypp::base::shared_ptr<PI> pi;
+ OUT( zypp::makeResolvable( pi ) );
+
+
+
+#if 0
/* NVRA */
zypp::base::shared_ptr<PI> pi;
Package::Ptr p( makeResolvable( /*NVRA*/ pi ) );
p = makeResolvable( /*NVRA*/ pi );
OUT( p );
+#endif
INT << "===[END]============================================" << endl;
return 0;
## Process this file with automake to produce Makefile.in
## ##################################################
-noinst_PROGRAMS = Main Main.debug PtrTest Main2
+noinst_PROGRAMS = Main Main.debug PtrTest
## ##################################################
## ##################################################
-Main_SOURCES = Main.cc main.cc
-Main2_SOURCES = main.cc Main.cc
+Main_SOURCES = Main.cc
Main_debug_SOURCES = $(Main_SOURCES)
Main_debug_LDFLAGS = -static
std::string Capability::asString() const
{ return _pimpl->asString(); }
- bool Capability::matches( constResolvablePtr resolvable_r,
+ bool Capability::matches( Resolvable::constPtr resolvable_r,
const SolverContext & solverContext_r ) const
{ return _pimpl->matches( resolvable_r, solverContext_r ); }
- bool Capability::matches( constResolvablePtr resolvable_r ) const
+ bool Capability::matches( Resolvable::constPtr resolvable_r ) const
{ return _pimpl->matches( resolvable_r, SolverContext() ); }
/******************************************************************
#include "zypp/base/PtrTypes.h"
-#include "zypp/ResolvableFwd.h"
+#include "zypp/Resolvable.h"
#include "zypp/SolverContextFwd.h"
///////////////////////////////////////////////////////////////////
/** */
std::string asString() const;
/** */
- bool matches( constResolvablePtr resolvable_r,
+ bool matches( Resolvable::constPtr resolvable_r,
const SolverContext & colverContext_r ) const;
/** */
- bool matches( constResolvablePtr resolvable_r ) const;
+ bool matches( Resolvable::constPtr resolvable_r ) const;
private:
/** Pointer to implementation */
Message::Message( const std::string & name_r,
const Edition & edition_r,
const Arch & arch_r )
- : ResObject( ResKind("Message"), name_r, edition_r, arch_r )
+ : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
{}
///////////////////////////////////////////////////////////////////
Package::Package( const std::string & name_r,
const Edition & edition_r,
const Arch & arch_r )
- : ResObject( ResKind("Package"), name_r, edition_r, arch_r )
+ : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
{}
///////////////////////////////////////////////////////////////////
Patch::Patch( const std::string & name_r,
const Edition & edition_r,
const Arch & arch_r )
- : ResObject( ResKind("Patch"), name_r, edition_r, arch_r )
+ : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
{}
///////////////////////////////////////////////////////////////////
Product::Product( const std::string & name_r,
const Edition & edition_r,
const Arch & arch_r )
- : ResObject( ResKind("Product"), name_r, edition_r, arch_r )
+ : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
{}
///////////////////////////////////////////////////////////////////
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
-#include <zypp/base/PtrTypes.h>
+#include "zypp/base/PtrTypes.h"
+#include "zypp/ResTraits.h"
#include "zypp/ResKind.h"
#include "zypp/Edition.h"
};
///////////////////////////////////////////////////////////////////
+
+
+
+ ///////////////////////////////////////////////////////////////////
+
/** Required by base::intrusive_ptr to add a reference. */
inline void intrusive_ptr_add_ref( const Resolvable * ptr_r )
{ base::ReferenceCounted::add_ref( ptr_r ); }
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/ResolvableFwd.h
- *
-*/
-#ifndef ZYPP_RESOLVABLEFWD_H
-#define ZYPP_RESOLVABLEFWD_H
-
-#include "zypp/base/PtrTypes.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- class ResKind;
- class Edition;
- class Arch;
- class Dependencies;
-
- DEFINE_PTR_TYPE(Resolvable)
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_RESOLVABLEFWD_H
Script::Script( const std::string & name_r,
const Edition & edition_r,
const Arch & arch_r )
- : ResObject( ResKind("Script"), name_r, edition_r, arch_r )
+ : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
{}
///////////////////////////////////////////////////////////////////
Selection::Selection( const std::string & name_r,
const Edition & edition_r,
const Arch & arch_r )
- : ResObject( ResKind("Selection"), name_r, edition_r, arch_r )
+ : ResObject( ResTraits<Self>::_kind, name_r, edition_r, arch_r )
{}
///////////////////////////////////////////////////////////////////
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
-#include "zypp/ResolvableFwd.h"
+#include "zypp/Resolvable.h"
#include "zypp/SolverContextFwd.h"
#include "zypp/ResKind.h"
/** */
virtual std::string asString() const = 0;
/** */
- virtual bool matches( constResolvablePtr resolvable_r,
+ virtual bool matches( Resolvable::constPtr resolvable_r,
const SolverContext & colverContext_r ) const = 0;
private:
virtual std::string asString() const
{ return _name; }
/** */
- virtual bool matches( constResolvablePtr resolvable_r,
+ virtual bool matches( Resolvable::constPtr resolvable_r,
const SolverContext & colverContext_r ) const
{ return false; }
private:
{ /////////////////////////////////////////////////////////////////
class Resolvable;
+ template<class _Res>
+ class ResImplConnect;
typedef std::string line;
typedef std::list<std::string> text;