From: Michael Andres Date: Tue, 25 Oct 2005 21:48:23 +0000 (+0000) Subject: backup X-Git-Tag: 6.6.0~6388 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d617d5210974f0e0ae9c9db1c744477be365039f;p=platform%2Fupstream%2Flibzypp.git backup --- diff --git a/test/devel.ma/Main.cc b/test/devel.ma/Main.cc index cb625156f..24242aed6 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 45abf23bc..bcfa3359b 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 000000000..da9fc74f5 --- /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 000000000..bdf60c782 --- /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 26c05e08e..95613ae4b 100644 --- a/zypp/CapFactory.cc +++ b/zypp/CapFactory.cc @@ -10,15 +10,39 @@ * */ #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 5ae3d240b..849d83332 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 7b440724c..ccf554fbe 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 3a12a4284..b206a0b4d 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: @@ -53,11 +55,15 @@ namespace zypp virtual ~Capability(); 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 cbece41f6..80f7c51f9 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 c1ad9f9ef..6518a3844 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 1e526f28b..6b82543a5 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 000000000..0a4dfde53 --- /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 717579dea..cd04c9f63 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 4ce52077b..933944b65 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 1c3212497..84062d833 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 000000000..94c4ea3c1 --- /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 69bb109b6..14f92f790 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; }; ///////////////////////////////////////////////////////////////////