This repository has been archived on 2024-07-15. You can view files and clone it, but cannot push or open issues or pull requests.
hedera/db/db-calc.h

99 lines
2.8 KiB
C
Raw Permalink Normal View History

2013-10-11 23:07:35 +00:00
/*
Copyright (C) 2012 - Juan Ferrer Toribio
This program 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 2.1 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
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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
*/
#ifndef DB_CALC_H
#define DB_CALC_H
#include <glib-object.h>
#include <gvn/gvn-param.h>
#include "db-model.h"
#define DB_CALC_LOG_DOMAIN (g_quark_from_string ("DbCalc"))
#define DB_TYPE_CALC (db_calc_get_type ())
2014-07-09 07:49:56 +00:00
#define DB_CALC(self) (G_TYPE_CHECK_INSTANCE_CAST (self, DB_TYPE_CALC, DbCalc))
#define DB_IS_CALC(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, DB_TYPE_CALC))
#define DB_CALC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((self), DB_TYPE_CALC, DbCalcClass))
2013-10-11 23:07:35 +00:00
#define DB_IS_CALC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DB_TYPE_CLASS))
2014-07-09 07:49:56 +00:00
#define DB_CALC_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS ((self), DB_TYPE_CALC, DbCalcClass))
2013-10-11 23:07:35 +00:00
#define DB_TYPE_CALC_TYPE (db_calc_type_get_type ())
2013-10-11 23:07:35 +00:00
typedef struct _DbCalc DbCalc;
typedef struct _DbCalcClass DbCalcClass;
/**
* DbCalcFunc:
2014-07-09 07:49:56 +00:00
* @self: a #DbCalc
2013-10-11 23:07:35 +00:00
* @iter: a #DbIter pointing to a row of the model
* @out: the return position for the resulting value
* @user_data: (closure): the data passed to the function
*
* The prototype of the functions used by the #DbCalc to perform operations
* on more than one column or to perform additional operations to a column,
* previously to add them to the calculations performed by the @DbCalc itself.
**/
2014-07-09 07:49:56 +00:00
typedef void (*DbCalcFunc) (DbCalc * self, DbIter * iter, GValue * out, gpointer user_data);
2013-10-11 23:07:35 +00:00
/**
* DbCalcType:
* @DB_CALC_TYPE_SUM: sumatory of the values
* @DB_CALC_TYPE_AVG: average of the values
2013-10-11 23:07:35 +00:00
*
* Defines which type of operation will be performed over the column values.
**/
typedef enum
{
DB_CALC_TYPE_SUM,
2014-07-09 07:49:56 +00:00
DB_CALC_TYPE_AVG
2013-10-11 23:07:35 +00:00
}
DbCalcType;
2013-10-11 23:07:35 +00:00
struct _DbCalc
{
GObject parent;
GValue * value;
GvnParam * master;
GvnParamSpec * spec;
2013-10-11 23:07:35 +00:00
DbModel * model;
DbCalcType type;
2013-10-11 23:07:35 +00:00
DbCalcFunc func;
gpointer data;
2014-07-09 07:49:56 +00:00
guint column_index;
gchar * column_name;
2013-10-11 23:07:35 +00:00
guint count;
};
struct _DbCalcClass
{
/* <private> */
GObjectClass klass;
2013-10-11 23:07:35 +00:00
};
GType db_calc_get_type ();
GType db_calc_type_get_type ();
DbCalc * db_calc_new ();
2013-10-11 23:07:35 +00:00
DbCalc * db_calc_new_with_func (DbModel * model
,DbCalcType type
2013-10-11 23:07:35 +00:00
,DbCalcFunc func
,gpointer data);
#endif