Mailinglist Archive: zypp-commit (171 mails)

< Previous Next >
[zypp-commit] <sat-solver> master : Add equality operator for Job
  • From: Klaus Kämpf <kkaempf@xxxxxxx>
  • Date: Tue, 23 Jun 2009 15:04:29 +0200
  • Message-id: <E1MJ5hP-0007j9-FM@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 8961216328ecddeb1a30ff934a8607164321105d
Author: Klaus Kämpf <kkaempf@xxxxxxx>
Date: Tue Jun 23 15:04:29 2009 +0200

Add equality operator for Job
---
applayer/job.c | 14 ++++++++++++++
applayer/job.h | 2 ++
bindings/job.i | 32 ++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/applayer/job.c b/applayer/job.c
index 2a4a6f5..7c6f957 100644
--- a/applayer/job.c
+++ b/applayer/job.c
@@ -65,3 +65,17 @@ job_relation( const Job *j )
}
return NULL;
}
+
+
+int
+job_equal( const Job *job1, const Job *job2 )
+{
+ if (job1 != job2)
+ {
+ if (job1->pool != job2->pool
+ || job1->cmd != job2->cmd
+ || job1->id != job2->id)
+ return 0;
+ }
+ return 1;
+}
diff --git a/applayer/job.h b/applayer/job.h
index e787ded..b916b64 100644
--- a/applayer/job.h
+++ b/applayer/job.h
@@ -45,4 +45,6 @@ const char *job_name( const Job *j );
/* Return Relation (or NULL if job doesn't affect Relation) */
Relation *job_relation( const Job *j );

+/* return non-zero if jobs are equal */
+int job_equal( const Job *job1, const Job *job2 );
#endif /* SATSOLVER_JOB_H */
diff --git a/bindings/job.i b/bindings/job.i
index ba48574..f35c1c2 100644
--- a/bindings/job.i
+++ b/bindings/job.i
@@ -52,5 +52,37 @@ typedef struct _Job {} Job;
Relation *relation()
{ return job_relation( $self ); }

+ /*
+ * Job equality
+ */
+
+#if defined(SWIGPERL)
+ /*
+ * :nodoc:
+ */
+ int __eq__( const Job *job )
+#endif
+#if defined(SWIGRUBY)
+ %typemap(out) int equal
+ "$result = $1 ? Qtrue : Qfalse;";
+ %rename("==") equal;
+ /*
+ * Equality operator
+ *
+ */
+ int equal( const Job *job )
+#endif
+
+#if defined(SWIGPYTHON)
+ /*
+ * :nodoc:
+ * Python treats 'eq' and 'ne' distinct.
+ */
+ int __ne__( const Job *job )
+ { return !job_equal($self, job); }
+ int __eq__( const Job *job )
+#endif
+ { return job_equal($self, job); }
+
}

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

< Previous Next >
This Thread
  • No further messages