Mailinglist Archive: zypp-commit (258 mails)

< Previous Next >
[zypp-commit] r8359 - in /branches/tmp/ma/jump_sat/libzypp/zypp: ./ sat/ target/store/
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Thu, 24 Jan 2008 12:15:50 -0000
  • Message-id: <20080124121551.5CD4226373@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Thu Jan 24 13:15:50 2008
New Revision: 8359

URL: http://svn.opensuse.org/viewcvs/zypp?rev=8359&view=rev
Log:
Add ResObject construction from Solvable
- ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
- template<class _Res>
ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )

Added:
branches/tmp/ma/jump_sat/libzypp/zypp/ResObjects.h
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/Atom.h
branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt
branches/tmp/ma/jump_sat/libzypp/zypp/Language.h
branches/tmp/ma/jump_sat/libzypp/zypp/Message.h
branches/tmp/ma/jump_sat/libzypp/zypp/Package.h
branches/tmp/ma/jump_sat/libzypp/zypp/Patch.h
branches/tmp/ma/jump_sat/libzypp/zypp/Pattern.h
branches/tmp/ma/jump_sat/libzypp/zypp/Product.h
branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.h
branches/tmp/ma/jump_sat/libzypp/zypp/Resolvable.cc
branches/tmp/ma/jump_sat/libzypp/zypp/Script.h
branches/tmp/ma/jump_sat/libzypp/zypp/Selection.h
branches/tmp/ma/jump_sat/libzypp/zypp/SrcPackage.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h
branches/tmp/ma/jump_sat/libzypp/zypp/target/store/serialize.cc

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Atom.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Atom.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Atom.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Atom.h Thu Jan 24 13:15:50 2008
@@ -31,6 +31,8 @@
typedef TraitsType::constPtrType constPtr;

protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
+ /** Ctor */
Atom( const sat::Solvable & solvable_r );
/** Dtor */
virtual ~Atom();

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt Thu Jan 24 13:15:50
2008
@@ -143,6 +143,7 @@
ResKind.h
ResFilters.h
ResObject.h
+ ResObjectsh
ResPool.h
ResPoolManager.h
ResPoolProxy.h

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Language.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Language.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Language.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Language.h Thu Jan 24 13:15:50 2008
@@ -41,6 +41,7 @@
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 */

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Message.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Message.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Message.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Message.h Thu Jan 24 13:15:50 2008
@@ -39,6 +39,8 @@
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();

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Package.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Package.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Package.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Package.h Thu Jan 24 13:15:50 2008
@@ -98,6 +98,8 @@
OnMediaLocation location() const;

protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
+ /** Ctor */
Package( const sat::Solvable & solvable_r );
/** Dtor */
virtual ~Package();

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Patch.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Patch.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Patch.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Patch.h Thu Jan 24 13:15:50 2008
@@ -56,6 +56,7 @@
bool interactive() const;

protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Patch( const sat::Solvable & solvable_r );
/** Dtor */

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Pattern.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Pattern.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Pattern.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Pattern.h Thu Jan 24 13:15:50 2008
@@ -58,6 +58,7 @@
const Capabilities & extends() const;

protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Pattern( const sat::Solvable & solvable_r );
/** Dtor */

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Product.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Product.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Product.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Product.h Thu Jan 24 13:15:50 2008
@@ -82,6 +82,7 @@
Edition distributionEdition() const;

protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Product( const sat::Solvable & solvable_r );
/** Dtor */

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.cc?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.cc Thu Jan 24 13:15:50 2008
@@ -42,8 +42,7 @@
//
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() << "]" );
}

///////////////////////////////////////////////////////////////////
@@ -97,6 +96,34 @@
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
///////////////////////////////////////////////////////////////////

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResObject.h Thu Jan 24 13:15:50 2008
@@ -96,13 +96,6 @@
ByteCount downloadSize() const;

/**
- * \short Download size
- * \deprecated Use downloadSize()
- */
- ZYPP_DEPRECATED ByteCount archivesize() const
- { return downloadSize(); }
-
- /**
* Source providing this resolvable
*/
Repository repository() const;
@@ -159,13 +152,30 @@
* \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
@@ -176,12 +186,12 @@
* \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

Added: branches/tmp/ma/jump_sat/libzypp/zypp/ResObjects.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResObjects.h?rev=8359&view=auto
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResObjects.h (added)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResObjects.h Thu Jan 24 13:15:50 2008
@@ -0,0 +1,26 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Resolvable.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Resolvable.cc?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Resolvable.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Resolvable.cc Thu Jan 24 13:15:50 2008
@@ -35,13 +35,13 @@
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

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Script.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Script.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Script.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Script.h Thu Jan 24 13:15:50 2008
@@ -60,6 +60,7 @@
OnMediaLocation undoScriptLocation() const;

protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
/** Ctor */
Script( const sat::Solvable & solvable_r );
/** Dtor */

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Selection.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Selection.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Selection.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Selection.h Thu Jan 24 13:15:50 2008
@@ -49,6 +49,7 @@
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 */

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/SrcPackage.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/SrcPackage.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/SrcPackage.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/SrcPackage.h Thu Jan 24 13:15:50 2008
@@ -40,6 +40,8 @@
OnMediaLocation location() const;

protected:
+ friend Ptr make<Self>( const sat::Solvable & solvable_r );
+ /** Ctor */
SrcPackage( const sat::Solvable & solvable_r );
/** Dtor */
virtual ~SrcPackage();

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc Thu Jan 24 13:15:50
2008
@@ -115,6 +115,30 @@
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() );

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h Thu Jan 24 13:15:50
2008
@@ -84,6 +84,9 @@
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;
@@ -199,6 +202,12 @@
/////////////////////////////////////////////////////////////////
} // 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
///////////////////////////////////////////////////////////////////

Modified: branches/tmp/ma/jump_sat/libzypp/zypp/target/store/serialize.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/target/store/serialize.cc?rev=8359&r1=8358&r2=8359&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/target/store/serialize.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/target/store/serialize.cc Thu Jan 24
13:15:50 2008
@@ -166,7 +166,6 @@
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 )

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages