From d617d5210974f0e0ae9c9db1c744477be365039f Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Tue, 25 Oct 2005 21:48:23 +0000 Subject: [PATCH] backup --- test/devel.ma/Main.cc | 5 +++-- test/devel.ma/Makefile.am | 2 +- test/devel.ma/main.cc | 10 ++++++++++ test/devel.ma/main.h | 12 ++++++++++++ zypp/CapFactory.cc | 33 ++++++++++++++++++++++++++++++--- zypp/CapFactory.h | 10 +++++++--- zypp/Capability.cc | 10 ++++++++-- zypp/Capability.h | 12 +++++++++--- zypp/Resolvable.h | 7 ++----- zypp/ResolvableFwd.h | 5 +++++ zypp/base/PtrTypes.h | 4 ++++ zypp/capability/Capabilities.h | 18 ++++++++++++++++++ zypp/capability/CapabilityImpl.cc | 9 +++++---- zypp/capability/CapabilityImpl.h | 21 ++++++++++++++++++--- zypp/capability/Makefile.am | 8 ++++++-- zypp/capability/NamedCap.cc | 30 ++++++++++++++++++++++++++++++ zypp/capability/NamedCap.h | 21 +++++++++++++++++++-- 17 files changed, 187 insertions(+), 30 deletions(-) create mode 100644 test/devel.ma/main.cc create mode 100644 test/devel.ma/main.h create mode 100644 zypp/capability/Capabilities.h create mode 100644 zypp/capability/NamedCap.cc diff --git a/test/devel.ma/Main.cc b/test/devel.ma/Main.cc index cb62515..24242ae 100644 --- a/test/devel.ma/Main.cc +++ b/test/devel.ma/Main.cc @@ -7,6 +7,7 @@ #include #include #include +#include "main.h" #define TAG INT << __PRETTY_FUNCTION__ << std::endl @@ -16,7 +17,7 @@ namespace zypp using namespace std; using namespace zypp; - +#include /****************************************************************** ** ** @@ -30,7 +31,7 @@ struct CapSetInsert : public std::unary_function { CapFactory _f; CapSetInsert( CapSet & x ) : _x(x) {} void operator()( const char * v ) - { _x.insert( _f.parse( v ) ); } + { _x.insert( _f.parse( ResKind(), v ) ); } }; int main( int argc, char * argv[] ) diff --git a/test/devel.ma/Makefile.am b/test/devel.ma/Makefile.am index 45abf23..bcfa335 100644 --- a/test/devel.ma/Makefile.am +++ b/test/devel.ma/Makefile.am @@ -15,7 +15,7 @@ LDADD = $(top_srcdir)/zypp/lib@PACKAGE@.la ## ################################################## -Main_SOURCES = Main.cc +Main_SOURCES = Main.cc main.cc Main_debug_SOURCES = $(Main_SOURCES) Main_debug_LDFLAGS = -static diff --git a/test/devel.ma/main.cc b/test/devel.ma/main.cc new file mode 100644 index 0000000..da9fc74 --- /dev/null +++ b/test/devel.ma/main.cc @@ -0,0 +1,10 @@ +#include "main.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/test/devel.ma/main.h b/test/devel.ma/main.h new file mode 100644 index 0000000..bdf60c7 --- /dev/null +++ b/test/devel.ma/main.h @@ -0,0 +1,12 @@ +#ifndef main_h +#define main_h + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // main_h diff --git a/zypp/CapFactory.cc b/zypp/CapFactory.cc index 26c05e0..95613ae 100644 --- a/zypp/CapFactory.cc +++ b/zypp/CapFactory.cc @@ -10,16 +10,40 @@ * */ #include +#include +#include #include "zypp/base/ReferenceCounted.h" #include "zypp/base/NonCopyable.h" #include "zypp/CapFactory.h" -#include "zypp/capability/FileCap.h" +#include "zypp/capability/Capabilities.h" using namespace std; /////////////////////////////////////////////////////////////////// +namespace +{ ///////////////////////////////////////////////////////////////// + + typedef zypp::capability::CapabilityImplPtr CapabilityImplPtr; + + /** \todo check set ordering to assert no dups */ + struct USetOrder : public std::binary_function + { + bool operator()( const CapabilityImplPtr & lhs, + const CapabilityImplPtr & rhs ) const + { return lhs->asString() < rhs->asString(); } + }; + + typedef std::set USet; + + USet _uset; + + ///////////////////////////////////////////////////////////////// +} // namespace +/////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// @@ -97,10 +121,13 @@ namespace zypp // METHOD NAME : CapFactory::parse // METHOD TYPE : Capability // - Capability CapFactory::parse( const std::string & strval_r ) const + /** \todo fix it */ + Capability CapFactory::parse( const ResKind & refers_r, const std::string & strval_r ) const { // fix - return Capability( new capability::FileCap ); + CapabilityImplPtr newcap( new capability::NamedCap( refers_r, strval_r ) ); + USet::iterator in( _uset.insert( newcap ).first ); + return Capability( *in ); } /****************************************************************** diff --git a/zypp/CapFactory.h b/zypp/CapFactory.h index 5ae3d24..849d833 100644 --- a/zypp/CapFactory.h +++ b/zypp/CapFactory.h @@ -46,9 +46,13 @@ namespace zypp ~CapFactory(); public: - /** */ - Capability parse( const std::string & strval_r ) const; - + /** */ + Capability parse( const ResKind & refers_r, const std::string & strval_r ) const; + /* + template + Capability parse( const std::string & strval_r ) const + { return parse( _Res::kind(), strval_r ); } + */ private: /** Pointer to implementation */ detail::CapFactoryImplPtr _pimpl; diff --git a/zypp/Capability.cc b/zypp/Capability.cc index 7b44072..ccf554f 100644 --- a/zypp/Capability.cc +++ b/zypp/Capability.cc @@ -47,11 +47,17 @@ namespace zypp Capability::constImplPtr Capability::sayFriend() const { return _pimpl; } + const ResKind & Capability::refers() const + { return _pimpl->refers(); } + + std::string Capability::asString() const + { return _pimpl->asString(); } + bool Capability::matches( constResolvablePtr resolvable_r, - const SolverContext & solverContext_r ) + const SolverContext & solverContext_r ) const { return _pimpl->matches( resolvable_r, solverContext_r ); } - bool Capability::matches( constResolvablePtr resolvable_r ) + bool Capability::matches( constResolvablePtr resolvable_r ) const { return _pimpl->matches( resolvable_r, SolverContext() ); } /****************************************************************** diff --git a/zypp/Capability.h b/zypp/Capability.h index 3a12a42..b206a0b 100644 --- a/zypp/Capability.h +++ b/zypp/Capability.h @@ -36,7 +36,9 @@ namespace zypp // // CLASS NAME : Capability // - /** */ + /** Resolvable capabilitiy. + * \invariant Nonzero \c _pimpl + */ class Capability { private: @@ -54,10 +56,14 @@ namespace zypp public: /** */ + const ResKind & refers() const; + /** */ + std::string asString() const; + /** */ bool matches( constResolvablePtr resolvable_r, - const SolverContext & colverContext_r ); + const SolverContext & colverContext_r ) const; /** */ - bool matches( constResolvablePtr resolvable_r ); + bool matches( constResolvablePtr resolvable_r ) const; private: /** Pointer to implementation */ diff --git a/zypp/Resolvable.h b/zypp/Resolvable.h index cbece41..80f7c51 100644 --- a/zypp/Resolvable.h +++ b/zypp/Resolvable.h @@ -18,6 +18,8 @@ #include "zypp/base/ReferenceCounted.h" #include "zypp/base/NonCopyable.h" +#include "zypp/ResolvableFwd.h" + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// @@ -28,11 +30,6 @@ namespace zypp ///////////////////////////////////////////////////////////////// } // namespace detail /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(Resolvable) - - class ResKind; - class Edition; - class Arch; /////////////////////////////////////////////////////////////////// // diff --git a/zypp/ResolvableFwd.h b/zypp/ResolvableFwd.h index c1ad9f9..6518a38 100644 --- a/zypp/ResolvableFwd.h +++ b/zypp/ResolvableFwd.h @@ -18,6 +18,11 @@ namespace zypp { ///////////////////////////////////////////////////////////////// + class ResKind; + class Edition; + class Arch; + class Capability; + DEFINE_PTR_TYPE(Resolvable) ///////////////////////////////////////////////////////////////// diff --git a/zypp/base/PtrTypes.h b/zypp/base/PtrTypes.h index 1e526f2..6b82543 100644 --- a/zypp/base/PtrTypes.h +++ b/zypp/base/PtrTypes.h @@ -36,6 +36,10 @@ namespace zypp * \li \c shared_ptr Object ownership shared among multiple pointers * * \li \c weak_ptr Non-owning observers of an object owned by shared_ptr. + * + * \todo Intrusive Ptr class which supports constness. Used as PIMPL. + * Offers 'const Impl *' in const context, otherwise 'Impl *'. to + * prevent const classes from calling nonconst Impl methods. */ /*@{*/ diff --git a/zypp/capability/Capabilities.h b/zypp/capability/Capabilities.h new file mode 100644 index 0000000..0a4dfde --- /dev/null +++ b/zypp/capability/Capabilities.h @@ -0,0 +1,18 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/Capabilities.h + * +*/ +#ifndef ZYPP_CAPABILITY_CAPABILITIES_H +#define ZYPP_CAPABILITY_CAPABILITIES_H + +#include "zypp/capability/CapabilityImpl.h" +#include "zypp/capability/NamedCap.h" + +#endif // ZYPP_CAPABILITY_CAPABILITIES_H diff --git a/zypp/capability/CapabilityImpl.cc b/zypp/capability/CapabilityImpl.cc index 717579d..cd04c9f 100644 --- a/zypp/capability/CapabilityImpl.cc +++ b/zypp/capability/CapabilityImpl.cc @@ -25,10 +25,11 @@ namespace zypp /////////////////////////////////////////////////////////////////// // - // METHOD NAME : CapabilityImpl::~CapabilityImpl - // METHOD TYPE : Dtor + // METHOD NAME : CapabilityImpl::CapabilityImpl + // METHOD TYPE : Ctor // - CapabilityImpl::~CapabilityImpl() + CapabilityImpl::CapabilityImpl( const ResKind & refers_r ) + : _refers( refers_r ) {} /****************************************************************** @@ -38,7 +39,7 @@ namespace zypp */ std::ostream & operator<<( std::ostream & str, const CapabilityImpl & obj ) { - return str << "CapabilityImpl"; + return str << '[' << obj.refers() << "] " << obj.asString(); } ///////////////////////////////////////////////////////////////// diff --git a/zypp/capability/CapabilityImpl.h b/zypp/capability/CapabilityImpl.h index 4ce5207..933944b 100644 --- a/zypp/capability/CapabilityImpl.h +++ b/zypp/capability/CapabilityImpl.h @@ -17,6 +17,7 @@ #include "zypp/ResolvableFwd.h" #include "zypp/SolverContextFwd.h" +#include "zypp/ResKind.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -26,6 +27,9 @@ namespace zypp { ///////////////////////////////////////////////////////////////// DEFINE_PTR_TYPE(CapabilityImpl) + /** \todo Check implementation */ + typedef std::string CapKind; + /////////////////////////////////////////////////////////////////// // // CLASS NAME : CapabilityImpl @@ -34,13 +38,24 @@ namespace zypp class CapabilityImpl : public base::ReferenceCounted, private base::NonCopyable { public: - /** Dtor */ - virtual ~CapabilityImpl(); + /** Ctor */ + CapabilityImpl( const ResKind & refers_r ); public: /** */ + virtual const CapKind & kind() const = 0; + /** */ + const ResKind & refers() const + { return _refers; } + /** */ + virtual std::string asString() const = 0; + /** */ virtual bool matches( constResolvablePtr resolvable_r, - const SolverContext & colverContext_r ) = 0; + const SolverContext & colverContext_r ) const = 0; + + private: + /** */ + ResKind _refers; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/capability/Makefile.am b/zypp/capability/Makefile.am index 1c32124..84062d8 100644 --- a/zypp/capability/Makefile.am +++ b/zypp/capability/Makefile.am @@ -5,7 +5,9 @@ SUBDIRS = ## ################################################## -include_HEADERS = CapabilityImpl.h \ +include_HEADERS = \ + CapabilityImpl.h\ + Capabilities.h \ \ ConditionalCap.h\ FileCap.h \ @@ -18,6 +20,8 @@ noinst_LTLIBRARIES = lib@PACKAGE@_capability.la ## ################################################## lib@PACKAGE@_capability_la_SOURCES = \ - CapabilityImpl.cc + CapabilityImpl.cc \ + \ + NamedCap.cc ## ################################################## diff --git a/zypp/capability/NamedCap.cc b/zypp/capability/NamedCap.cc new file mode 100644 index 0000000..94c4ea3 --- /dev/null +++ b/zypp/capability/NamedCap.cc @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/capability/NamedCap.cc + * +*/ +#include "zypp/capability/NamedCap.h" + +using namespace std; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace capability + { ///////////////////////////////////////////////////////////////// + + const CapKind NamedCap::_kind( "NamedCap" ); + + ///////////////////////////////////////////////////////////////// + } // namespace capability + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/capability/NamedCap.h b/zypp/capability/NamedCap.h index 69bb109..14f92f7 100644 --- a/zypp/capability/NamedCap.h +++ b/zypp/capability/NamedCap.h @@ -29,10 +29,27 @@ namespace zypp class NamedCap : public CapabilityImpl { public: + /** Ctor */ + NamedCap( const ResKind & refers_r, const std::string & name_r ) + : CapabilityImpl( refers_r ) + , _name( name_r ) + {} + public: + /** */ + virtual const CapKind & kind() const + { return _kind; } + /** */ + virtual std::string asString() const + { return _name; } /** */ - bool matches( constResolvablePtr resolvable_r, - const SolverContext & colverContext_r ) + virtual bool matches( constResolvablePtr resolvable_r, + const SolverContext & colverContext_r ) const { return false; } + private: + /** */ + static const CapKind _kind; + /** */ + std::string _name; }; /////////////////////////////////////////////////////////////////// -- 2.7.4