#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
MIL << "NULL" << endl;
}
+#if 0
struct PI : public zypp::detail::MessageImplIf
{
virtual std::string text() const { return "message text"; }
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;
/******************************************************************
**
**
{
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;
}
AM_LDFLAGS =
-AM_CXXFLAGS = -pg
+AM_CXXFLAGS =
+# gperf: -pg
LDADD = $(top_srcdir)/zypp/lib@PACKAGE@.la
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
//
Capability CapFactory::parse( const std::string & strval_r ) const
{
- return parse( strval_r, ResKind() );
+ return parse( strval_r, Resolvable::Kind() );
}
///////////////////////////////////////////////////////////////////
// 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 );
~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 */
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
public:
/** */
- const ResKind & refers() const;
+ const Resolvable::Kind & refers() const;
/** */
std::string asString() const;
/** */
CapSet.h \
Dependencies.h \
Edition.h \
- ResKind.h \
ResObject.h \
Resolvable.h \
ResTraits.h \
CapSet.cc \
Dependencies.cc \
Edition.cc \
- ResKind.cc \
ResObject.cc \
Resolvable.cc \
ResTraits.cc \
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 )
{}
///////////////////////////////////////////////////////////////////
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 */
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 )
{}
///////////////////////////////////////////////////////////////////
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:
/** */
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 )
{}
///////////////////////////////////////////////////////////////////
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;
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 )
{}
///////////////////////////////////////////////////////////////////
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) */
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ 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
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ 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
// 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 )
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:
/** */
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 );
*/
#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
#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;
};
/////////////////////////////////////////////////////////////////
// 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 )
//
///////////////////////////////////////////////////////////////////
- const ResKind & Resolvable::kind() const
+ const Resolvable::Kind & Resolvable::kind() const
{ return _pimpl->kind(); }
const std::string & Resolvable::name() const
#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"
// 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;
/** */
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 );
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 )
{}
///////////////////////////////////////////////////////////////////
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 */
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 )
{}
///////////////////////////////////////////////////////////////////
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:
/** */
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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
## ##################################################
include_HEADERS = \
+ KindOf.h \
Logger.h \
NonCopyable.h \
PtrTypes.h \
// METHOD NAME : CapabilityImpl::CapabilityImpl
// METHOD TYPE : Ctor
//
- CapabilityImpl::CapabilityImpl( const ResKind & refers_r )
+ CapabilityImpl::CapabilityImpl( const Resolvable::Kind & refers_r )
: _refers( refers_r )
{}
#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
{ /////////////////////////////////////////////////////////////////
DEFINE_PTR_TYPE(CapabilityImpl)
- /** \todo Check implementation */
+ /** \todo Check implementation, use base::KindOf */
typedef std::string CapKind;
///////////////////////////////////////////////////////////////////
{
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;
private:
/** */
- ResKind _refers;
+ Resolvable::Kind _refers;
};
///////////////////////////////////////////////////////////////////
{
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 )
{}
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,
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 )
public:
/** */
- const ResKind & kind() const
+ const Kind & kind() const
{ return _kind; }
/** */
const std::string & name() const
private:
/** */
- ResKind _kind;
+ Kind _kind;
/** */
std::string _name;
/** */