and NVRAD(name,edition,arch,dependencies).
- Resolvable construction now supports NVRAD. Manipulation of
Dependencies after construction via the Resolvables public
interface is deprecated. To be fixed in RpmDb and YUMParser.
//http://www.boost.org/libs/libraries.htm
#include <iostream>
#include <list>
+#include <vector>
#include <string>
+#include <iterator>
#include <zypp/base/Logger.h>
#include <zypp/base/Exception.h>
+#include <zypp/base/String.h>
#include <zypp/base/PtrTypes.h>
-#include <zypp/parser/tagfile/Tags.h>
+
+#include <zypp/parser/tagfile/Parser.h>
+#include <zypp/Package.h>
+#include <zypp/CapSet.h>
+#include <zypp/CapFactory.h>
+#include <zypp/detail/PackageImpl.h>
#include <zypp/NVRA.h>
+using std::endl;
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
namespace tagfile
{ /////////////////////////////////////////////////////////////////
- void echoOn( std::ostream & str,
- iterator_t first, const iterator_t last,
- const char* s = "" )
- {
- //return;
- str << first.get_position() << last.get_position();
- str << s << ">>";
- while ( first != last )
- str << *first++;
- str << "<< " << std::endl;
- }
- void echo( iterator_t first, const iterator_t last, const char* s = "" )
+ struct PackagesParser : public Parser
{
- echoOn( DBG, first, last, s );
- }
- void xecho( const char * first, const char *const last, const char* s = "" )
- {
- DBG << ">>" << std::string(first,last) << "<< " << std::endl;
- }
- void mecho( iterator_t first, const iterator_t last, const char* s = "" )
- {
- echoOn( MIL, first, last, s );
- }
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // SingleTag Grammar
- //
- ////////////////////////////////////////////////////////////////////////////
-
-
- struct Merror_report_parser
- {
- Merror_report_parser( const char * msg_r )
- : msg( msg_r )
- {}
-
- typedef spirit::nil_t result_t;
-
- template <typename ScannerT>
- int operator()( const ScannerT & scan, result_t & /*result*/ ) const
- {
- SEC << scan.first.get_position() << ' ' << msg << std::endl;
- return -1; // Fail.
- }
-
- const char * msg;
+ std::list<Package::Ptr> result;
+
+ shared_ptr<detail::PackageImpl> pkgImpl;
+
+ Package::Ptr pkg;
+ Dependencies deps;
+
+ void collectPkg()
+ {
+ if ( pkg )
+ {
+ pkg->setDeps( deps );
+ result.push_back( pkg );
+ // reset
+ deps = Dependencies();
+ }
+ }
+
+ void collectDeps( const std::list<std::string> & depstr_r,
+ std::insert_iterator<CapSet> result_r )
+ {
+ Capability c( CapFactory().parse( ResTraits<Package>::kind, "" ) );
+ INT << c << endl;
+ *result_r++ = c;
+ }
+
+ CapSet collectDeps( const std::list<std::string> & depstr_r )
+ {
+ return CapSet();
+ }
+
+ /* Overload to consume SingleTag data. */
+ virtual void consume( const STag & stag_r )
+ {
+ if ( stag_r.stag.isPlain( "Pkg" ) )
+ {
+ collectPkg();
+
+ std::vector<std::string> words;
+ str::split( stag_r.value, std::back_inserter(words) );
+
+ if ( str::split( stag_r.value, std::back_inserter(words) ) != 4 )
+ ZYPP_THROW( ParseException( "Pkg" ) );
+
+ pkg = detail::makeResolvableAndImpl( words[0],
+ Edition(words[1],words[2]),
+ Arch(words[4]),
+ pkgImpl );
+ }
+ //MIL << stag_r << endl;
+ }
+ /* Overload to consume MulitTag data. */
+ virtual void consume( const MTag & mtag_r )
+ {
+ if ( mtag_r.stag.isPlain( "Prv" ) )
+ {
+ CapSet cs;
+ collectDeps( mtag_r.value, std::inserter(cs,cs.end()) );
+ INT << cs.size() << endl;
+ deps.setProvides( cs );
+ }
+ else if ( mtag_r.stag.isPlain( "Prq" ) )
+ {
+ deps.setPrerequires( collectDeps( mtag_r.value ) );
+ }
+ else if ( mtag_r.stag.isPlain( "Req" ) )
+ {
+ deps.setRequires( collectDeps( mtag_r.value ) );
+ }
+ else if ( mtag_r.stag.isPlain( "Con" ) )
+ {
+ deps.setConflicts( collectDeps( mtag_r.value ) );
+ }
+ else if ( mtag_r.stag.isPlain( "Obs" ) )
+ {
+ deps.setObsoletes( collectDeps( mtag_r.value ) );
+ }
+ }
};
- typedef functor_parser<Merror_report_parser> Merror_report_p;
-
-
-
-
/////////////////////////////////////////////////////////////////
} // namespace tagfile
///////////////////////////////////////////////////////////////////
// Types
//
////////////////////////////////////////////////////////////////////////////
+
using std::endl;
-using std::list;
-using std::string;
using namespace zypp;
using namespace zypp::parser::tagfile;
-typedef scanner<iterator_t> scanner_t;
-typedef rule<scanner_t> rule_t;
+
////////////////////////////////////////////////////////////////////////////
//
// Just for the stats
};
////////////////////////////////////////////////////////////////////////////
-NVRA parseNVRA( const std::string & value )
-{
- std::string n;
- std::string v;
- std::string r;
- std::string a;
-
- parse_info<> info = parse( value.c_str(),
-
- lexeme_d[(+~space_p)] [assign_a(n)]
- >> lexeme_d[(+(~space_p & ~ch_p('-')))] [assign_a(v)]
- >> lexeme_d[(+(~space_p & ~ch_p('-')))] [assign_a(r)]
- >> lexeme_d[(+~space_p)] [assign_a(a)]
- ,
- space_p );
-
- NVRA data;
- if ( info.full )
- {
- data = NVRA( n, Edition(v,r), Arch(a) );
- }
- else
- {
- ERR << "parseNVRA failed on " << value << std::endl;
- }
- INT << data << endl;
- return data;
-}
-
-
-struct PConsume
-{
- static bool isTag( const Tag & tag_r, const std::string & ident_r )
- {
- return tag_r.ident == ident_r && tag_r.ext.empty();
- }
- static bool isLangTag( const Tag & tag_r, const std::string & ident_r )
- {
- return tag_r.ident == ident_r && ! tag_r.ext.empty();
- }
-
- bool newPkg( const std::string & value )
- {
- NVRA data( parseNVRA( value ) );
- return true;
- }
-
-
- PConsume & operator=( const STag & stag_r )
- {
- if ( isTag( stag_r.stag, "Pkg" ) )
- {
- newPkg( stag_r.value );
- MIL << stag_r << endl;
- }
- return *this;
- }
- PConsume & operator=( const MTag & mtag_r )
- {
- return *this;
- }
-
- scoped_ptr<NVRA> _nvra;
-};
+using namespace std;
////////////////////////////////////////////////////////////////////////////
//
// Main
if (argc >= 2 )
infile = argv[1];
- // Create a file iterator for this file
- fiterator_t first(infile);
- if (!first)
- {
- ERR << "Unable to open file!\n";
- return -1;
- }
- // Create an EOF iterator
- fiterator_t last = first.make_end();
-
- // Create position iterators
- iterator_t begin( first, last, infile );
- iterator_t end;
-
- // Result var
- SingleTag stag;
- MultiTag mtag;
- STag stagData;
- MTag mtagData;
-
- PConsume consume;
-
-#if 1
- rule_t file = end_p
- | ( stag [var(consume)=arg1]
- | mtag [var(consume)=arg1]
- | ( *blank_p
- >> !( ch_p('#')
- >> *(anychar_p - eol_p)
- )
- >> (eol_p|end_p)
- )
- | error_report_p( "illegal line" )
- )
- >> file
- ;
-#else
- rule_t file =
- end_p
- | (+~space_p) [&echo]
- >> ( lazy_p(var(skip))
- | Merror_report_p( "lazy failed" )
- )
- >> file
- ;
-#endif
-
- // Parse
- shared_ptr<Measure> duration( new Measure );
- parse_info<iterator_t> info
- = parse( begin, end,
-
- file
-
- );
- duration.reset();
+ PackagesParser p;
+ p.parse( infile );
- // Check for fail...
- if ( info.full )
- USR << "Parse succeeded!\n";
- else if ( info.hit )
- {
- ERR << "Parse partial!\n";
- ERR << " at pos " << info.length << endl;
- }
- else
- {
- ERR << "Parse failed!\n";
- ERR << " at pos " << info.length << endl;
- }
+ SEC << p.result.size() << endl;
+ MIL << *p.result.front() << endl;
+ MIL << p.result.front()->deps() << endl;
INT << "===[END]============================================" << endl;
return 0;
///////////////////////////////////////////////////////////////////
class CapFactory;
- struct CapMatchContext {};
///////////////////////////////////////////////////////////////////
//
/** \relates DependenciesImpl Stream output */
inline std::ostream & operator<<( std::ostream & str, const Dependencies::Impl & obj )
{
- str << "PROVIDES:" << endl << obj._provides;
- str << "PREREQUIRES:" << endl << obj._prerequires;
- str << "REQUIRES:" << endl << obj._requires;
- str << "CONFLICTS:" << endl << obj._conflicts;
- str << "OBSOLETES:" << endl << obj._obsoletes;
- str << "RECOMMENDS:" << endl << obj._recommends;
- str << "SUGGESTS:" << endl << obj._suggests;
- str << "FRESHENS:" << endl << obj._freshens;
- return str;
+ str << "Dependencies: [" << endl;
+ if ( ! obj._provides.empty() )
+ str << "PROVIDES:" << endl << obj._provides;
+ if ( ! obj._prerequires.empty() )
+ str << "PREREQUIRES:" << endl << obj._prerequires;
+ if ( ! obj._requires.empty() )
+ str << "REQUIRES:" << endl << obj._requires;
+ if ( ! obj._conflicts.empty() )
+ str << "CONFLICTS:" << endl << obj._conflicts;
+ if ( ! obj._obsoletes.empty() )
+ str << "OBSOLETES:" << endl << obj._obsoletes;
+ if ( ! obj._recommends.empty() )
+ str << "RECOMMENDS:" << endl << obj._recommends;
+ if ( ! obj._suggests.empty() )
+ str << "SUGGESTS:" << endl << obj._suggests;
+ if ( ! obj._freshens.empty() )
+ str << "FRESHENS:" << endl << obj._freshens;
+ return str << "]";
}
///////////////////////////////////////////////////////////////////
{
string ret;
+#warning RE-fix asString and supress epoch
// if ( _pimpl->_epoch )
ret += str::form( "%d:", _pimpl->_epoch );
Edition.h \
LanguageCode.h \
Locale.h \
+ NVR.h \
NVRA.h \
+ NVRAD.h \
Rel.h \
ResObject.h \
Resolvable.h \
Edition.cc \
LanguageCode.cc \
Locale.cc \
+ NVR.cc \
NVRA.cc \
+ NVRAD.cc \
Rel.cc \
ResObject.cc \
Resolvable.cc \
// METHOD NAME : Message::Message
// METHOD TYPE : Ctor
//
- Message::Message( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
- : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+ Message::Message( const NVRAD & nvrad_r )
+ : ResObject( TraitsType::kind, nvrad_r )
{}
///////////////////////////////////////////////////////////////////
std::string type();
protected:
- /** Ctor */
- Message( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r );
+ Message( const NVRAD & nvrad_r );
/** Dtor */
virtual ~Message();
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/NVR.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/NVR.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const NVR & obj )
+ {
+ return str << obj.name << '-' << obj.edition;
+ }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/NVR.h
+ *
+*/
+#ifndef ZYPP_NVR_H
+#define ZYPP_NVR_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/Edition.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : NVR
+ //
+ /** Helper storing Name and Edition. */
+ struct NVR
+ {
+ /** Default ctor */
+ NVR()
+ {}
+
+ /** Ctor */
+ explicit
+ NVR( const std::string & name_r,
+ const Edition & edition_r = Edition() )
+ : name( name_r )
+ , edition( edition_r )
+ {}
+
+ /** */
+ std::string name;
+ /** */
+ Edition edition;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates NVR Stream output */
+ std::ostream & operator<<( std::ostream & str, const NVR & obj );
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_NVR_H
#define ZYPP_NVRA_H
#include <iosfwd>
-#include <string>
-#include "zypp/base/PtrTypes.h"
-#include "zypp/Edition.h"
+#include "zypp/NVR.h"
#include "zypp/Arch.h"
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : NVRA
//
- /** */
- struct NVRA
+ /** Helper storing Name, Edition and Arch. */
+ struct NVRA : public NVR
{
/** Default ctor */
NVRA()
NVRA( const std::string & name_r,
const Edition & edition_r = Edition(),
const Arch & arch_r = Arch() )
- : name( name_r )
- , edition( edition_r )
+ : NVR( name_r, edition_r )
+ , arch( arch_r )
+ {}
+
+ /** Ctor */
+ explicit
+ NVRA( const NVR & nvr_r,
+ const Arch & arch_r = Arch() )
+ : NVR( nvr_r )
, arch( arch_r )
{}
- /** */
- std::string name;
- /** */
- Edition edition;
/** */
Arch arch;
};
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/NVRAD.cc
+ *
+*/
+
+#include "zypp/NVRAD.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/NVRAD.h
+ *
+*/
+#ifndef ZYPP_NVRAD_H
+#define ZYPP_NVRAD_H
+
+#include "zypp/NVRA.h"
+#include "zypp/Dependencies.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : NVRAD
+ //
+ /** Helper storing Name, Edition, Arch and Dependencies. */
+ struct NVRAD : public NVRA
+ {
+ /** Default ctor */
+ NVRAD()
+ {}
+
+ /** Ctor */
+ explicit
+ NVRAD( const std::string & name_r,
+ const Edition & edition_r = Edition(),
+ const Arch & arch_r = Arch(),
+ const Dependencies & deps_r = Dependencies() )
+ : NVRA( name_r, edition_r, arch_r )
+ , deps( deps_r )
+ {}
+
+ /** Ctor */
+ explicit
+ NVRAD( const NVRA & nvra_r,
+ const Dependencies & deps_r = Dependencies() )
+ : NVRA( nvra_r )
+ , deps( deps_r )
+ {}
+
+ /** Ctor */
+ explicit
+ NVRAD( const NVR & nvr_r,
+ const Arch & arch_r = Arch(),
+ const Dependencies & deps_r = Dependencies() )
+ : NVRA( nvr_r, arch_r )
+ , deps( deps_r )
+ {}
+
+ /** */
+ Dependencies deps;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_NVRAD_H
// METHOD NAME : Package::Package
// METHOD TYPE : Ctor
//
- Package::Package( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
- : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+ Package::Package( const NVRAD & nvrad_r )
+ : ResObject( TraitsType::kind, nvrad_r )
{}
///////////////////////////////////////////////////////////////////
// data here:
protected:
- /** Ctor */
- Package( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r );
+ Package( const NVRAD & nvrad_r );
/** Dtor */
virtual ~Package();
// METHOD NAME : Patch::Patch
// METHOD TYPE : Ctor
//
- Patch::Patch( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
- : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+ Patch::Patch( const NVRAD & nvrad_r )
+ : ResObject( TraitsType::kind, nvrad_r )
{}
///////////////////////////////////////////////////////////////////
protected:
/** Ctor */
- Patch( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r );
+ Patch( const NVRAD & nvrad_r );
/** Dtor */
virtual ~Patch();
// METHOD NAME : Product::Product
// METHOD TYPE : Ctor
//
- Product::Product( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
- : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+ Product::Product( const NVRAD & nvrad_r )
+ : ResObject( TraitsType::kind, nvrad_r )
{}
///////////////////////////////////////////////////////////////////
protected:
/** Ctor */
- Product( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r );
+ Product( const NVRAD & nvrad_r );
/** Dtor */
virtual ~Product();
// METHOD TYPE : Ctor
//
ResObject::ResObject( const Kind & kind_r,
- const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
- : Resolvable( kind_r, name_r, edition_r, arch_r )
+ const NVRAD & nvrad_r )
+ : Resolvable( kind_r, nvrad_r )
{}
///////////////////////////////////////////////////////////////////
protected:
/** Ctor */
ResObject( const Kind & kind_r,
- const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r );
+ const NVRAD & nvrad_r );
/** Dtor */
virtual ~ResObject();
// METHOD TYPE : Ctor
//
Resolvable::Resolvable( const Kind & kind_r,
- const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
- : _pimpl( new Impl( kind_r, name_r, edition_r, arch_r ) )
+ const NVRAD & nvrad_r )
+ : _pimpl( new Impl( kind_r, nvrad_r ) )
{}
///////////////////////////////////////////////////////////////////
const Arch & Resolvable::arch() const
{ return _pimpl->arch(); }
+ const CapSet & Resolvable::provides() const
+ { return _pimpl->deps().provides(); }
+
+ const CapSet & Resolvable::prerequires() const
+ { return _pimpl->deps().prerequires(); }
+
+ const CapSet & Resolvable::requires() const
+ { return _pimpl->deps().requires(); }
+
+ const CapSet & Resolvable::conflicts() const
+ { return _pimpl->deps().conflicts(); }
+
+ const CapSet & Resolvable::obsoletes() const
+ { return _pimpl->deps().obsoletes(); }
+
+ const CapSet & Resolvable::recommends() const
+ { return _pimpl->deps().recommends(); }
+
+ const CapSet & Resolvable::suggests() const
+ { return _pimpl->deps().suggests(); }
+
+ const CapSet & Resolvable::freshens() const
+ { return _pimpl->deps().freshens(); }
+
+
const Dependencies & Resolvable::deps() const
{ return _pimpl->deps(); }
#include "zypp/Edition.h"
#include "zypp/Arch.h"
+#include "zypp/CapSetFwd.h"
#include "zypp/Dependencies.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ struct NVRAD;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Resolvable
const Edition & edition() const;
/** */
const Arch & arch() const;
+
+ /** \name Dependencies. */
+ //@{
+ const CapSet & provides() const;
+ const CapSet & prerequires() const;
+ const CapSet & requires() const;
+ const CapSet & conflicts() const;
+ const CapSet & obsoletes() const;
+ const CapSet & recommends() const;
+ const CapSet & suggests() const;
+ const CapSet & freshens() const;
+ //@}
+
/** */
const Dependencies & deps() const;
/** */
protected:
/** Ctor */
Resolvable( const Kind & kind_r,
- const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r );
+ const NVRAD & nvrad_r );
/** Dtor */
virtual ~Resolvable();
/** Helper for stream output */
// METHOD NAME : Script::Script
// METHOD TYPE : Ctor
//
- Script::Script( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
- : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+ Script::Script( const NVRAD & nvrad_r )
+ : ResObject( TraitsType::kind, nvrad_r )
{}
///////////////////////////////////////////////////////////////////
protected:
/** Ctor */
- Script( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r );
+ Script( const NVRAD & nvrad_r );
/** Dtor */
virtual ~Script();
// METHOD NAME : Selection::Selection
// METHOD TYPE : Ctor
//
- Selection::Selection( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
- : ResObject( TraitsType::kind, name_r, edition_r, arch_r )
+ Selection::Selection( const NVRAD & nvrad_r )
+ : ResObject( TraitsType::kind, nvrad_r )
{}
///////////////////////////////////////////////////////////////////
protected:
/** Ctor */
- Selection( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r );
+ Selection( const NVRAD & nvrad_r );
/** Dtor */
virtual ~Selection();
#define ZYPP_DETAIL_RESOBJECTFACTORY_H
#include "zypp/base/PtrTypes.h"
+#include "zypp/NVRAD.h"
///////////////////////////////////////////////////////////////////
namespace zypp
class Edition;
class Arch;
+ struct NVRAD;
///////////////////////////////////////////////////////////////////
namespace detail
namespace _resobjectfactory_detail
{ /////////////////////////////////////////////////////////////////
+ /** Glues a Resolvable to it's implementation. */
template<class _Res>
class ResImplConnect : public _Res
{
// typedef intrusive_ptr<Self> Ptr;
// typedef intrusive_ptr<const Self> constPtr;
public:
- /** \todo protect against NULL Impl. */
- ResImplConnect( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r,
+ /** Ctor */
+ ResImplConnect( const NVRAD & nvrad_r,
Impl_Ptr impl_r )
- : _Res( name_r, edition_r, arch_r )
+ : _Res( nvrad_r )
, _impl( impl_r )
{ _impl->_backRef = this; }
+
virtual ~ResImplConnect()
{ _impl->_backRef = 0; }
+
private:
Impl_Ptr _impl;
virtual Impl & pimpl() { return *_impl; }
template<class _Impl>
typename _Impl::ResType::Ptr
- makeResolvableAndImpl( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r,
+ makeResolvableAndImpl( const NVRAD & nvrad_r,
shared_ptr<_Impl> & impl_r )
{
impl_r.reset( new _Impl );
return new
_resobjectfactory_detail::ResImplConnect<typename _Impl::ResType>
- ( name_r, edition_r, arch_r, impl_r );
+ ( nvrad_r, impl_r );
}
template<class _Impl>
typename _Impl::ResType::Ptr
- makeResolvableFromImpl( const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r,
+ makeResolvableAndImpl( const std::string & name_r,
+ const Edition & edition_r,
+ const Arch & arch_r,
+ shared_ptr<_Impl> & impl_r )
+ {
+ return makeResolvableAndImpl( NVRAD( name_r, edition_r, arch_r ), impl_r );
+ }
+
+ template<class _Impl>
+ typename _Impl::ResType::Ptr
+ makeResolvableFromImpl( const NVRAD & nvrad_r,
shared_ptr<_Impl> impl_r )
{
if ( ! impl_r )
throw ( "makeResolvableFromImpl: Impl already managed" );
return new
_resobjectfactory_detail::ResImplConnect<typename _Impl::ResType>
- ( name_r, edition_r, arch_r, impl_r );
+ ( nvrad_r, impl_r );
+ }
+
+ template<class _Impl>
+ typename _Impl::ResType::Ptr
+ makeResolvableFromImpl( const std::string & name_r,
+ const Edition & edition_r,
+ const Arch & arch_r,
+ shared_ptr<_Impl> impl_r )
+ {
+ return makeResolvableFromImpl( NVRAD( name_r, edition_r, arch_r ), impl_r );
}
/////////////////////////////////////////////////////////////////
#define ZYPP_DETAIL_RESOLVABLEIMPL_H
#include "zypp/Resolvable.h"
+#include "zypp/NVRAD.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{
/** Ctor */
Impl( const Kind & kind_r,
- const std::string & name_r,
- const Edition & edition_r,
- const Arch & arch_r )
+ const NVRAD & nvrad_r )
: _kind( kind_r )
- , _name( name_r )
- , _edition( edition_r )
- , _arch( arch_r )
+ , _name( nvrad_r.name )
+ , _edition( nvrad_r.edition )
+ , _arch( nvrad_r.arch )
+ , _deps( nvrad_r.deps )
{}
public:
/** */
const Kind & kind() const
{ return _kind; }
-
/** */
const std::string & name() const
{ return _name; }
-
/** */
const Edition & edition() const
{ return _edition; }
-
+ /** */
const Arch & arch() const
{ return _arch; }
-
/** */
const Dependencies & deps() const
{ return _deps; }
void setDeps( const Dependencies & val_r )
{ _deps = val_r; }
-
-
private:
/** */
Kind _kind;
**/
class ResItem : public base::ReferenceCounted, private base::NonCopyable {
-
+
private:
Channel_constPtr _channel;
size_t installedSize() const { return _installed_size; }
void setInstalledSize (size_t installed_size) { _installed_size = installed_size; }
- const CapSet & requires() const { return _resObject->deps().requires(); }
- const CapSet & provides() const { return _resObject->deps().provides(); }
- const CapSet & conflicts() const { return _resObject->deps().conflicts(); }
- const CapSet & obsoletes() const { return _resObject->deps().obsoletes(); }
- const CapSet & suggests() const { return _resObject->deps().suggests(); }
- const CapSet & recommends() const { return _resObject->deps().recommends(); }
- const CapSet & freshens() const { return _resObject->deps().freshens(); }
+ const CapSet & requires() const { return _resObject->requires(); }
+ const CapSet & provides() const { return _resObject->provides(); }
+ const CapSet & conflicts() const { return _resObject->conflicts(); }
+ const CapSet & obsoletes() const { return _resObject->obsoletes(); }
+ const CapSet & suggests() const { return _resObject->suggests(); }
+ const CapSet & recommends() const { return _resObject->recommends(); }
+ const CapSet & freshens() const { return _resObject->freshens(); }
void setDependencies (const Dependencies & dependencies) { _resObject->setDeps(dependencies); }