Mailinglist Archive: zypp-commit (301 mails)

< Previous Next >
[zypp-commit] r7658 - in /trunk/sat-solver: bindings/ruby/satsolver.rb bindings/satsolver.i examples/ruby/basic.rb src/CMakeLists.txt src/pool.h
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Fri, 26 Oct 2007 13:57:25 -0000
  • Message-id: <20071026135725.337551737E@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Fri Oct 26 15:57:24 2007
New Revision: 7658

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7658&view=rev
Log:
- iterators for solver decisions

Modified:
trunk/sat-solver/bindings/ruby/satsolver.rb
trunk/sat-solver/bindings/satsolver.i
trunk/sat-solver/examples/ruby/basic.rb
trunk/sat-solver/src/CMakeLists.txt
trunk/sat-solver/src/pool.h

Modified: trunk/sat-solver/bindings/ruby/satsolver.rb
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/satsolver.rb?rev=7658&r1=7657&r2=7658&view=diff
==============================================================================
--- trunk/sat-solver/bindings/ruby/satsolver.rb (original)
+++ trunk/sat-solver/bindings/ruby/satsolver.rb Fri Oct 26 15:57:24 2007
@@ -1,5 +1,14 @@
require 'satsolverx'

+module Satsolverx
+ class Solvable
+# def to_s
+# "#{id_2str(self.source.pool, name)}-#{id_2str(self.source.pool,
evr)}-#{id_2str(self.source.pool, arch)}"
+# end
+ end
+end
+
module Satsolver
include Satsolverx
+
end
\ No newline at end of file

Modified: trunk/sat-solver/bindings/satsolver.i
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/satsolver.i?rev=7658&r1=7657&r2=7658&view=diff
==============================================================================
--- trunk/sat-solver/bindings/satsolver.i (original)
+++ trunk/sat-solver/bindings/satsolver.i Fri Oct 26 15:57:24 2007
@@ -20,7 +20,7 @@
#include "source.h"
#include "source_solv.h"
}
-
+#include <sstream>

%}

@@ -175,6 +175,21 @@
const char * name()
{ return id2str($self->source->pool, $self->name);}

+ %rename("to_s") asString();
+ const char * asString()
+ {
+ std::stringstream ss;
+ if ( $self->source == NULL )
+ return "<UNKNOWN>";
+
+ ss << id2str($self->source->pool, $self->name);
+ ss << "-";
+ ss << id2str($self->source->pool, $self->evr);
+ ss << "-";
+ ss << id2str($self->source->pool, $self->arch);
+ return ss.str().c_str();
+ }
+
}

%include "solver.h"
@@ -192,6 +207,51 @@

void solve(Queue *job) { solve($self, job); }
void print_decisions() { printdecisions($self); }
+
+ void each_to_install()
+ {
+ Id p;
+ Solvable *s;
+ for (int i = 0; i < $self->decisionq.count; i++)
+ {
+ p = $self->decisionq.elements[i];
+ /* conflict */
+ if (p < 0)
+ continue;
+ /* already installed resolvable */
+ if (p >= $self->system->start && p < $self->system->start +
$self->system->nsolvables)
+ continue;
+ /** system resolvable */
+ if (p == SYSTEMSOLVABLE)
+ continue;
+
+ // getting source
+ s = $self->pool->solvables + p;
+ Source *source = s->source;
+ rb_yield(SWIG_NewPointerObj((void*) s, SWIGTYPE_p__Solvable, 0));
+ }
+ }
+
+ void each_to_remove()
+ {
+ Id p;
+ Solvable *s;
+
+ /* solvables to be erased */
+ for (int i = $self->system->start;
+ i < $self->system->start + $self->system->nsolvables;
+ i++)
+ {
+ /* what is this? */
+ if ($self->decisionmap[i] > 0)
+ continue;
+
+ // getting source
+ s = $self->pool->solvables + i;
+ Source *source = s->source;
+ rb_yield(SWIG_NewPointerObj((void*) s, SWIGTYPE_p__Solvable, 0));
+ }
+ }
};

%include "source.h"

Modified: trunk/sat-solver/examples/ruby/basic.rb
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/examples/ruby/basic.rb?rev=7658&r1=7657&r2=7658&view=diff
==============================================================================
--- trunk/sat-solver/examples/ruby/basic.rb (original)
+++ trunk/sat-solver/examples/ruby/basic.rb Fri Oct 26 15:57:24 2007
@@ -18,14 +18,14 @@
end

s.each_solvable do |r|
- puts "#{r.name}"
+ puts r
end

q = Queue.new
puts q.empty?

-r = pool.select_solvable(s, 'gnome-desktop')
-puts r.name
+r = pool.select_solvable(s, 'G')
+puts r

# push one command and one resolvable to the queue
q.push(SOLVER_INSTALL_SOLVABLE)
@@ -46,4 +46,12 @@
# solve the queue
solv.solve(q)

-solv.print_decisions
\ No newline at end of file
+#solv.print_decisions
+
+solv.each_to_install do |i|
+ puts "to install #{i}"
+end
+
+solv.each_to_remove do |i|
+ puts "to remove #{i}"
+end
\ No newline at end of file

Modified: trunk/sat-solver/src/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/CMakeLists.txt?rev=7658&r1=7657&r2=7658&view=diff
==============================================================================
--- trunk/sat-solver/src/CMakeLists.txt (original)
+++ trunk/sat-solver/src/CMakeLists.txt Fri Oct 26 15:57:24 2007
@@ -4,5 +4,5 @@

ADD_LIBRARY(satsolver STATIC ${libsatsolver_SRCS})

-SET(libsatsolver_HEADERS bitmap.h evr.h hash.h poolarch.h pool.h poolid.h
pooltypes.h queue.h solvable.h solver.h source.h source_solv.h util.h )
-INSTALL( FILES ${libsatsolver_HEADERS} DESTINATION
"${CMAKE_INSTALL_PREFIX}/include/satsolver" )
+#SET(libsatsolver_HEADERS bitmap.h evr.h hash.h poolarch.h pool.h poolid.h
pooltypes.h queue.h solvable.h solver.h source.h source_solv.h util.h )
+#INSTALL( FILES ${libsatsolver_HEADERS} DESTINATION
"${CMAKE_INSTALL_PREFIX}/include/satsolver" )

Modified: trunk/sat-solver/src/pool.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.h?rev=7658&r1=7657&r2=7658&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.h (original)
+++ trunk/sat-solver/src/pool.h Fri Oct 26 15:57:24 2007
@@ -134,9 +134,21 @@
#define REL_WITH 18
#define REL_NAMESPACE 19

+/**
+ * Creates a new pool
+ */
extern Pool *pool_create(void);
+/**
+ * Delete a pool
+ */
extern void pool_free(Pool *pool);
+/**
+ * ????
+ */
extern void pool_freesource(Pool *pool, Source *source);
+/**
+ * Prepares a pool for solving
+ */
extern void pool_prepare(Pool *pool);
extern void pool_freewhatprovides(Pool *pool);
extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);

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

< Previous Next >
This Thread
  • No further messages