[libgda] Added sources to build DB as Collection set of interfaces and fixes.
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Added sources to build DB as Collection set of interfaces and fixes.
- Date: Fri, 23 Dec 2011 18:02:43 +0000 (UTC)
commit 609552cacc66c9a2026c438d000ff573cd94bc7e
Author: Daniel Espinosa <despinosa src gnome org>
Date: Fri Dec 23 11:58:39 2011 -0600
Added sources to build DB as Collection set of interfaces and fixes.
* Added and fixed to build sources for DB Collection
* DataModelIterable moved to a independient file
* Moved out from build Selectable sources until they build or have better
hierarchy solution
libgda/data/DataModelIterable.vala | 370 ++++++++++++++++++++++++++++++++++++
libgda/data/DataModelIterator.vala | 346 ---------------------------------
libgda/data/DbCollection.vala | 10 +-
libgda/data/DbField.vala | 6 +-
libgda/data/DbRecord.vala | 2 +-
libgda/data/DbSchema.vala | 2 +-
libgda/data/DbTable.vala | 34 ++++
libgda/data/GdaData-5.0.gir | 231 ++++++++++++++++++++---
libgda/data/Makefile.am | 25 +++-
libgda/data/SqlExpression.vala | 6 +-
libgda/data/SqlWhere.vala | 6 +-
11 files changed, 649 insertions(+), 389 deletions(-)
---
diff --git a/libgda/data/DataModelIterable.vala b/libgda/data/DataModelIterable.vala
new file mode 100644
index 0000000..8be273c
--- /dev/null
+++ b/libgda/data/DataModelIterable.vala
@@ -0,0 +1,370 @@
+/* -*- Mode: Vala; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * libgdadata
+ * Copyright (C) Daniel Espinosa Ortiz 2011 <esodan gmail com>
+ *
+ * libgda is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libgda is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ using Gee;
+ using Gda;
+
+ namespace GdaData {
+
+ public class DataModelIterable : Gee.AbstractCollection<Value?>, Gda.DataModel
+ {
+ private Gda.DataModel model;
+
+ public DataModelIterable (Gda.DataModel model) {
+ this.model = model;
+ }
+
+ // Iterable Interface
+
+ public Type element_type {
+ get { return typeof (GLib.Value); }
+ }
+
+ public override Iterator<Value?> iterator ()
+ {
+ return new DataModelIterator (this.model);
+ }
+
+ // Traversable Interface
+
+ public override Gee.Iterator<Value?> chop (int offset, int length = -1)
+ {
+ var iter = new DataModelIterator (this.model);
+ return iter.chop (offset, length);
+ }
+
+ public override Gee.Iterator<Value?> filter (owned Gee.Predicate<Value?> f)
+ {
+ var iter = new DataModelIterator (this.model);
+ return iter.filter (f);
+ }
+
+ public new void @foreach (Gee.ForallFunc<Value?> f)
+ {
+ try {
+ for (int i = 0; i < this.model.get_n_rows (); i++) {
+ for (int j = 0; j < this.model.get_n_columns (); j++) {
+ Value v = this.model.get_value_at (i, j);
+ f(v);
+ }
+ }
+ } catch {}
+ }
+
+ public override Gee.Iterator<A> stream<A> (owned Gee.StreamFunc<Value?,A> f)
+ {
+ var iter = new DataModelIterator (this.model);
+ return iter.stream<A> (f);
+ }
+
+ // Interface Collection
+ public override bool add (Value? item) {
+ try {
+ int i = this.model.append_row ();
+ if (i >= 0)
+ return true;
+ } catch {}
+
+ return false;
+ }
+
+ /**
+ * { inheritDoc}
+ *
+ * { inheritDoc}<< BR >>
+ * << BR >>
+ * collection must include just values for one row, with the same type expected in the table.<<BR>>
+ * <<BR>>
+ * If the collection is a database proxy, you need to apply to make changes permanently.
+ */
+ public override bool add_all (Gee.Collection<Value?> collection)
+ requires (collection.size == this.model.get_n_columns ())
+ {
+ try {
+ var vals = collection.to_array ();
+ for (int i = 0; i < this.model.get_n_columns (); i++) {
+ var v = this.model.get_value_at (i, 0);
+ if (vals[i].type () != v.type ())
+ return false;
+ }
+
+ var r = this.model.append_row ();
+ for (int j = 0; j < this.model.get_n_columns (); j++) {
+ var v2 = vals[j];
+ try {
+ this.model.set_value_at (j, r, v2);
+ }
+ catch {
+ return false;
+ }
+ }
+ } catch {}
+ return true;
+ }
+
+ /**
+ * { inheritDoc}
+ *
+ * { inheritDoc}<< BR >>
+ * <<BR>>
+ * If the collection is a proxy, you need to apply to make changes permanently.
+ */
+ public override void clear () {
+ try {
+ for (int i = 0; i < this.model.get_n_rows (); i++ ) {
+ this.model.remove_row (i);
+ }
+ } catch {}
+ }
+
+ public override bool contains (Value? item)
+ {
+ try {
+ for (int r = 0; r < this.model.get_n_rows (); r++) {
+ for (int c = 0; c < this.model.get_n_columns (); c++) {
+ Value v = this.model.get_value_at (c, r);
+ if (Gda.value_compare (v, item) == 0)
+ return true;
+ }
+ }
+ } catch {}
+ return false;
+ }
+
+ public override bool contains_all (Gee.Collection<Value?> collection)
+ {
+ bool ret = true;
+ foreach (Value v in collection) {
+ if (this.contains (v))
+ continue;
+ else
+ ret = false;
+ }
+
+ return ret;
+ }
+
+ /**
+ * { inheritDoc}
+ *
+ * { inheritDoc}<< BR >>
+ * << BR >>
+ * Search for the first item in the collection that match item and removes it.<<BR>>
+ * <<BR>>
+ * ''Caution:'' Removing a single value removes all the row.
+ * <<BR>>
+ * If the collection is a database proxy, you need to apply to make changes permanently.
+ */
+ public override bool remove (Value? item) {
+ for (int r = 0; r < this.model.get_n_rows (); r++) {
+ for (int c = 0; c < this.model.get_n_columns (); c++) {
+ try {
+ Value v = this.model.get_value_at (c, r);
+ if (Gda.value_compare (v, item) == 0) {
+ this.model.remove_row (r);
+ return true;
+ }
+ }
+ catch {
+ continue;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * { inheritDoc}
+ *
+ * { inheritDoc}<< BR >>
+ * << BR >>
+ * Search for the first item in the collection that match item and removes it.<<BR>>
+ * <<BR>>
+ * ''Caution:'' Removing a single value removes all the row and its values.
+ * <<BR>>
+ * If the collection is a database proxy, you need to apply to make changes permanently.
+ */
+ public override bool remove_all (Gee.Collection<Value?> collection)
+ {
+ foreach (Value v in collection) {
+ for (int r = 0; r < this.model.get_n_rows (); r++) {
+ for (int c = 0; c < this.model.get_n_columns (); c++) {
+ try {
+ Value v2 = this.model.get_value_at (c, r);
+ if (Gda.value_compare (v2, v) == 0) {
+ try {
+ this.model.remove_row (r);
+ }
+ catch {
+ return false;
+ }
+ }
+ }
+ catch {
+ continue;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * { inheritDoc}
+ *
+ * { inheritDoc}<< BR >>
+ * << BR >>
+ * Search for the first item in the collection that match item and removes it.<<BR>>
+ * <<BR>>
+ * ''Caution:'' Removing a single value removes all the row and its values.
+ * <<BR>>
+ * If the collection is a database proxy, you need to apply to make changes permanently.
+ */
+ public override bool retain_all (Gee.Collection<Value?> collection)
+ {
+ foreach (Value v in collection) {
+ for (int r = 0; r < this.model.get_n_rows (); r++) {
+ for (int c = 0; c < this.model.get_n_columns (); c++) {
+ try {
+ Value v2 = this.model.get_value_at (c, r);
+ if (Gda.value_compare (v2, v) != 0) {
+ try {
+ this.model.remove_row (r);
+ }
+ catch {
+ return false;
+ }
+ }
+ }
+ catch {
+ continue;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public override bool is_empty {
+ get {
+ if (this.model.get_n_rows () <= 0)
+ return true;
+
+ return false;
+ }
+ }
+ public override bool read_only {
+ get {
+ if (this.model is Gda.DataProxy)
+ return ((Gda.DataProxy) this.model).is_read_only ();
+
+ return true;
+ }
+ }
+ public override Gee.Collection<Value?> read_only_view {
+ owned get {
+ if (this.model is Gda.DataProxy)
+ return (Gee.Collection<Value?>)
+ new DataModelIterable (((DataProxy)this.model).get_proxied_model ());
+ return (Gee.Collection<Value?>) new DataModelIterable (this.model);
+ }
+ }
+
+ public override int size {
+ get {
+ return this.model.get_n_columns () * this.model.get_n_rows ();
+ }
+ }
+
+ // Interface Gda.DataModel
+ public int append_row () throws GLib.Error {
+ return this.model.append_row ();
+ }
+
+ public Gda.DataModelIter create_iter () {
+ return this.model.create_iter ();
+ }
+
+ public unowned Gda.Column describe_column (int col) {
+ return this.model.describe_column (col);
+ }
+
+ public Gda.DataModelAccessFlags get_access_flags () {
+ return this.model.get_access_flags ();
+ }
+
+ public Gda.ValueAttribute get_attributes_at (int col, int row) {
+ return this.model.get_attributes_at (col, row);
+ }
+
+ public int get_n_columns () {
+ return this.model.get_n_columns ();
+ }
+
+ public int get_n_rows () {
+ return this.model.get_n_rows ();
+ }
+
+ public unowned GLib.Value? get_value_at (int col, int row) throws GLib.Error {
+ return this.model.get_value_at (col, row);
+ }
+
+ // THIS FUNCTIONS HAVEN'T DEFAULT IMPLEMENTATION OR PUBLIC API AND THEN CAN'T BE IMPLEMENTED HERE
+ public bool get_notify () {
+
+ return this.model.get_notify ();
+ }
+
+ public bool iter_at_row (Gda.DataModelIter iter, int row) {
+ return this.model.iter_at_row (iter, row);
+ }
+
+ public bool iter_next (Gda.DataModelIter iter) {
+ return this.model.iter_next (iter);
+ }
+
+ public bool iter_prev (Gda.DataModelIter iter) {
+ return this.model.iter_prev (iter);
+ }
+
+ public bool iter_set_value (Gda.DataModelIter iter, int col, GLib.Value value) throws GLib.Error {
+ return this.model.iter_set_value (iter, col, value);
+ }
+
+ public void set_notify (bool do_notify_changes)
+ {
+ this.model.set_notify (do_notify_changes);
+ }
+ public bool remove_row (int row) throws GLib.Error {
+ return this.model.remove_row (row);
+ }
+
+ public void send_hint (Gda.DataModelHint hint, GLib.Value? hint_value) {
+ this.model.send_hint (hint, hint_value);
+ }
+
+ public bool set_value_at (int col, int row, GLib.Value value) throws GLib.Error {
+ return this.model.set_value_at (col, row, value);
+ }
+ }
+ }
+
diff --git a/libgda/data/DataModelIterator.vala b/libgda/data/DataModelIterator.vala
index c610eb9..ce0f6e3 100644
--- a/libgda/data/DataModelIterator.vala
+++ b/libgda/data/DataModelIterator.vala
@@ -21,352 +21,6 @@
using Gda;
namespace GdaData {
-
- public class DataModelIterable : Gee.AbstractCollection<Value?>, Gda.DataModel
- {
- private Gda.DataModel model;
-
- public DataModelIterable (Gda.DataModel model) {
- this.model = model;
- }
-
- // Iterable Interface
-
- public Type element_type {
- get { return typeof (GLib.Value); }
- }
-
- public override Iterator<Value?> iterator ()
- {
- return new DataModelIterator (this.model);
- }
-
- // Traversable Interface
-
- public override Gee.Iterator<Value?> chop (int offset, int length = -1)
- {
- var iter = new DataModelIterator (this.model);
- return iter.chop (offset, length);
- }
-
- public override Gee.Iterator<Value?> filter (owned Gee.Predicate<Value?> f)
- {
- var iter = new DataModelIterator (this.model);
- return iter.filter (f);
- }
-
- public new void @foreach (Gee.ForallFunc<Value?> f)
- {
- try {
- for (int i = 0; i < this.model.get_n_rows (); i++) {
- for (int j = 0; j < this.model.get_n_columns (); j++) {
- Value v = this.model.get_value_at (i, j);
- f(v);
- }
- }
- } catch {}
- }
-
- public override Gee.Iterator<A> stream<A> (owned Gee.StreamFunc<Value?,A> f)
- {
- var iter = new DataModelIterator (this.model);
- return iter.stream<A> (f);
- }
-
- // Interface Collection
- public override bool add (Value? item) {
- try {
- int i = this.model.append_row ();
- if (i >= 0)
- return true;
- } catch {}
-
- return false;
- }
-
- /**
- * { inheritDoc}
- *
- * { inheritDoc}<< BR >>
- * << BR >>
- * collection must include just values for one row, with the same type expected in the table.<<BR>>
- * <<BR>>
- * If the collection is a database proxy, you need to apply to make changes permanently.
- */
- public override bool add_all (Gee.Collection<Value?> collection)
- requires (collection.size == this.model.get_n_columns ())
- {
- try {
- var vals = collection.to_array ();
- for (int i = 0; i < this.model.get_n_columns (); i++) {
- var v = this.model.get_value_at (i, 0);
- if (vals[i].type () != v.type ())
- return false;
- }
-
- var r = this.model.append_row ();
- for (int j = 0; j < this.model.get_n_columns (); j++) {
- var v2 = vals[j];
- try {
- this.model.set_value_at (j, r, v2);
- }
- catch {
- return false;
- }
- }
- } catch {}
- return true;
- }
-
- /**
- * { inheritDoc}
- *
- * { inheritDoc}<< BR >>
- * <<BR>>
- * If the collection is a proxy, you need to apply to make changes permanently.
- */
- public override void clear () {
- try {
- for (int i = 0; i < this.model.get_n_rows (); i++ ) {
- this.model.remove_row (i);
- }
- } catch {}
- }
-
- public override bool contains (Value? item)
- {
- try {
- for (int r = 0; r < this.model.get_n_rows (); r++) {
- for (int c = 0; c < this.model.get_n_columns (); c++) {
- Value v = this.model.get_value_at (c, r);
- if (Gda.value_compare (v, item) == 0)
- return true;
- }
- }
- } catch {}
- return false;
- }
-
- public override bool contains_all (Gee.Collection<Value?> collection)
- {
- bool ret = true;
- foreach (Value v in collection) {
- if (this.contains (v))
- continue;
- else
- ret = false;
- }
-
- return ret;
- }
-
- /**
- * { inheritDoc}
- *
- * { inheritDoc}<< BR >>
- * << BR >>
- * Search for the first item in the collection that match item and removes it.<<BR>>
- * <<BR>>
- * ''Caution:'' Removing a single value removes all the row.
- * <<BR>>
- * If the collection is a database proxy, you need to apply to make changes permanently.
- */
- public override bool remove (Value? item) {
- for (int r = 0; r < this.model.get_n_rows (); r++) {
- for (int c = 0; c < this.model.get_n_columns (); c++) {
- try {
- Value v = this.model.get_value_at (c, r);
- if (Gda.value_compare (v, item) == 0) {
- this.model.remove_row (r);
- return true;
- }
- }
- catch {
- continue;
- }
- }
- }
-
- return false;
- }
-
- /**
- * { inheritDoc}
- *
- * { inheritDoc}<< BR >>
- * << BR >>
- * Search for the first item in the collection that match item and removes it.<<BR>>
- * <<BR>>
- * ''Caution:'' Removing a single value removes all the row and its values.
- * <<BR>>
- * If the collection is a database proxy, you need to apply to make changes permanently.
- */
- public override bool remove_all (Gee.Collection<Value?> collection)
- {
- foreach (Value v in collection) {
- for (int r = 0; r < this.model.get_n_rows (); r++) {
- for (int c = 0; c < this.model.get_n_columns (); c++) {
- try {
- Value v2 = this.model.get_value_at (c, r);
- if (Gda.value_compare (v2, v) == 0) {
- try {
- this.model.remove_row (r);
- }
- catch {
- return false;
- }
- }
- }
- catch {
- continue;
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * { inheritDoc}
- *
- * { inheritDoc}<< BR >>
- * << BR >>
- * Search for the first item in the collection that match item and removes it.<<BR>>
- * <<BR>>
- * ''Caution:'' Removing a single value removes all the row and its values.
- * <<BR>>
- * If the collection is a database proxy, you need to apply to make changes permanently.
- */
- public override bool retain_all (Gee.Collection<Value?> collection)
- {
- foreach (Value v in collection) {
- for (int r = 0; r < this.model.get_n_rows (); r++) {
- for (int c = 0; c < this.model.get_n_columns (); c++) {
- try {
- Value v2 = this.model.get_value_at (c, r);
- if (Gda.value_compare (v2, v) != 0) {
- try {
- this.model.remove_row (r);
- }
- catch {
- return false;
- }
- }
- }
- catch {
- continue;
- }
- }
- }
- }
-
- return true;
- }
-
- public override bool is_empty {
- get {
- if (this.model.get_n_rows () <= 0)
- return true;
-
- return false;
- }
- }
- public override bool read_only {
- get {
- if (this.model is Gda.DataProxy)
- return ((Gda.DataProxy) this.model).is_read_only ();
-
- return true;
- }
- }
- public override Gee.Collection<Value?> read_only_view {
- owned get {
- if (this.model is Gda.DataProxy)
- return (Gee.Collection<Value?>)
- new DataModelIterable (((DataProxy)this.model).get_proxied_model ());
- return (Gee.Collection<Value?>) new DataModelIterable (this.model);
- }
- }
-
- public override int size {
- get {
- return this.model.get_n_columns () * this.model.get_n_rows ();
- }
- }
-
- // Interface Gda.DataModel
- public int append_row () throws GLib.Error {
- return this.model.append_row ();
- }
-
- public Gda.DataModelIter create_iter () {
- return this.model.create_iter ();
- }
-
- public unowned Gda.Column describe_column (int col) {
- return this.model.describe_column (col);
- }
-
- public Gda.DataModelAccessFlags get_access_flags () {
- return this.model.get_access_flags ();
- }
-
- public Gda.ValueAttribute get_attributes_at (int col, int row) {
- return this.model.get_attributes_at (col, row);
- }
-
- public int get_n_columns () {
- return this.model.get_n_columns ();
- }
-
- public int get_n_rows () {
- return this.model.get_n_rows ();
- }
-
- public unowned GLib.Value? get_value_at (int col, int row) throws GLib.Error {
- return this.model.get_value_at (col, row);
- }
-
- // THIS FUNCTIONS HAVEN'T DEFAULT IMPLEMENTATION OR PUBLIC API AND THEN CAN'T BE IMPLEMENTED HERE
- public bool get_notify () {
-
- return this.model.get_notify ();
- }
-
- public bool iter_at_row (Gda.DataModelIter iter, int row) {
- return this.model.iter_at_row (iter, row);
- }
-
- public bool iter_next (Gda.DataModelIter iter) {
- return this.model.iter_next (iter);
- }
-
- public bool iter_prev (Gda.DataModelIter iter) {
- return this.model.iter_prev (iter);
- }
-
- public bool iter_set_value (Gda.DataModelIter iter, int col, GLib.Value value) throws GLib.Error {
- return this.model.iter_set_value (iter, col, value);
- }
-
- public void set_notify (bool do_notify_changes)
- {
- this.model.set_notify (do_notify_changes);
- }
- public bool remove_row (int row) throws GLib.Error {
- return this.model.remove_row (row);
- }
-
- public void send_hint (Gda.DataModelHint hint, GLib.Value? hint_value) {
- this.model.send_hint (hint, hint_value);
- }
-
- public bool set_value_at (int col, int row, GLib.Value value) throws GLib.Error {
- return this.model.set_value_at (col, row, value);
- }
- }
-
/**
* Iterator that implements [ link [Gee.Iterator] and [ link [Gee.Traversable]]
*/
diff --git a/libgda/data/DbCollection.vala b/libgda/data/DbCollection.vala
index e9a48c3..1461d39 100644
--- a/libgda/data/DbCollection.vala
+++ b/libgda/data/DbCollection.vala
@@ -22,16 +22,10 @@ using Gda;
namespace GdaData
{
- public interface DbCollection : Object
+ public interface DbCollection : GLib.Object
{
public abstract Collection<DbSchema> schemas { get; }
- public static Collection<Table> get_tables (string schema) {
- foreach (DbShema sh in shemas) {
- if (sh.name == schema) {
- return sh.tables;
- }
- }
- }
+ public abstract Collection<DbTable> get_tables (string schema);
}
}
diff --git a/libgda/data/DbField.vala b/libgda/data/DbField.vala
index 01d0f34..18da3a2 100644
--- a/libgda/data/DbField.vala
+++ b/libgda/data/DbField.vala
@@ -22,10 +22,10 @@ using Gda;
namespace GdaData
{
- public abstract class DbField<G> : Object
+ public abstract class DbField<G> : GLib.Object
{
- public abstract DbRecord record { get; set construct; };
- public abstract G value { get; set; };
+ public abstract DbRecord record { get; set construct; }
+ public abstract G value { get; set; }
public abstract string name { get; set; }
public abstract string column_name { get; set; }
public abstract DbField.Attribute attributes { get; set construct; }
diff --git a/libgda/data/DbRecord.vala b/libgda/data/DbRecord.vala
index cec6986..759874e 100644
--- a/libgda/data/DbRecord.vala
+++ b/libgda/data/DbRecord.vala
@@ -22,7 +22,7 @@ using Gda;
namespace GdaData
{
- public interface DbRecord : Object
+ public interface DbRecord : GLib.Object
{
public abstract DbTable table { get; set construct; }
public abstract Collection<DbField> fields { get; }
diff --git a/libgda/data/DbSchema.vala b/libgda/data/DbSchema.vala
index 01cd2ba..93fba36 100644
--- a/libgda/data/DbSchema.vala
+++ b/libgda/data/DbSchema.vala
@@ -22,7 +22,7 @@ using Gda;
namespace GdaData
{
- public interface DbSchema : Object
+ public interface DbSchema : GLib.Object
{
public abstract string name { get; set; }
public abstract Collection<DbTable> tables { get; }
diff --git a/libgda/data/DbTable.vala b/libgda/data/DbTable.vala
new file mode 100644
index 0000000..5f2c9c3
--- /dev/null
+++ b/libgda/data/DbTable.vala
@@ -0,0 +1,34 @@
+/* -*- Mode: Vala; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * libgdadata
+ * Copyright (C) Daniel Espinosa Ortiz 2011 <esodan gmail com>
+ *
+ * libgda is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libgda is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using Gee;
+using Gda;
+
+namespace GdaData
+{
+ public interface DbTable : GLib.Object
+ {
+ public abstract DbSchema schema { get; set construct; }
+ public abstract string name { get; set; }
+ public abstract Collection<DbRecord> tables { get; }
+ public abstract Collection<DbTable> fk_depends { get; }
+ public abstract Collection<DbTable> fk { get; }
+ public abstract Iterator<DbRecord> iterator ();
+ }
+}
diff --git a/libgda/data/GdaData-5.0.gir b/libgda/data/GdaData-5.0.gir
index 9328cbd..947ced4 100644
--- a/libgda/data/GdaData-5.0.gir
+++ b/libgda/data/GdaData-5.0.gir
@@ -98,6 +98,80 @@
</field>
</record>
<record name="ObjectPrivate" c:type="GdaDataObjectPrivate" disguised="1"/>
+ <class name="DbField" c:type="GdaDataDbField" glib:type-name="GdaDataDbField" glib:get-type="gda_data_db_field_get_type" glib:type-struct="DbFieldClass" parent="GObject.Object" abstract="1">
+ <field name="parent_instance">
+ <type name="GObject.Object" c:type="GObject"/>
+ </field>
+ <field name="priv">
+ <type name="DbFieldPrivate" c:type="GdaDataDbFieldPrivate*"/>
+ </field>
+ <property name="record" writable="1" construct="1">
+ <type name="GdaData.DbRecord" c:type="GdaDataDbRecord*"/>
+ </property>
+ <property name="value" writable="1">
+ <type name="gpointer" c:type="gpointer"/>
+ </property>
+ <property name="name" writable="1">
+ <type name="utf8" c:type="gchar*"/>
+ </property>
+ <property name="column-name" writable="1">
+ <type name="utf8" c:type="gchar*"/>
+ </property>
+ <property name="attributes" writable="1" construct="1">
+ <type name="GdaData.DbFieldAttribute" c:type="GdaDataDbFieldAttribute"/>
+ </property>
+ </class>
+ <record name="DbFieldClass" c:type="GdaDataDbFieldClass" glib:is-gtype-struct-for="DbField">
+ <field name="parent_class">
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
+ </field>
+ </record>
+ <record name="DbFieldPrivate" c:type="GdaDataDbFieldPrivate" disguised="1"/>
+ <bitfield name="DbFieldAttribute" c:type="GdaDataDbFieldAttribute" glib:type-name="GdaDataDbFieldAttribute" glib:get-type="gda_data_db_field_attribute_get_type">
+ <member name="none" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_NONE" value="1"/>
+ <member name="is_null" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_IS_NULL" value="2"/>
+ <member name="can_be_null" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_CAN_BE_NULL" value="4"/>
+ <member name="is_default" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_IS_DEFAULT" value="8"/>
+ <member name="can_be_default" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_CAN_BE_DEFAULT" value="16"/>
+ <member name="is_unchanged" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_IS_UNCHANGED" value="32"/>
+ <member name="actions_shown" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_ACTIONS_SHOWN" value="64"/>
+ <member name="data_non_valid" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_DATA_NON_VALID" value="128"/>
+ <member name="has_value_orig" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_HAS_VALUE_ORIG" value="256"/>
+ <member name="no_modif" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_NO_MODIF" value="512"/>
+ <member name="unused" c:identifier="GDA_DATA_DB_FIELD_ATTRIBUTE_UNUSED" value="1024"/>
+ </bitfield>
+ <class name="DataModelIterator" c:type="GdaDataDataModelIterator" glib:type-name="GdaDataDataModelIterator" glib:get-type="gda_data_data_model_iterator_get_type" glib:type-struct="DataModelIteratorClass" parent="GObject.Object">
+ <implements name="Gee.Traversable"/>
+ <implements name="Gee.Iterator"/>
+ <field name="parent_instance">
+ <type name="GObject.Object" c:type="GObject"/>
+ </field>
+ <field name="priv">
+ <type name="DataModelIteratorPrivate" c:type="GdaDataDataModelIteratorPrivate*"/>
+ </field>
+ <constructor name="new" c:identifier="gda_data_data_model_iterator_new">
+ <parameters>
+ <parameter name="model" transfer-ownership="none">
+ <type name="Gda.DataModel" c:type="GdaDataModel*"/>
+ </parameter>
+ </parameters>
+ <return-value transfer-ownership="full">
+ <type name="GdaData.DataModelIterator" c:type="GdaDataDataModelIterator*"/>
+ </return-value>
+ </constructor>
+ <property name="current-column">
+ <type name="gint" c:type="gint"/>
+ </property>
+ <property name="current-row">
+ <type name="gint" c:type="gint"/>
+ </property>
+ </class>
+ <record name="DataModelIteratorClass" c:type="GdaDataDataModelIteratorClass" glib:is-gtype-struct-for="DataModelIterator">
+ <field name="parent_class">
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
+ </field>
+ </record>
+ <record name="DataModelIteratorPrivate" c:type="GdaDataDataModelIteratorPrivate" disguised="1"/>
<class name="DataModelIterable" c:type="GdaDataDataModelIterable" glib:type-name="GdaDataDataModelIterable" glib:get-type="gda_data_data_model_iterable_get_type" glib:type-struct="DataModelIterableClass" parent="Gee.AbstractCollection">
<implements name="Gda.DataModel"/>
<field name="parent_instance">
@@ -139,37 +213,148 @@
</field>
</record>
<record name="DataModelIterablePrivate" c:type="GdaDataDataModelIterablePrivate" disguised="1"/>
- <class name="DataModelIterator" c:type="GdaDataDataModelIterator" glib:type-name="GdaDataDataModelIterator" glib:get-type="gda_data_data_model_iterator_get_type" glib:type-struct="DataModelIteratorClass" parent="GObject.Object">
- <implements name="Gee.Traversable"/>
- <implements name="Gee.Iterator"/>
- <field name="parent_instance">
- <type name="GObject.Object" c:type="GObject"/>
- </field>
- <field name="priv">
- <type name="DataModelIteratorPrivate" c:type="GdaDataDataModelIteratorPrivate*"/>
- </field>
- <constructor name="new" c:identifier="gda_data_data_model_iterator_new">
+ <interface name="DbCollection" c:type="GdaDataDbCollection" glib:type-name="GdaDataDbCollection" glib:get-type="gda_data_db_collection_get_type" glib:type-struct="DbCollectionIface">
+ <prerequisite name="GObject.Object"/>
+ <method name="get_tables" c:identifier="gda_data_db_collection_get_tables">
<parameters>
- <parameter name="model" transfer-ownership="none">
- <type name="Gda.DataModel" c:type="GdaDataModel*"/>
+ <parameter name="schema" transfer-ownership="none">
+ <type name="utf8" c:type="const gchar*"/>
</parameter>
</parameters>
<return-value transfer-ownership="full">
- <type name="GdaData.DataModelIterator" c:type="GdaDataDataModelIterator*"/>
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbTable" c:type="GdaDataDbTable*"/>
+ </type>
</return-value>
- </constructor>
- <property name="current-column">
- <type name="gint" c:type="gint"/>
+ </method>
+ <virtual-method name="get_tables" invoker="get_tables">
+ <parameters>
+ <parameter name="schema" transfer-ownership="none">
+ <type name="utf8" c:type="const gchar*"/>
+ </parameter>
+ </parameters>
+ <return-value transfer-ownership="full">
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbTable" c:type="GdaDataDbTable*"/>
+ </type>
+ </return-value>
+ </virtual-method>
+ <property name="schemas">
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbSchema" c:type="GdaDataDbSchema*"/>
+ </type>
</property>
- <property name="current-row">
- <type name="gint" c:type="gint"/>
+ </interface>
+ <record name="DbCollectionIface" c:type="GdaDataDbCollectionIface" glib:is-gtype-struct-for="DbCollection">
+ <field name="parent_iface">
+ <type name="GObject.TypeInterface" c:type="GTypeInterface"/>
+ </field>
+ <field name="get_tables">
+ <callback name="get_tables" c:type="get_tables">
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="GdaData.DbCollection" c:type="GdaDataDbCollection*"/>
+ </parameter>
+ <parameter name="schema" transfer-ownership="none">
+ <type name="utf8" c:type="const gchar*"/>
+ </parameter>
+ </parameters>
+ <return-value transfer-ownership="full">
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbTable" c:type="GdaDataDbTable*"/>
+ </type>
+ </return-value>
+ </callback>
+ </field>
+ </record>
+ <interface name="DbTable" c:type="GdaDataDbTable" glib:type-name="GdaDataDbTable" glib:get-type="gda_data_db_table_get_type" glib:type-struct="DbTableIface">
+ <prerequisite name="GObject.Object"/>
+ <method name="iterator" c:identifier="gda_data_db_table_iterator">
+ <return-value transfer-ownership="full">
+ <type name="Gee.Iterator" c:type="GeeIterator*">
+ <type name="GdaData.DbRecord" c:type="GdaDataDbRecord*"/>
+ </type>
+ </return-value>
+ </method>
+ <virtual-method name="iterator" invoker="iterator">
+ <return-value transfer-ownership="full">
+ <type name="Gee.Iterator" c:type="GeeIterator*">
+ <type name="GdaData.DbRecord" c:type="GdaDataDbRecord*"/>
+ </type>
+ </return-value>
+ </virtual-method>
+ <property name="schema" writable="1" construct="1">
+ <type name="GdaData.DbSchema" c:type="GdaDataDbSchema*"/>
</property>
- </class>
- <record name="DataModelIteratorClass" c:type="GdaDataDataModelIteratorClass" glib:is-gtype-struct-for="DataModelIterator">
- <field name="parent_class">
- <type name="GObject.ObjectClass" c:type="GObjectClass"/>
+ <property name="name" writable="1">
+ <type name="utf8" c:type="gchar*"/>
+ </property>
+ <property name="tables">
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbRecord" c:type="GdaDataDbRecord*"/>
+ </type>
+ </property>
+ <property name="fk-depends">
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbTable" c:type="GdaDataDbTable*"/>
+ </type>
+ </property>
+ <property name="fk">
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbTable" c:type="GdaDataDbTable*"/>
+ </type>
+ </property>
+ </interface>
+ <record name="DbTableIface" c:type="GdaDataDbTableIface" glib:is-gtype-struct-for="DbTable">
+ <field name="parent_iface">
+ <type name="GObject.TypeInterface" c:type="GTypeInterface"/>
+ </field>
+ <field name="iterator">
+ <callback name="iterator" c:type="iterator">
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="GdaData.DbTable" c:type="GdaDataDbTable*"/>
+ </parameter>
+ </parameters>
+ <return-value transfer-ownership="full">
+ <type name="Gee.Iterator" c:type="GeeIterator*">
+ <type name="GdaData.DbRecord" c:type="GdaDataDbRecord*"/>
+ </type>
+ </return-value>
+ </callback>
+ </field>
+ </record>
+ <interface name="DbRecord" c:type="GdaDataDbRecord" glib:type-name="GdaDataDbRecord" glib:get-type="gda_data_db_record_get_type" glib:type-struct="DbRecordIface">
+ <prerequisite name="GObject.Object"/>
+ <property name="table" writable="1" construct="1">
+ <type name="GdaData.DbTable" c:type="GdaDataDbTable*"/>
+ </property>
+ <property name="fields">
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbField" c:type="GdaDataDbField*"/>
+ </type>
+ </property>
+ </interface>
+ <record name="DbRecordIface" c:type="GdaDataDbRecordIface" glib:is-gtype-struct-for="DbRecord">
+ <field name="parent_iface">
+ <type name="GObject.TypeInterface" c:type="GTypeInterface"/>
+ </field>
+ </record>
+ <interface name="DbSchema" c:type="GdaDataDbSchema" glib:type-name="GdaDataDbSchema" glib:get-type="gda_data_db_schema_get_type" glib:type-struct="DbSchemaIface">
+ <prerequisite name="GObject.Object"/>
+ <property name="name" writable="1">
+ <type name="utf8" c:type="gchar*"/>
+ </property>
+ <property name="tables">
+ <type name="Gee.Collection" c:type="GeeCollection*">
+ <type name="GdaData.DbTable" c:type="GdaDataDbTable*"/>
+ </type>
+ </property>
+ </interface>
+ <record name="DbSchemaIface" c:type="GdaDataDbSchemaIface" glib:is-gtype-struct-for="DbSchema">
+ <field name="parent_iface">
+ <type name="GObject.TypeInterface" c:type="GTypeInterface"/>
</field>
</record>
- <record name="DataModelIteratorPrivate" c:type="GdaDataDataModelIteratorPrivate" disguised="1"/>
</namespace>
</repository>
diff --git a/libgda/data/Makefile.am b/libgda/data/Makefile.am
index 1b7210c..7111ab6 100644
--- a/libgda/data/Makefile.am
+++ b/libgda/data/Makefile.am
@@ -31,10 +31,33 @@ VALAFLAGS = \
--pkg libgda-5.0 \
$(NULL)
-libgdadata_5_0_la_VALASOURCES = \
+object_persistance_sources = \
DataObject.vala \
SelectQuery.vala \
+ $(NULL)
+
+db_collection_sources = \
+ DbCollection.vala \
+ DbTable.vala \
+ DbRecord.vala \
+ DbField.vala \
+ DbSchema.vala \
+ $(NULL)
+
+selectable_sources = \
+ SqlWhere.vala \
+ SqlExpression.vala \
+ $(NULL)
+
+data_model_collection_sources = \
DataModelIterator.vala \
+ DataModelIterable.vala \
+ $(NULL)
+
+libgdadata_5_0_la_VALASOURCES = \
+ $(object_persistance_sources) \
+ $(db_collection_sources) \
+ $(data_model_collection_sources) \
$(NULL)
libgdadata_5_0_la_SOURCES = \
diff --git a/libgda/data/SqlExpression.vala b/libgda/data/SqlExpression.vala
index 9f4c54c..be0dae5 100644
--- a/libgda/data/SqlExpression.vala
+++ b/libgda/data/SqlExpression.vala
@@ -22,10 +22,10 @@ using Gda;
namespace GdaData
{
- public interface SqlExpression<A,G> : Object
+ public interface SqlExpression<A,G> : GLib.Object
{
- public Gee.HashTable<A,G> fields { get; }
- public Gee.HashTable<A,G> values { get; }
+ public abstract Gee.HashMap<A,G> fields { get; }
+ public abstract Gee.HashMap<A,G> values { get; }
public abstract bool verify (DbCollection db);
diff --git a/libgda/data/SqlWhere.vala b/libgda/data/SqlWhere.vala
index a5c2a10..ba093ac 100644
--- a/libgda/data/SqlWhere.vala
+++ b/libgda/data/SqlWhere.vala
@@ -22,14 +22,14 @@ using Gda;
namespace GdaData
{
- public interface SqlWhere<Expression> : Object, Traversable<Expression>, Iterable<Expression>, Collection<Expression>
+ public class SqlWhere<Expression> : GLib.Object, Traversable<Expression>, Iterable<Expression>, Collection<Expression>
{
/**
* Verify that all expressions are valid in the context of the given database collection
*/
public static Collection<Expression> verify (DbCollection db)
{
- var l = new Gee.List<Expression> ();
+ var l = new ArrayList<Expression> ();
var iter = this.iterator ();
while (iter.next ())
{
@@ -37,7 +37,7 @@ namespace GdaData
if (!e.verify (db))
l.add (e);
}
- return l;
+ return (Collection) l;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]