1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/* mg-context.h
*
* Copyright (C) 2003 Vivien Malerba
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#ifndef __MG_CONTEXT_H_
#define __MG_CONTEXT_H_
#include "mg-base.h"
#include "mg-defs.h"
#include <libgda/libgda.h>
G_BEGIN_DECLS
#define MG_CONTEXT_TYPE (mg_context_get_type())
#define MG_CONTEXT(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, mg_context_get_type(), MgContext)
#define MG_CONTEXT_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, mg_context_get_type (), MgContextClass)
#define IS_MG_CONTEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, mg_context_get_type ())
/* Interfaces:
* MgRerefer
*/
/* error reporting */
extern GQuark mg_context_error_quark (void);
#define MG_CONTEXT_ERROR mg_context_error_quark ()
enum
{
MG_CONTEXT_NO_NODE_ERROR,
MG_CONTEXT_NODE_OUTDATED_ERROR,
MG_CONTEXT_VALUE_PROV_OBJ_TYPE_ERROR,
MG_CONTEXT_VALUE_PROV_DATA_TYPE_ERROR,
MG_CONTEXT_VALUE_PROV_INVISIBLE_ERROR,
MG_CONTEXT_VALUE_PROV_QUERY_TYPE_ERROR,
MG_CONTEXT_DEPENDENCY_NOT_IN_CONTEXT_ERROR,
MG_CONTEXT_DEPENDENCY_POSITION_ERROR
};
/* use either 'param' or 'query' and 'params' */
struct _MgContextNode {
/* this MgContextNode is only for one parameter, free fill */
MgParameter *param;
/* this MgContextNode is for one or more parameters, listed in 'params' and the params values
depend on the result of the execution of 'query' */
MgQuery *query;
GSList *params;
GHashTable *params_pos_in_query; /* key=param value=column in query where its source field is */
};
#define MG_CONTEXT_NODE(x) ((MgContextNode *)x)
/* struct for the object's data */
struct _MgContext
{
MgBase object;
GSList *parameters;
GSList *nodes;
MgContextPrivate *priv;
};
/* struct for the object's class */
struct _MgContextClass
{
MgBaseClass class;
void (*param_changed) (MgContext *context, MgParameter *param);
};
guint mg_context_get_type (void);
GObject *mg_context_new (MgConf *conf, GSList *params);
GObject *mg_context_new_copy (MgContext *orig, gboolean copy_params, GHashTable *replacements);
void mg_context_add_param (MgContext *context, MgParameter *param);
void mg_context_merge_context_params (MgContext *context, MgContext *context_to_merge);
gboolean mg_context_is_coherent (MgContext *context, GError **error);
gboolean mg_context_is_valid (MgContext *context);
gboolean mg_context_needs_user_input (MgContext *context);
MgParameter *mg_context_find_parameter_for_field (MgContext *context, MgQfield *for_field);
MgContextNode *mg_context_find_node_for_param (MgContext *context, MgParameter *param);
void mg_context_set_param_default_value (MgContext *context, MgParameter *param, const GdaValue *value);
void mg_context_set_param_default_alias (MgContext *context, MgParameter *param, MgParameter *alias);
const GdaValue *mg_context_get_param_default_value (MgContext *context, MgParameter *param);
G_END_DECLS
#endif
|