print "Available items: %d" % ( Z.pool().size() )
for item in Z.pool():
- print "* %s:%s-%s.%s\t(%s)" % ( item.resolvable().kindToS(),
+ print "* %s:%s-%s.%s\t(%s)" % ( item.resolvable().kind(),
item.resolvable().name(),
item.resolvable().edition(),
item.resolvable().arch(),
print "Installed items: %d" % ( Z.pool().size() )
for item in Z.pool():
- print "i %s:%s-%s.%s" % ( item.resolvable().kindToS(),
+ print "i %s:%s-%s.%s" % ( item.resolvable().kind(),
item.resolvable().name(),
item.resolvable().edition(),
item.resolvable().arch() )
else:
t = "*"
print "%s %s:%s-%s.%s\t(%s)" % ( t,
- item.resolvable().kindToS(),
+ item.resolvable().kind(),
item.resolvable().name(),
item.resolvable().edition(),
item.resolvable().arch(),
-%typemap(in) Resolvable::Kind {
-
- VALUE kindstring = rb_funcall( $input, rb_intern("to_s"), 0, 0);
- kindstring = rb_funcall( kindstring, rb_intern("downcase"), 0, 0);
- std::string s(RSTRING(pathstring)->ptr);
-
- // FIXME make the string lowercase first
-
- if ( s == "patch" )
- {
- $1 == Patch::Kind;
- }
- if ( s == "package" )
- {
- $1 == Package::Kind;
- }
- if ( s == "script" )
- {
- $1 == Script::Kind;
- }
- if ( s == "message" )
- {
- $1 == Message::Kind;
- }
- if ( s == "pattern" )
- {
- $1 == Pattern::Kind;
- }
- if ( s == "Selection" )
- {
- $1 == Selection::Kind;
- }
-
-}
-
-%typemap(out) Kind {
- const char *s = $1.asString().c_str();
- $result = ID2SYM(rb_intern(s));
-}
-
-%extend Resolvable::TraitsType::KindType {
- const char* toS() {
- return "unknown";
- }
-}
-
-%extend Resolvable
+template<class _Tp>
+class KindOf
{
- // FIXME: this is just a workaround since the whole code above does not work
- const char* kindToS()
- {
- if (isKind<Package>(self))
- return "package";
- else if (isKind<Patch>(self))
- return "patch";
- else if (isKind<Product>(self))
- return "product";
- else if (isKind<Pattern>(self))
- return "pattern";
- else if (isKind<Language>(self))
- return "language";
- return "unknown";
- }
-}
-
+ public:
+ /** DefaultCtor: empty string */
+ KindOf()
+ {}
+ /** Ctor from string.
+ * Lowercase version of \a value_r is used as identification.
+ */
+ explicit
+ KindOf( const std::string & value_r )
+ : _value( str::toLower(value_r) )
+ {}
+ /** Dtor */
+ ~KindOf()
+ {}
+ public:
+ /** Identification string. */
+ const std::string & asString() const
+ { return _value; }
+
+ /** Order on KindOf (arbitrary).
+ * Not necessarily lexicographical.
+ * \todo Enable class _Tp to define the order,
+ * Fix logical operators below to use compare,
+ */
+ int compare( const KindOf & rhs ) const
+ { return _value.compare( rhs._value ); }
+
+ private:
+ /** */
+ std::string _value;
+};
+
+%template(KindOfResolvable) KindOf<Resolvable>;
--- /dev/null
+class Patch : public ResObject
+{
+ public:
+ typedef detail::PatchImplIf Impl;
+ typedef Patch Self;
+ typedef ResTraits<Self> TraitsType;
+ typedef TraitsType::PtrType Ptr;
+ typedef TraitsType::constPtrType constPtr;
+
+ public:
+ typedef Impl::AtomList AtomList;
+
+ public:
+ /** Patch ID */
+ std::string id() const;
+ /** Patch time stamp */
+ Date timestamp() const;
+ /** Patch category (recommended, security,...) */
+ std::string category() const;
+ /** Does the system need to reboot to finish the update process? */
+ bool reboot_needed() const;
+ /** Does the patch affect the package manager itself? */
+ bool affects_pkg_manager() const;
+ /** The list of all atoms building the patch */
+ AtomList atoms() const;
+ /** Is the patch installation interactive? (does it need user input?) */
+ bool interactive() const;
+
+
+ protected:
+ /** Ctor */
+ Patch( const NVRAD & nvrad_r );
+ /** Dtor */
+ virtual ~Patch();
+
+ private:
+ /** Access implementation */
+ virtual Impl & pimpl() = 0;
+ /** Access implementation */
+ virtual const Impl & pimpl() const = 0;
+};
};
+#if 0
%extend intrusive_ptr<const ResObject>
{
// FIXME: this is just a workaround, see Kind.i
return compareByNVRA(*self, other);
}
}
-
+#endif
-#ifdef SWIGPERL5
-#else
-%template(PoolItemSet) std::set<PoolItem_Ref>;
-%apply std::set<PoolItem_Ref>::const_iterator { ResPool::const_iterator };
+
%apply unsigned { ResPool::size_type };
-#endif
class ResPool
{
#endif
#ifdef SWIGPYTHON
+%template(PoolItemSet) std::set<PoolItem_Ref>;
%newobject ResPool::const_iterator(PyObject **PYTHON_SELF);
%extend ResPool {
swig::PySwigIterator* iterator(PyObject **PYTHON_SELF)
return swig::make_output_iterator(self->begin(), self->begin(),
self->end(), *PYTHON_SELF);
}
+ swig::PySwigIterator* kinditerator(PyObject **PYTHON_SELF, const ResObject::Kind & kind_r)
+ {
+ return swig::make_output_iterator(self->byKindBegin( kind_r ), self->byKindBegin( kind_r ),
+ self->byKindEnd( kind_r ), *PYTHON_SELF);
+ }
+ swig::PySwigIterator* nameiterator(PyObject **PYTHON_SELF, const std::string &name)
+ {
+ return swig::make_output_iterator(self->byNameBegin( name ), self->byNameBegin( name ),
+ self->byNameEnd( name ), *PYTHON_SELF);
+ }
%pythoncode {
def __iter__(self): return self.iterator()
+ def byKindIterator(self, kind): return self.kinditerator(kind)
+ def byNameIterator(self, name): return self.nameiterator(name)
}
}
--- /dev/null
+
+/** Base of ResTraits. Defines the Resolvable::Kind type. */
+struct ResolvableTraits
+{
+ typedef KindOf<Resolvable> KindType;
+};
+
+/** ResTraits. Defines common types and the Kind value. */
+template<typename _Res>
+ struct ResTraits : public ResolvableTraits
+ {
+ typedef intrusive_ptr<_Res> PtrType;
+ typedef intrusive_ptr<const _Res> constPtrType;
+ };
+
+%template(ResTraitsResolvable) ResTraits<Resolvable>;
+
+%pythoncode
+{
+ def KindOfPackage():
+ return KindOfResolvable( "package" )
+ def KindOfSrcPackage():
+ return KindOfResolvable( "srcpackage" )
+ def KindOfPatch():
+ return KindOfResolvable( "patch" )
+ def KindOfPattern():
+ return KindOfResolvable( "pattern" )
+ def KindOfProduct():
+ return KindOfResolvable( "product" )
+ def KindOfAtom():
+ return KindOfResolvable( "atom" )
+ def KindOfScript():
+ return KindOfResolvable( "script" )
+ def KindOfMessage():
+ return KindOfResolvable( "message" )
+ def KindOfLanguage():
+ return KindOfResolvable( "language" )
+}
bool verifySystem (bool considerNewHardware);
bool establishPool (void);
bool freshenPool (void);
- bool resolvePool (void);
+ bool resolvePool (void);
bool resolvePool (bool tryAllPossibilities);
bool resolveDependencies( void );
void undo( void );
void doUpgrade( UpgradeStatistics & opt_stats_r );
std::list<PoolItem_Ref> problematicUpdateItems( void ) const;
ResolverProblemList problems();
- std::list<std::string> problemDescription( void ) const;
+ std::list<std::string> problemDescription( void ) const;
void applySolutions( const ProblemSolutionList & solutions );
Arch architecture() const;
void setForceResolve (const bool force);
const bool forceResolve();
void setPreferHighestVersion (const bool highestVersion);
- const bool preferHighestVersion();
+ const bool preferHighestVersion();
bool transactResObject( ResObject::constPtr robj, bool install = true);
//bool transactResKind( Resolvable::Kind kind );
void transactReset( ResStatus::TransactByValue causer );
void addRequire (const Capability & capability);
- void addConflict (const Capability & capability);
+ void addConflict (const Capability & capability);
void setTimeout( int seconds );
- int timeout();
+ int timeout();
void setMaxSolverPasses (int count);
int maxSolverPasses ();
bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
solver::detail::Resolver_Ptr _pimpl;
};
+typedef intrusive_ptr<Resolver> Resolver_Ptr;
+%template(Resolver_Ptr) intrusive_ptr<Resolver>;
%include "ResStore.i"
%include "Edition.i"
%include "Kind.i"
+%include "ResTraits.i"
%include "Date.i"
%include "Capability.i"
%include "CapSet.i"
%include "NVRA.i"
%include "NVRAD.i"
%include "Package.i"
+%include "Patch.i"
%include "PublicKey.i"
%include "KeyRing.i"
%include "Target.i"