From d8a029200b71e5b397854e84967335bf629d9a5b Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Mon, 24 Oct 2005 18:59:20 +0000 Subject: [PATCH] capability backup --- configure.ac | 3 +- test/devel.ma/Makefile.am | 6 ++- test/devel.ma/ma_test | 2 +- test/genclass.in | 99 +++++++++++++++++++++-------------- zypp/Capability.cc | 69 +++++++++++++++++++++++++ zypp/Capability.h | 72 ++++++++++++++++++++++++++ zypp/Edition.h | 7 ++- zypp/Makefile.am | 9 +++- zypp/RelOp.h | 24 +++++++++ zypp/Resolvable.cc | 1 + zypp/ResolvableFwd.h | 26 ++++++++++ zypp/SolverContext.cc | 105 ++++++++++++++++++++++++++++++++++++++ zypp/SolverContext.h | 61 ++++++++++++++++++++++ zypp/SolverContextFwd.h | 24 +++++++++ zypp/base/PtrTypes.h | 17 ++++++ zypp/base/ReferenceCounted.h | 45 +++++++--------- zypp/capability/.cvsignore | 8 +++ zypp/capability/CapabilityImpl.cc | 49 ++++++++++++++++++ zypp/capability/CapabilityImpl.h | 56 ++++++++++++++++++++ zypp/capability/ConditionalCap.h | 45 ++++++++++++++++ zypp/capability/FileCap.h | 45 ++++++++++++++++ zypp/capability/Makefile.am | 23 +++++++++ zypp/capability/NamedCap.h | 45 ++++++++++++++++ zypp/capability/OrCap.h | 45 ++++++++++++++++ zypp/capability/VersionedCap.h | 45 ++++++++++++++++ zypp/detail/Makefile.am | 14 ++--- zypp/detail/MessageImpl.cc | 1 + zypp/detail/MessageImpl.h | 2 +- zypp/detail/PackageImpl.cc | 1 + zypp/detail/PatchImpl.cc | 1 + zypp/detail/PatchImpl.h | 1 + zypp/detail/ResolvableImpl.cc | 1 + zypp/detail/ScriptImpl.cc | 1 + zypp/detail/ScriptImpl.h | 2 +- zypp/detail/SelectionImpl.cc | 1 + 35 files changed, 878 insertions(+), 78 deletions(-) create mode 100644 zypp/Capability.cc create mode 100644 zypp/Capability.h create mode 100644 zypp/RelOp.h create mode 100644 zypp/ResolvableFwd.h create mode 100644 zypp/SolverContext.cc create mode 100644 zypp/SolverContext.h create mode 100644 zypp/SolverContextFwd.h create mode 100644 zypp/capability/.cvsignore create mode 100644 zypp/capability/CapabilityImpl.cc create mode 100644 zypp/capability/CapabilityImpl.h create mode 100644 zypp/capability/ConditionalCap.h create mode 100644 zypp/capability/FileCap.h create mode 100644 zypp/capability/Makefile.am create mode 100644 zypp/capability/NamedCap.h create mode 100644 zypp/capability/OrCap.h create mode 100644 zypp/capability/VersionedCap.h diff --git a/configure.ac b/configure.ac index ca7f1d2..63de336 100644 --- a/configure.ac +++ b/configure.ac @@ -104,7 +104,8 @@ AC_OUTPUT( \ test/devel.ma/Makefile \ zypp/Makefile \ zypp/base/Makefile \ - zypp/detail/Makefile + zypp/detail/Makefile \ + zypp/capability/Makefile ) dnl ================================================== diff --git a/test/devel.ma/Makefile.am b/test/devel.ma/Makefile.am index 8cd61ee..45abf23 100644 --- a/test/devel.ma/Makefile.am +++ b/test/devel.ma/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in ## ################################################## -noinst_PROGRAMS = Main Main.debug +noinst_PROGRAMS = Main Main.debug PtrTest ## ################################################## @@ -22,6 +22,10 @@ Main_debug_LDFLAGS = -static ## ################################################## +PtrTest_SOURCES = PtrTest.cc + +## ################################################## + .PHONY: always $(noinst_PROGRAMS): $(top_srcdir)/zypp/lib@PACKAGE@.la diff --git a/test/devel.ma/ma_test b/test/devel.ma/ma_test index 41cc3c9..021e155 100755 --- a/test/devel.ma/ma_test +++ b/test/devel.ma/ma_test @@ -29,7 +29,7 @@ else MAKE="make -j 15" fi -$MAKE -C ../zypp || exit 1 +$MAKE -C ../../zypp || exit 1 $MAKE $PRG || exit 1 ./$PRG "$@" 2> $LPIPE diff --git a/test/genclass.in b/test/genclass.in index 1e41a4e..69b539f 100644 --- a/test/genclass.in +++ b/test/genclass.in @@ -104,6 +104,13 @@ $(intro $CLASS_H) #include "zypp/base/PtrTypes.h" $(nsopen) +${INDENT}/////////////////////////////////////////////////////////////////// +${INDENT}namespace detail +${INDENT}{ ///////////////////////////////////////////////////////////////// +${INDENT} DEFINE_PTR_TYPE(${CLASS}Impl) +${INDENT} ///////////////////////////////////////////////////////////////// +${INDENT}} // namespace detail +${INDENT}/////////////////////////////////////////////////////////////////// ${INDENT}/////////////////////////////////////////////////////////////////// ${INDENT}// @@ -115,21 +122,24 @@ ${INDENT}{ ${INDENT}public: ${INDENT} /** Default ctor */ ${INDENT} ${CLASS}(); - +${INDENT} /** Factory ctor */ +${INDENT} explicit +${INDENT} ${CLASS}( detail::${CLASS}ImplPtr impl_r ); ${INDENT} /** Dtor */ ${INDENT} ~${CLASS}(); -${INDENT} /** Stream output */ -${INDENT} friend std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj ); - ${INDENT}private: -${INDENT} /** Hides implementation */ -${INDENT} struct Impl; ${INDENT} /** Pointer to implementation */ -${INDENT} base::shared_ptr _pimpl; +${INDENT} detail::${CLASS}ImplPtr _pimpl; +${INDENT}public: +${INDENT} /** Avoid a bunch of friend decl. */ +${INDENT} detail::const${CLASS}ImplPtr sayFriend() const; ${INDENT}}; ${INDENT}/////////////////////////////////////////////////////////////////// +${INDENT}/** \relates ${CLASS} Stream output */ +${INDENT}extern std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj ); + $(nsclose) #endif // $INCLUDE_DEF EOF @@ -142,8 +152,8 @@ cat < -#include "zypp/base/Logger.h" -#include "zypp/base/BaseTypes.h" +#include "zypp/base/ReferenceCounted.h" +#include "zypp/base/NonCopyable.h" #include "${INCLUDE_H}" using namespace std; @@ -151,35 +161,33 @@ using namespace std; $(nsopen) ${INDENT}/////////////////////////////////////////////////////////////////// -${INDENT}// -${INDENT}// CLASS NAME : ${CLASS}::Impl -${INDENT}// -${INDENT}/** ${CLASS} implementation */ -${INDENT}struct ${CLASS}::Impl : private zypp::base::noncopyable -${INDENT}{ -${INDENT} /** Default ctor*/ -${INDENT} Impl(); - -${INDENT} /** Dtor */ -${INDENT} ~Impl(); - -${INDENT} /** Stream output */ -${INDENT} friend std::ostream & operator<<( std::ostream & str, const Impl & obj ); - -${INDENT}}; +${INDENT}namespace detail +${INDENT}{ ///////////////////////////////////////////////////////////////// + +${INDENT} /////////////////////////////////////////////////////////////////// +${INDENT} // +${INDENT} // CLASS NAME : ${CLASS}Impl +${INDENT} // +${INDENT} /** ${CLASS} implementation */ +${INDENT} struct ${CLASS}Impl : public base::ReferenceCounted, private base::NonCopyable +${INDENT} { +${INDENT} /** Default ctor*/ +${INDENT} ${CLASS}Impl(); +${INDENT} /** Dtor */ +${INDENT} ~${CLASS}Impl(); +${INDENT} }; +${INDENT} /////////////////////////////////////////////////////////////////// + +${INDENT} /** \relates ${CLASS}Impl Stream output */ +${INDENT} inline std::ostream & operator<<( std::ostream & str, const ${CLASS}Impl & obj ) +${INDENT} { +${INDENT} return str << "${CLASS}Impl"; +${INDENT} } + +${INDENT} ///////////////////////////////////////////////////////////////// +${INDENT}} // namespace detail ${INDENT}/////////////////////////////////////////////////////////////////// -${INDENT}/****************************************************************** -${INDENT}** -${INDENT}** FUNCTION NAME : operator<< -${INDENT}** FUNCTION TYPE : std::ostream & -${INDENT}*/ -${INDENT}std::ostream & operator<<( std::ostream & str, const ${CLASS}::Impl & obj ) -${INDENT}{ -${INDENT} return str << "${CLASS}::Impl"; -${INDENT}} - - ${INDENT}/////////////////////////////////////////////////////////////////// ${INDENT}// ${INDENT}// CLASS NAME : ${CLASS} @@ -196,12 +204,29 @@ ${INDENT}{} ${INDENT}/////////////////////////////////////////////////////////////////// ${INDENT}// +${INDENT}// METHOD NAME : ${CLASS}::${CLASS} +${INDENT}// METHOD TYPE : Ctor +${INDENT}// +${INDENT}${CLASS}::${CLASS}( detail::${CLASS}ImplPtr impl_r ) +${INDENT}: _pimpl( impl_r ) +${INDENT}{} + +${INDENT}/////////////////////////////////////////////////////////////////// +${INDENT}// ${INDENT}// METHOD NAME : ${CLASS}::~${CLASS} ${INDENT}// METHOD TYPE : Dtor ${INDENT}// ${INDENT}${CLASS}::~${CLASS}() ${INDENT}{} +${INDENT}/////////////////////////////////////////////////////////////////// +${INDENT}// +${INDENT}// METHOD NAME : ${CLASS}::sayFriend +${INDENT}// METHOD TYPE : detail::const${CLASS}ImplPtr +${INDENT}// +${INDENT}detail::const${CLASS}ImplPtr ${CLASS}::sayFriend() const +${INDENT}{ return _pimpl; } + ${INDENT}/****************************************************************** ${INDENT}** ${INDENT}** FUNCTION NAME : operator<< @@ -209,7 +234,7 @@ ${INDENT}** FUNCTION TYPE : std::ostream & ${INDENT}*/ ${INDENT}std::ostream & operator<<( std::ostream & str, const ${CLASS} & obj ) ${INDENT}{ -${INDENT} return str << obj._pimpl; +${INDENT} return str << *obj.sayFriend(); ${INDENT}} $(nsclose) diff --git a/zypp/Capability.cc b/zypp/Capability.cc new file mode 100644 index 0000000..7b44072 --- /dev/null +++ b/zypp/Capability.cc @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/Capability.cc + * +*/ +#include + +#include "zypp/Capability.h" +#include "zypp/capability/CapabilityImpl.h" + +#include "zypp/SolverContext.h" + +using namespace std; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : Capability::Capability + // METHOD TYPE : Ctor + // + Capability::Capability( ImplPtr impl_r ) + : _pimpl( impl_r ) + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : Capability::~Capability + // METHOD TYPE : Dtor + // + Capability::~Capability() + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : Capability::sayFriend + // METHOD TYPE : capability::constCapabilityImplPtr + // + Capability::constImplPtr Capability::sayFriend() const + { return _pimpl; } + + bool Capability::matches( constResolvablePtr resolvable_r, + const SolverContext & solverContext_r ) + { return _pimpl->matches( resolvable_r, solverContext_r ); } + + bool Capability::matches( constResolvablePtr resolvable_r ) + { return _pimpl->matches( resolvable_r, SolverContext() ); } + + /****************************************************************** + ** + ** FUNCTION NAME : operator<< + ** FUNCTION TYPE : std::ostream & + */ + std::ostream & operator<<( std::ostream & str, const Capability & obj ) + { + return str << *obj.sayFriend(); + } + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/Capability.h b/zypp/Capability.h new file mode 100644 index 0000000..f958259 --- /dev/null +++ b/zypp/Capability.h @@ -0,0 +1,72 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/Capability.h + * +*/ +#ifndef ZYPP_CAPABILITY_H +#define ZYPP_CAPABILITY_H + +#include + +#include "zypp/base/PtrTypes.h" + +#include "zypp/ResolvableFwd.h" +#include "zypp/SolverContextFwd.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + DEFINE_PTR_TYPE(CapabilityImpl); + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : Capability + // + /** */ + class Capability + { + typedef capability::CapabilityImplPtr ImplPtr; + typedef capability::constCapabilityImplPtr constImplPtr; + + public: + /** Factory ctor */ + explicit + Capability( ImplPtr impl_r ); + /** Dtor */ + virtual ~Capability(); + + public: + /** */ + bool matches( constResolvablePtr resolvable_r, + const SolverContext & colverContext_r ); + /** */ + bool matches( constResolvablePtr resolvable_r ); + + private: + /** Pointer to implementation */ + ImplPtr _pimpl; + public: + /** Avoid a bunch of friend decl. */ + constImplPtr sayFriend() const; + }; + /////////////////////////////////////////////////////////////////// + + /** \relates Capability Stream output */ + extern std::ostream & operator<<( std::ostream & str, const Capability & obj ); + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_CAPABILITY_H diff --git a/zypp/Edition.h b/zypp/Edition.h index 57fb66f..1ba5894 100644 --- a/zypp/Edition.h +++ b/zypp/Edition.h @@ -16,6 +16,7 @@ #include #include "zypp/base/PtrTypes.h" +#include "zypp/RelOp.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -29,7 +30,9 @@ namespace zypp class Edition { public: + /** */ typedef unsigned epoch_t; + public: /** Default ctor */ Edition(); @@ -39,6 +42,7 @@ namespace zypp epoch_t epoch = 0 ); /** Dtor */ ~Edition(); + public: /** */ epoch_t epoch() const; @@ -46,6 +50,7 @@ namespace zypp const std::string & version() const; /** */ const std::string & release() const; + private: /** Hides implementation */ struct Impl; @@ -54,7 +59,7 @@ namespace zypp }; /////////////////////////////////////////////////////////////////// - /** \relates ResEdition Stream output */ + /** \relates Edition Stream output */ extern std::ostream & operator<<( std::ostream & str, const Edition & obj ); ///////////////////////////////////////////////////////////////// diff --git a/zypp/Makefile.am b/zypp/Makefile.am index c39e7a0..3e813c3 100644 --- a/zypp/Makefile.am +++ b/zypp/Makefile.am @@ -1,12 +1,13 @@ ## Process this file with automake to produce Makefile.in ## ################################################## -SUBDIRS = base detail +SUBDIRS = base detail capability ## ################################################## include_HEADERS = \ Arch.h \ + Capability.h \ Edition.h \ ResKind.h \ Resolvable.h \ @@ -14,6 +15,7 @@ include_HEADERS = \ Selection.h \ Message.h \ Script.h \ + SolverContext.h \ Patch.h ## ################################################## @@ -24,6 +26,7 @@ lib_LTLIBRARIES = lib@PACKAGE@.la lib@PACKAGE@_la_SOURCES = \ Arch.cc \ + Capability.cc \ Edition.cc \ ResKind.cc \ Resolvable.cc \ @@ -31,11 +34,13 @@ lib@PACKAGE@_la_SOURCES = \ Selection.cc \ Message.cc \ Script.cc \ + SolverContext.cc\ Patch.cc lib@PACKAGE@_la_LDFLAGS = @LIB_VERSION_INFO@ lib@PACKAGE@_la_LIBADD = base/lib@PACKAGE@_base.la \ - detail/lib@PACKAGE@_detail.la + detail/lib@PACKAGE@_detail.la \ + capability/lib@PACKAGE@_capability.la ## ################################################## diff --git a/zypp/RelOp.h b/zypp/RelOp.h new file mode 100644 index 0000000..daae2ff --- /dev/null +++ b/zypp/RelOp.h @@ -0,0 +1,24 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/RelOp.h + * +*/ +#ifndef ZYPP_RELOP_H +#define ZYPP_RELOP_H + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + enum RelOp { ANY, EQ, NE, LT, LE, GT, GE, NONE }; + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_RELOP_H diff --git a/zypp/Resolvable.cc b/zypp/Resolvable.cc index e7271d6..a2eaf8f 100644 --- a/zypp/Resolvable.cc +++ b/zypp/Resolvable.cc @@ -17,6 +17,7 @@ using namespace std; /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(Resolvable) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/ResolvableFwd.h b/zypp/ResolvableFwd.h new file mode 100644 index 0000000..c1ad9f9 --- /dev/null +++ b/zypp/ResolvableFwd.h @@ -0,0 +1,26 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/ResolvableFwd.h + * +*/ +#ifndef ZYPP_RESOLVABLEFWD_H +#define ZYPP_RESOLVABLEFWD_H + +#include "zypp/base/PtrTypes.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + DEFINE_PTR_TYPE(Resolvable) + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_RESOLVABLEFWD_H diff --git a/zypp/SolverContext.cc b/zypp/SolverContext.cc new file mode 100644 index 0000000..7d97df8 --- /dev/null +++ b/zypp/SolverContext.cc @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/SolverContext.cc + * +*/ +#include + +#include "zypp/base/ReferenceCounted.h" +#include "zypp/base/NonCopyable.h" +#include "zypp/SolverContext.h" + +using namespace std; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + namespace detail + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : SolverContextImpl + // + /** SolverContext implementation */ + struct SolverContextImpl : public base::ReferenceCounted, private base::NonCopyable + { + /** Default ctor*/ + SolverContextImpl(); + /** Dtor */ + ~SolverContextImpl(); + }; + /////////////////////////////////////////////////////////////////// + + IMPL_PTR_TYPE(SolverContextImpl) + + /** \relates SolverContextImpl Stream output */ + inline std::ostream & operator<<( std::ostream & str, const SolverContextImpl & obj ) + { + return str << "SolverContextImpl"; + } + + ///////////////////////////////////////////////////////////////// + } // namespace detail + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : SolverContext + // + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : SolverContext::SolverContext + // METHOD TYPE : Ctor + // + SolverContext::SolverContext() + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : SolverContext::SolverContext + // METHOD TYPE : Ctor + // + SolverContext::SolverContext( detail::SolverContextImplPtr impl_r ) + : _pimpl( impl_r ) + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : SolverContext::~SolverContext + // METHOD TYPE : Dtor + // + SolverContext::~SolverContext() + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : SolverContext::sayFriend + // METHOD TYPE : detail::constSolverContextImplPtr + // + detail::constSolverContextImplPtr SolverContext::sayFriend() const + { return _pimpl; } + + /****************************************************************** + ** + ** FUNCTION NAME : operator<< + ** FUNCTION TYPE : std::ostream & + */ + std::ostream & operator<<( std::ostream & str, const SolverContext & obj ) + { + return str << *obj.sayFriend(); + } + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/SolverContext.h b/zypp/SolverContext.h new file mode 100644 index 0000000..36a5bba --- /dev/null +++ b/zypp/SolverContext.h @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/SolverContext.h + * +*/ +#ifndef ZYPP_SOLVERCONTEXT_H +#define ZYPP_SOLVERCONTEXT_H + +#include + +#include "zypp/base/PtrTypes.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace detail + { ///////////////////////////////////////////////////////////////// + DEFINE_PTR_TYPE(SolverContextImpl) + ///////////////////////////////////////////////////////////////// + } // namespace detail + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : SolverContext + // + /** */ + class SolverContext + { + public: + /** Default ctor */ + SolverContext(); + /** Factory ctor */ + explicit + SolverContext( detail::SolverContextImplPtr impl_r ); + /** Dtor */ + ~SolverContext(); + + private: + /** Pointer to implementation */ + detail::SolverContextImplPtr _pimpl; + public: + /** Avoid a bunch of friend decl. */ + detail::constSolverContextImplPtr sayFriend() const; + }; + /////////////////////////////////////////////////////////////////// + + /** \relates SolverContext Stream output */ + extern std::ostream & operator<<( std::ostream & str, const SolverContext & obj ); + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_SOLVERCONTEXT_H diff --git a/zypp/SolverContextFwd.h b/zypp/SolverContextFwd.h new file mode 100644 index 0000000..aaa9c91 --- /dev/null +++ b/zypp/SolverContextFwd.h @@ -0,0 +1,24 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/SolverContextFwd.h + * +*/ +#ifndef ZYPP_SOLVERCONTEXTFWD_H +#define ZYPP_SOLVERCONTEXTFWD_H + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + class SolverContext; + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_SOLVERCONTEXTFWD_H diff --git a/zypp/base/PtrTypes.h b/zypp/base/PtrTypes.h index 8f339ec..1e526f2 100644 --- a/zypp/base/PtrTypes.h +++ b/zypp/base/PtrTypes.h @@ -16,6 +16,7 @@ #include #include #include +#include /////////////////////////////////////////////////////////////////// namespace zypp @@ -47,6 +48,12 @@ namespace zypp /** */ using boost::weak_ptr; + /** 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; + /*@}*/ ///////////////////////////////////////////////////////////////// @@ -55,4 +62,14 @@ namespace zypp ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// + +/** Forward declaration of Ptr types */ +#define DEFINE_PTR_TYPE(NAME) \ +class NAME; \ +extern void intrusive_ptr_add_ref( const NAME * ); \ +extern void intrusive_ptr_release( const NAME * ); \ +typedef zypp::base::intrusive_ptr NAME##Ptr; \ +typedef zypp::base::intrusive_ptr const##NAME##Ptr; + +/////////////////////////////////////////////////////////////////// #endif // ZYPP_BASE_PTRTYPES_H diff --git a/zypp/base/ReferenceCounted.h b/zypp/base/ReferenceCounted.h index 6eec4b5..210db2c 100644 --- a/zypp/base/ReferenceCounted.h +++ b/zypp/base/ReferenceCounted.h @@ -13,7 +13,8 @@ #define ZYPP_BASE_REFERENCECOUNTED_H #include -#include + +#include "zypp/base/PtrTypes.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -77,32 +78,24 @@ namespace zypp delete this; } + /** Called by zypp::base::intrusive_ptr to add a reference. + * \see ZYPP_BASE_SMART_PTR + */ + static void add_ref( const ReferenceCounted * ptr_r ) + { if( ptr_r ) ptr_r->ref(); } + + /** Called by zypp::base::intrusive_ptr to add a reference. + * \see ZYPP_BASE_SMART_PTR + */ + static void release( const ReferenceCounted * ptr_r ) + { if( ptr_r ) ptr_r->unref(); } + 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 /////////////////////////////////////////////////////////////////// @@ -110,11 +103,11 @@ namespace zypp } // namespace zypp /////////////////////////////////////////////////////////////////// -/** Forward declaration of Ptr types */ -#define DEFINE_PTR_TYPE(NAME) \ -class NAME; \ -typedef zypp::base::intrusive_ptr NAME##Ptr; \ -typedef zypp::base::intrusive_ptr const##NAME##Ptr; +#define IMPL_PTR_TYPE(NAME) \ +void intrusive_ptr_add_ref( const NAME * ptr_r ) \ +{ zypp::base::ReferenceCounted::add_ref( ptr_r ); } \ +void intrusive_ptr_release( const NAME * ptr_r ) \ +{ zypp::base::ReferenceCounted::release( ptr_r ); } /////////////////////////////////////////////////////////////////// #endif // ZYPP_BASE_REFERENCECOUNTED_H diff --git a/zypp/capability/.cvsignore b/zypp/capability/.cvsignore new file mode 100644 index 0000000..5c94a2f --- /dev/null +++ b/zypp/capability/.cvsignore @@ -0,0 +1,8 @@ +Makefile.in +Makefile +.deps +.libs +*.o +*.lo +*.a +*.la diff --git a/zypp/capability/CapabilityImpl.cc b/zypp/capability/CapabilityImpl.cc new file mode 100644 index 0000000..717579d --- /dev/null +++ b/zypp/capability/CapabilityImpl.cc @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/CapabilityImpl.cc + * +*/ +#include + +#include "zypp/capability/CapabilityImpl.h" + +using namespace std; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(CapabilityImpl) + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : CapabilityImpl::~CapabilityImpl + // METHOD TYPE : Dtor + // + CapabilityImpl::~CapabilityImpl() + {} + + /****************************************************************** + ** + ** FUNCTION NAME : operator<< + ** FUNCTION TYPE : std::ostream & + */ + std::ostream & operator<<( std::ostream & str, const CapabilityImpl & obj ) + { + return str << "CapabilityImpl"; + } + + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/capability/CapabilityImpl.h b/zypp/capability/CapabilityImpl.h new file mode 100644 index 0000000..4ce5207 --- /dev/null +++ b/zypp/capability/CapabilityImpl.h @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/CapabilityImpl.h + * +*/ +#ifndef ZYPP_CAPABILITY_CAPABILITYIMPL_H +#define ZYPP_CAPABILITY_CAPABILITYIMPL_H + +#include "zypp/base/ReferenceCounted.h" +#include "zypp/base/NonCopyable.h" + +#include "zypp/ResolvableFwd.h" +#include "zypp/SolverContextFwd.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + DEFINE_PTR_TYPE(CapabilityImpl) + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : CapabilityImpl + // + /** */ + class CapabilityImpl : public base::ReferenceCounted, private base::NonCopyable + { + public: + /** Dtor */ + virtual ~CapabilityImpl(); + + public: + /** */ + virtual bool matches( constResolvablePtr resolvable_r, + const SolverContext & colverContext_r ) = 0; + }; + /////////////////////////////////////////////////////////////////// + + /** \relates CapabilityImpl Stream output */ + extern std::ostream & operator<<( std::ostream & str, const CapabilityImpl & obj ); + + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_CAPABILITY_CAPABILITYIMPL_H diff --git a/zypp/capability/ConditionalCap.h b/zypp/capability/ConditionalCap.h new file mode 100644 index 0000000..fd2c5d3 --- /dev/null +++ b/zypp/capability/ConditionalCap.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/ConditionalCap.h + * +*/ +#ifndef ZYPP_CAPABILITY_CONDITIONALCAP_H +#define ZYPP_CAPABILITY_CONDITIONALCAP_H + +#include "zypp/capability/CapabilityImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : ConditionalCap + // + /** */ + class ConditionalCap : public CapabilityImpl + { + public: + /** */ + bool matches( constResolvablePtr resolvable_r, + const SolverContext & colverContext_r ) + { return false; } + }; + /////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_CAPABILITY_CONDITIONALCAP_H diff --git a/zypp/capability/FileCap.h b/zypp/capability/FileCap.h new file mode 100644 index 0000000..d93ef24 --- /dev/null +++ b/zypp/capability/FileCap.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/FileCap.h + * +*/ +#ifndef ZYPP_CAPABILITY_FILECAP_H +#define ZYPP_CAPABILITY_FILECAP_H + +#include "zypp/capability/CapabilityImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : FileCap + // + /** */ + class FileCap : public CapabilityImpl + { + public: + /** */ + bool matches( constResolvablePtr resolvable_r, + const SolverContext & colverContext_r ) + { return false; } + }; + /////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_CAPABILITY_FILECAP_H diff --git a/zypp/capability/Makefile.am b/zypp/capability/Makefile.am new file mode 100644 index 0000000..1c32124 --- /dev/null +++ b/zypp/capability/Makefile.am @@ -0,0 +1,23 @@ +## Process this file with automake to produce Makefile.in +## ################################################## + +SUBDIRS = + +## ################################################## + +include_HEADERS = CapabilityImpl.h \ + \ + ConditionalCap.h\ + FileCap.h \ + NamedCap.h \ + OrCap.h \ + VersionedCap.h + +noinst_LTLIBRARIES = lib@PACKAGE@_capability.la + +## ################################################## + +lib@PACKAGE@_capability_la_SOURCES = \ + CapabilityImpl.cc + +## ################################################## diff --git a/zypp/capability/NamedCap.h b/zypp/capability/NamedCap.h new file mode 100644 index 0000000..69bb109 --- /dev/null +++ b/zypp/capability/NamedCap.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/NamedCap.h + * +*/ +#ifndef ZYPP_CAPABILITY_NAMEDCAP_H +#define ZYPP_CAPABILITY_NAMEDCAP_H + +#include "zypp/capability/CapabilityImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : NamedCap + // + /** */ + class NamedCap : public CapabilityImpl + { + public: + /** */ + bool matches( constResolvablePtr resolvable_r, + const SolverContext & colverContext_r ) + { return false; } + }; + /////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_CAPABILITY_NAMEDCAP_H diff --git a/zypp/capability/OrCap.h b/zypp/capability/OrCap.h new file mode 100644 index 0000000..c7c72f1 --- /dev/null +++ b/zypp/capability/OrCap.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/OrCap.h + * +*/ +#ifndef ZYPP_CAPABILITY_ORCAP_H +#define ZYPP_CAPABILITY_ORCAP_H + +#include "zypp/capability/CapabilityImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : OrCap + // + /** */ + class OrCap : public CapabilityImpl + { + public: + /** */ + bool matches( constResolvablePtr resolvable_r, + const SolverContext & colverContext_r ) + { return false; } + }; + /////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_CAPABILITY_ORCAP_H diff --git a/zypp/capability/VersionedCap.h b/zypp/capability/VersionedCap.h new file mode 100644 index 0000000..689fe7c --- /dev/null +++ b/zypp/capability/VersionedCap.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/VersionedCap.h + * +*/ +#ifndef ZYPP_CAPABILITY_VERSIONEDCAP_H +#define ZYPP_CAPABILITY_VERSIONEDCAP_H + +#include "zypp/capability/CapabilityImpl.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : VersionedCap + // + /** */ + class VersionedCap : public CapabilityImpl + { + public: + /** */ + bool matches( constResolvablePtr resolvable_r, + const SolverContext & colverContext_r ) + { return false; } + }; + /////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_CAPABILITY_VERSIONEDCAP_H diff --git a/zypp/detail/Makefile.am b/zypp/detail/Makefile.am index c831963..3175dd9 100644 --- a/zypp/detail/Makefile.am +++ b/zypp/detail/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = ## ################################################## -include_HEADERS = \ +include_HEADERS = \ ResolvableImpl.h \ PackageImpl.h \ SelectionImpl.h \ @@ -18,12 +18,12 @@ noinst_LTLIBRARIES = lib@PACKAGE@_detail.la ## ################################################## -lib@PACKAGE@_detail_la_SOURCES = \ - ResolvableImpl.cc \ - PackageImpl.cc \ - SelectionImpl.cc \ - MessageImpl.cc \ - ScriptImpl.cc \ +lib@PACKAGE@_detail_la_SOURCES = \ + ResolvableImpl.cc \ + PackageImpl.cc \ + SelectionImpl.cc \ + MessageImpl.cc \ + ScriptImpl.cc \ PatchImpl.cc ## ################################################## diff --git a/zypp/detail/MessageImpl.cc b/zypp/detail/MessageImpl.cc index 5c3c44a..60097f8 100644 --- a/zypp/detail/MessageImpl.cc +++ b/zypp/detail/MessageImpl.cc @@ -23,6 +23,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(MessageImpl) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/detail/MessageImpl.h b/zypp/detail/MessageImpl.h index 54ef739..8b3d39f 100644 --- a/zypp/detail/MessageImpl.h +++ b/zypp/detail/MessageImpl.h @@ -24,7 +24,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// - + DEFINE_PTR_TYPE(MessageImpl) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/detail/PackageImpl.cc b/zypp/detail/PackageImpl.cc index 43e0fb1..77cfef8 100644 --- a/zypp/detail/PackageImpl.cc +++ b/zypp/detail/PackageImpl.cc @@ -21,6 +21,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(PackageImpl) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/detail/PatchImpl.cc b/zypp/detail/PatchImpl.cc index 38e25e3..c0881d2 100644 --- a/zypp/detail/PatchImpl.cc +++ b/zypp/detail/PatchImpl.cc @@ -24,6 +24,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(PatchImpl) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/detail/PatchImpl.h b/zypp/detail/PatchImpl.h index a25786b..5afe5de 100644 --- a/zypp/detail/PatchImpl.h +++ b/zypp/detail/PatchImpl.h @@ -25,6 +25,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// + DEFINE_PTR_TYPE(PatchImpl) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/detail/ResolvableImpl.cc b/zypp/detail/ResolvableImpl.cc index a63590f..934b1ca 100644 --- a/zypp/detail/ResolvableImpl.cc +++ b/zypp/detail/ResolvableImpl.cc @@ -21,6 +21,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(ResolvableImpl) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/detail/ScriptImpl.cc b/zypp/detail/ScriptImpl.cc index e65425b..6912786 100644 --- a/zypp/detail/ScriptImpl.cc +++ b/zypp/detail/ScriptImpl.cc @@ -23,6 +23,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(ScriptImpl) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/detail/ScriptImpl.h b/zypp/detail/ScriptImpl.h index d127eb3..74d8d67 100644 --- a/zypp/detail/ScriptImpl.h +++ b/zypp/detail/ScriptImpl.h @@ -24,7 +24,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// - + DEFINE_PTR_TYPE(ScriptImpl) /////////////////////////////////////////////////////////////////// // diff --git a/zypp/detail/SelectionImpl.cc b/zypp/detail/SelectionImpl.cc index 3bc3a2c..1b9edc9 100644 --- a/zypp/detail/SelectionImpl.cc +++ b/zypp/detail/SelectionImpl.cc @@ -21,6 +21,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// + IMPL_PTR_TYPE(SelectionImpl) /////////////////////////////////////////////////////////////////// // -- 2.7.4