2013-10-11 23:07:35 +00:00
|
|
|
/*
|
2014-09-18 11:06:06 +00:00
|
|
|
* Copyright (C) 2014 - Juan Ferrer Toribio
|
2013-10-11 23:07:35 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DB_ITERATOR_H
|
|
|
|
#define DB_ITERATOR_H
|
|
|
|
|
2014-09-18 11:06:06 +00:00
|
|
|
#include <gvn/gvn-param.h>
|
2013-10-11 23:07:35 +00:00
|
|
|
#include "db-model.h"
|
|
|
|
|
2014-09-18 11:06:06 +00:00
|
|
|
#define DB_TYPE_ITERATOR (db_iterator_get_type ())
|
|
|
|
#define DB_ITERATOR(self) (G_TYPE_CHECK_INSTANCE_CAST (self, DB_TYPE_ITERATOR, DbIterator))
|
|
|
|
#define DB_IS_ITERATOR(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, DB_TYPE_ITERATOR))
|
|
|
|
#define DB_ITERATOR_GET_INTERFACE(self) (G_TYPE_INSTANCE_GET_INTERFACE (self, DB_TYPE_ITERATOR, DbIteratorInterface))
|
2013-10-11 23:07:35 +00:00
|
|
|
|
2014-09-18 11:06:06 +00:00
|
|
|
#define DB_TYPE_ITERATOR_MODE (db_iterator_mode_get_type ())
|
2013-10-11 23:07:35 +00:00
|
|
|
|
|
|
|
typedef struct _DbIterator DbIterator;
|
2014-09-18 11:06:06 +00:00
|
|
|
typedef struct _DbIteratorInterface DbIteratorInterface;
|
2013-10-11 23:07:35 +00:00
|
|
|
|
|
|
|
#include "db-param.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DbIteratorMode:
|
|
|
|
* @DB_ITERATOR_MODE_ON_CHANGE: every change made in a cell will be sent to the
|
|
|
|
* database instantly.
|
|
|
|
* @DB_ITERATOR_MODE_ON_ITER: every change made in a row will be sent to the
|
|
|
|
* database when iter changes.
|
2014-09-18 11:06:06 +00:00
|
|
|
* @DB_ITERATOR_MODE_ON_DEMAND: nothing will be sent to the database until it's
|
2013-10-11 23:07:35 +00:00
|
|
|
* demanded.
|
|
|
|
*
|
2014-09-18 11:06:06 +00:00
|
|
|
* The working mode of an Iterator.
|
2013-10-11 23:07:35 +00:00
|
|
|
**/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DB_ITERATOR_MODE_ON_CHANGE
|
|
|
|
,DB_ITERATOR_MODE_ON_ITER
|
|
|
|
,DB_ITERATOR_MODE_ON_DEMAND
|
|
|
|
}
|
|
|
|
DbIteratorMode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DbIteratorMove:
|
|
|
|
* @DB_ITERATOR_MOVE_FIRST: Moves to the first position.
|
|
|
|
* @DB_ITERATOR_MOVE_PREVIOUS: Moves previous.
|
|
|
|
* @DB_ITERATOR_MOVE_NEXT: Moves next.
|
|
|
|
* @DB_ITERATOR_MOVE_LAST: Moves to the last position.
|
|
|
|
*
|
|
|
|
* Indicates the movement.
|
|
|
|
**/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DB_ITERATOR_MOVE_FIRST
|
|
|
|
,DB_ITERATOR_MOVE_PREVIOUS
|
|
|
|
,DB_ITERATOR_MOVE_NEXT
|
|
|
|
,DB_ITERATOR_MOVE_LAST
|
|
|
|
}
|
|
|
|
DbIteratorMove;
|
|
|
|
|
2014-09-18 11:06:06 +00:00
|
|
|
typedef DbIteratorMode (* DbIteratorGetMode) (DbIterator * self);
|
|
|
|
typedef void (* DbIteratorSetMode) (DbIterator * self, DbIteratorMode mode);
|
|
|
|
typedef gint (* DbIteratorGetRow) (DbIterator * self);
|
|
|
|
typedef gboolean (* DbIteratorGetIter) (DbIterator * self, DbIter ** iter);
|
|
|
|
typedef void (* DbIteratorSetIter) (DbIterator * self, DbIter * iter);
|
|
|
|
typedef gboolean (* DbIteratorMoveIter) (DbIterator * self, DbIter * iter);
|
|
|
|
typedef GList * (* DbIteratorGetParamList) (DbIterator * self);
|
|
|
|
typedef void (* DbIteratorDeleteSelection) (DbIterator * self);
|
2013-10-11 23:07:35 +00:00
|
|
|
|
2014-09-18 11:06:06 +00:00
|
|
|
struct _DbIteratorInterface
|
2013-10-11 23:07:35 +00:00
|
|
|
{
|
2014-09-18 11:06:06 +00:00
|
|
|
GTypeInterface parent;
|
|
|
|
DbIteratorGetMode get_mode;
|
|
|
|
DbIteratorSetMode set_mode;
|
|
|
|
DbIteratorGetRow get_row;
|
|
|
|
DbIteratorGetIter get_iter;
|
|
|
|
DbIteratorSetIter set_iter;
|
|
|
|
DbIteratorMoveIter move_iter;
|
|
|
|
DbIteratorGetParamList get_param_list;
|
|
|
|
DbIteratorDeleteSelection delete_selection;
|
2013-10-11 23:07:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GType db_iterator_get_type ();
|
|
|
|
GType db_iterator_mode_get_type () G_GNUC_CONST;
|
|
|
|
|
2014-07-16 14:12:36 +00:00
|
|
|
gboolean db_iterator_is_ready (DbIterator * self);
|
|
|
|
DbIteratorMode db_iterator_get_mode (DbIterator * self);
|
|
|
|
void db_iterator_set_mode (DbIterator * self, DbIteratorMode mode);
|
|
|
|
gint db_iterator_get_row (DbIterator * self);
|
2014-09-18 11:06:06 +00:00
|
|
|
gboolean db_iterator_get_iter (DbIterator * self, DbIter ** iter);
|
|
|
|
void db_iterator_add_param (DbIterator * self, DbParam * param);
|
|
|
|
GvnParam * db_iterator_get_param (DbIterator * self, const gchar * column);
|
|
|
|
GList * db_iterator_get_params (DbIterator * self);
|
|
|
|
void db_iterator_bind_param (DbIterator * self, const gchar * column, GvnParam * param);
|
|
|
|
void db_iterator_link (DbIterator * self, const gchar * field, DbIterator * src, const gchar * column);
|
|
|
|
void db_iterator_link_with_param (DbIterator * self, const gchar * field, GvnParam * param);
|
|
|
|
gboolean db_iterator_move_iter (DbIterator * self, DbIter * iter);
|
|
|
|
gboolean db_iterator_move_first (DbIterator * self);
|
|
|
|
gboolean db_iterator_move_last (DbIterator * self);
|
|
|
|
gboolean db_iterator_move_previous (DbIterator * self);
|
|
|
|
gboolean db_iterator_move_next (DbIterator * self);
|
|
|
|
gboolean db_iterator_move_to (DbIterator * self, DbIteratorMove move);
|
2014-07-16 14:12:36 +00:00
|
|
|
void db_iterator_refresh (DbIterator * self);
|
|
|
|
const GvnParamSpec * db_iterator_get_spec (DbIterator * self, gint column);
|
|
|
|
gint db_iterator_get_column_index (DbIterator * self, const gchar * name);
|
|
|
|
void db_iterator_delete (DbIterator * self);
|
|
|
|
void db_iterator_insert (DbIterator * self);
|
|
|
|
gint db_iterator_get_nrows (DbIterator * self);
|
|
|
|
DbModelUpdateFlags db_iterator_get_update_flags (DbIterator * self);
|
|
|
|
void db_iterator_reverse_operations (DbIterator * self);
|
|
|
|
void db_iterator_perform_operations (DbIterator * self);
|
|
|
|
DbModelRowOp db_iterator_get_pending_operations (DbIterator * self);
|
|
|
|
gboolean db_iterator_has_pending_operations (DbIterator * self);
|
2013-10-11 23:07:35 +00:00
|
|
|
|
2014-09-18 11:06:06 +00:00
|
|
|
void db_iterator_data_changed (DbIterator * self);
|
|
|
|
void db_iterator_iter_changed (DbIterator * self);
|
|
|
|
void db_iterator_operations_done (DbIterator * self);
|
|
|
|
void db_iterator_row_num_changed (DbIterator * self);
|
|
|
|
void db_iterator_status_changed (DbIterator * self, gboolean ready);
|
|
|
|
|
2014-10-09 15:12:15 +00:00
|
|
|
const GValue * db_iterator_get_value_by_index (DbIterator * self, gint column);
|
|
|
|
gboolean db_iterator_set_value_by_index (DbIterator * self, gint column, const GValue * value, GError ** err);
|
|
|
|
const GValue * db_iterator_get_value (DbIterator * self, const gchar * column_name);
|
|
|
|
gboolean db_iterator_set_value (DbIterator * self, const gchar * column_name, const GValue * value, GError ** err);
|
|
|
|
gboolean db_iterator_is_null (DbIterator * self, const gchar * column_name);
|
|
|
|
void db_iterator_set_null (DbIterator * self, const gchar * column_name);
|
|
|
|
gboolean db_iterator_get_boolean (DbIterator * self, const gchar * column_name);
|
|
|
|
void db_iterator_set_boolean (DbIterator * self, const gchar * column_name, gboolean value);
|
|
|
|
gint db_iterator_get_int (DbIterator * self, const gchar * column_name);
|
|
|
|
void db_iterator_set_int (DbIterator * self, const gchar * column_name, gint value);
|
|
|
|
glong db_iterator_get_long (DbIterator * self, const gchar * column_name);
|
|
|
|
void db_iterator_set_long (DbIterator * self, const gchar * column_name, glong value);
|
|
|
|
gdouble db_iterator_get_double (DbIterator * self, const gchar * column_name);
|
|
|
|
void db_iterator_set_double (DbIterator * self, const gchar * column_name, gdouble value);
|
|
|
|
const gchar * db_iterator_get_string (DbIterator * self, const gchar * column_name);
|
|
|
|
void db_iterator_set_string (DbIterator * self, const gchar * column_name, const gchar * value);
|
|
|
|
gpointer db_iterator_get_boxed (DbIterator * self, const gchar * column_name);
|
|
|
|
void db_iterator_set_boxed (DbIterator * self, const gchar * column_name, gpointer value);
|
|
|
|
|
2014-09-18 11:06:06 +00:00
|
|
|
#endif
|