typedef TraitsType::constPtrType constPtr;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
+ /** Ctor */
Atom( const sat::Solvable & solvable_r );
/** Dtor */
virtual ~Atom();
ResKind.h
ResFilters.h
ResObject.h
+ ResObjectsh
ResPool.h
ResPoolManager.h
ResPoolProxy.h
static Ptr availableInstance( const Locale & locale_r );
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Language( const sat::Solvable & solvable_r );
/** Dtor */
ResTraits<Patch>::constPtrType patch() const;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
+ /** Ctor */
Message( const sat::Solvable & solvable_r );
/** Dtor */
virtual ~Message();
OnMediaLocation location() const;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
+ /** Ctor */
Package( const sat::Solvable & solvable_r );
/** Dtor */
virtual ~Package();
bool interactive() const;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Patch( const sat::Solvable & solvable_r );
/** Dtor */
const Capabilities & extends() const;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Pattern( const sat::Solvable & solvable_r );
/** Dtor */
Edition distributionEdition() const;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Product( const sat::Solvable & solvable_r );
/** Dtor */
//
std::ostream & ResObject::dumpOn( std::ostream & str ) const
{
- str << "[S" << repository().numericId() << ":" << mediaNr() << "]";
- return Resolvable::dumpOn( str );
+ return Resolvable::dumpOn( str << "[S" << repository().numericId() << ":" << mediaNr() << "]" );
}
///////////////////////////////////////////////////////////////////
return _du;
}
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+#include "zypp/ResObjects.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
+ {
+ ResKind kind( solvable_r.kind() );
+#define OUTS(X) if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
+ OUTS( Atom );
+ OUTS( Language );
+ OUTS( Message );
+ OUTS( Package );
+ OUTS( Patch );
+ OUTS( Pattern );
+ OUTS( Product );
+ OUTS( Script );
+ OUTS( Selection );
+ OUTS( SrcPackage );
+#undef OUTS
+ return 0;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
ByteCount downloadSize() const;
/**
- * \short Download size
- * \deprecated Use downloadSize()
- */
- ZYPP_DEPRECATED ByteCount archivesize() const
- { return downloadSize(); }
-
- /**
* Source providing this resolvable
*/
Repository repository() const;
* \code
* sat::Solvable s;
* ResObject::Ptr p( makeResObject( s ) );
- * if ( p )
- * {
+ * ResObject::Ptr q( make<ResObject>( s ) );
+ * Package::Ptr pkg( make<Package>( s ) );
+ * \endcode
+ */
+ ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
+
+ /** Directly create a certain kind of ResObject from \ref sat::Solvable.
*
- * }
+ * If the sat::Solvables kind is not appropriate, a NULL
+ * pointer is returned.
+ * \code
+ * sat::Solvable s;
+ * ResObject::Ptr p( makeResObject( s ) );
+ * ResObject::Ptr q( make<ResObject>( s ) );
+ * Package::Ptr pkg( make<Package>( s ) );
* \endcode
*/
- inline ResObject::Ptr makeResObject( const sat::Solvable & solvable_r ) { return 0; }
+ template<class _Res>
+ inline typename ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )
+ { return( isKind<_Res>( solvable_r ) ? new _Res( solvable_r ) : 0 ); }
+ /** \overload Specialisation for ResObject autodetecting the kind of resolvable. */
+ template<>
+ inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
+ { return makeResObject( solvable_r ); }
/** Convert ResObject::Ptr into Ptr of a certain Kind.
* \return \c NULL iff \a p is \c NULL or points to a Resolvable
* \endcode
*/
template<class _Res>
- inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
- { return dynamic_pointer_cast<_Res>(p); }
+ inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
+ { return dynamic_pointer_cast<_Res>(p); }
template<class _Res>
- inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
- { return dynamic_pointer_cast<const _Res>(p); }
+ inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
+ { return dynamic_pointer_cast<const _Res>(p); }
/////////////////////////////////////////////////////////////////
} // namespace zypp
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ResObjects.h
+ *
+*/
+#ifndef ZYPP_RESOBJECTS_H
+#define ZYPP_RESOBJECTS_H
+
+#include "zypp/Atom.h"
+#include "zypp/Language.h"
+#include "zypp/Message.h"
+#include "zypp/Package.h"
+#include "zypp/Patch.h"
+#include "zypp/Pattern.h"
+#include "zypp/Product.h"
+#include "zypp/Script.h"
+#include "zypp/Selection.h"
+#include "zypp/SrcPackage.h"
+
+#endif // ZYPP_RESOBJECTS_H
Resolvable::~Resolvable()
{}
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : Resolvable::dumpOn
+ // METHOD TYPE : std::ostream &
+ //
std::ostream & Resolvable::dumpOn( std::ostream & str ) const
- {
- //::dumpOn( str, *(sat::Solvable*)(this) );
- //return str << sat::Solvable::dumpOn(str);
- return str;
- }
-
+ { return str << satSolvable(); }
/////////////////////////////////////////////////////////////////
} // namespace zypp
OnMediaLocation undoScriptLocation() const;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Script( const sat::Solvable & solvable_r );
/** Dtor */
const std::set<std::string> install_packages( const Locale & lang = Locale("") ) const;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Selection( const sat::Solvable & solvable_r );
/** Dtor */
OnMediaLocation location() const;
protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
+ /** Ctor */
SrcPackage( const sat::Solvable & solvable_r );
/** Dtor */
virtual ~SrcPackage();
return ResKind( std::string( ident, sep-ident ) );
}
+ bool Solvable::isKind( const ResKind & kind_r ) const
+ {
+ NO_SOLVABLE_RETURN( false );
+
+ // detect srcpackages by 'arch'
+ if ( kind_r == ResKind::srcpackage )
+ {
+ return( _solvable->arch == ARCH_SRC || _solvable->arch == ARCH_NOSRC );
+ }
+
+ // no ':' in package names (hopefully)
+ const char * ident = IdString( _solvable->name ).c_str();
+ if ( kind_r == ResKind::package )
+ {
+ return( ::strchr( ident, ':' ) == 0 );
+ }
+
+ // look for a 'kind:' prefix
+ const char * kind = kind_r.c_str();
+ unsigned ksize = ::strlen( kind );
+ return( ::strncmp( ident, kind, ksize ) == 0
+ && ident[ksize] == ':' );
+ }
+
std::string Solvable::name() const
{
NO_SOLVABLE_RETURN( std::string() );
IdString ident() const;
ResKind kind() const;
+ /** Test whether a Solvable is of a certain \ref ResKind. */
+ bool isKind( const ResKind & kind_r ) const;
+
std::string name() const;
Edition edition() const;
Arch arch() const;
/////////////////////////////////////////////////////////////////
} // namespace sat
///////////////////////////////////////////////////////////////////
+
+ /** \relates sat::Solvable Test whether a \ref sat::Solvable is of a certain Kind. */
+ template<class _Res>
+ inline bool isKind( const sat::Solvable & solvable_r )
+ { return solvable_r.isKind( ResTraits<_Res>::kind ); }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
out << " " << xml_tag_enclose(toXML(dep[Dep::CONFLICTS]), "conflicts") << endl;
if ( dep[Dep::OBSOLETES].size() > 0 )
out << " " << xml_tag_enclose(toXML(dep[Dep::OBSOLETES]), "obsoletes") << endl;
- // why the YUM tag is freshen without s????
if ( dep[Dep::FRESHENS].size() > 0 )
out << " " << xml_tag_enclose(toXML(dep[Dep::FRESHENS]), "freshens") << endl;
if ( dep[Dep::REQUIRES].size() > 0 )