MgEntity

MgEntity — Interface to represent a generic entity (for tables, views or queries)

Synopsis




            MgEntity;
GType       mg_entity_get_type              (void);
GSList*     mg_entity_get_all_fields        (MgEntity *iface);
GSList*     mg_entity_get_visible_fields    (MgEntity *iface);
MgField*    mg_entity_get_field_by_name     (MgEntity *iface,
                                             const gchar *name);
MgField*    mg_entity_get_field_by_xml_id   (MgEntity *iface,
                                             const gchar *xml_id);
MgField*    mg_entity_get_field_by_index    (MgEntity *iface,
                                             gint index);
gint        mg_entity_get_field_index       (MgEntity *iface,
                                             MgField *field);
void        mg_entity_add_field             (MgEntity *iface,
                                             MgField *field);
void        mg_entity_add_field_before      (MgEntity *iface,
                                             MgField *field,
                                             MgField *field_before);
void        mg_entity_swap_fields           (MgEntity *iface,
                                             MgField *field1,
                                             MgField *field2);
void        mg_entity_remove_field          (MgEntity *iface,
                                             MgField *field);
gboolean    mg_entity_is_writable           (MgEntity *iface);
GSList*     mg_entity_get_parameters        (MgEntity *iface);
MgContext*  mg_entity_get_exec_context      (MgEntity *iface);

Object Hierarchy


  GInterface
   +----MgEntity

Prerequisites

MgEntity requires GObject.

Known Implementations

MgEntity is implemented by MgDbTable and MgQuery.

Signal Prototypes


"field-added"
            void        user_function      (MgEntity *mgentity,
                                            gpointer arg1,
                                            gpointer user_data);
"field-removed"
            void        user_function      (MgEntity *mgentity,
                                            gpointer arg1,
                                            gpointer user_data);
"field-updated"
            void        user_function      (MgEntity *mgentity,
                                            gpointer arg1,
                                            gpointer user_data);
"fields-order-changed"
            void        user_function      (MgEntity *mgentity,
                                            gpointer user_data);

Description

Details

MgEntity

typedef struct _MgEntity MgEntity;


mg_entity_get_type ()

GType       mg_entity_get_type              (void);

Returns :

mg_entity_get_all_fields ()

GSList*     mg_entity_get_all_fields        (MgEntity *iface);

Get a new list containing all the DbField objects held within the object implementing the MgEntity interface.

iface : an object implementing the MgEntity interface
Returns : the new list.

mg_entity_get_visible_fields ()

GSList*     mg_entity_get_visible_fields    (MgEntity *iface);

Same as mg_entity_get_all_fields() but returns only the visible fields, the ones which are not hidden (this makes sense only for queries, not for DBMS tables where there are no hidden fields).

The returned list nodes are in the order in which the fields are within the entity.

iface : an object implementing the MgEntity interface
Returns : the new list.

mg_entity_get_field_by_name ()

MgField*    mg_entity_get_field_by_name     (MgEntity *iface,
                                             const gchar *name);

Get a MgField using its name. The notion of "field name" is the string returned by mg_field_get_name() on each of the fields composing iface. However, if that definition does not return any field, then each particular implementation of iface may try to give an extra definition to the notion of "field name".

For instance, in the case of the MgQuery object, the mg_field_get_name() is used as a first try to find a field, and if that fails, then the object tries to find fields from their SQL naming.

In the case where there can be more than one field with the same name (depending on iface's implementation), then the returned value is NULL.

iface : an object implementing the MgEntity interface
name :
Returns : the requested MgField or NULL if the field cannot be found, or if more than one field has been found.

mg_entity_get_field_by_xml_id ()

MgField*    mg_entity_get_field_by_xml_id   (MgEntity *iface,
                                             const gchar *xml_id);

iface : an object implementing the MgEntity interface
xml_id :
Returns : the requested MgField

mg_entity_get_field_by_index ()

MgField*    mg_entity_get_field_by_index    (MgEntity *iface,
                                             gint index);

iface : an object implementing the MgEntity interface
index :
Returns : the requested MgField or NULL if the index is out of bounds

mg_entity_get_field_index ()

gint        mg_entity_get_field_index       (MgEntity *iface,
                                             MgField *field);

Get the position of the field in the given entity. Positions start at 0. field MUST be a visible field.

iface : an object implementing the MgEntity interface
field : an object implementing the MgField interface
Returns : the position or -1 if the field is not in the entity or is not visible

mg_entity_add_field ()

void        mg_entity_add_field             (MgEntity *iface,
                                             MgField *field);

Add field to iface's fields (at the end of the list)

iface : an object implementing the MgEntity interface
field : an object implementing the MgField interface to add

mg_entity_add_field_before ()

void        mg_entity_add_field_before      (MgEntity *iface,
                                             MgField *field,
                                             MgField *field_before);

Add field to iface's fields, before field_before if it is not NULL, or at the end if field_before is NULL.

iface : an object implementing the MgEntity interface
field : an object implementing the MgField interface to add
field_before : an object implementing the MgField interface before which field will be added, or NULL

mg_entity_swap_fields ()

void        mg_entity_swap_fields           (MgEntity *iface,
                                             MgField *field1,
                                             MgField *field2);

iface : an object implementing the MgEntity interface
field1 : an object implementing the MgField interface
field2 : an object implementing the MgField interface

mg_entity_remove_field ()

void        mg_entity_remove_field          (MgEntity *iface,
                                             MgField *field);

iface : an object implementing the MgEntity interface
field : an object implementing the MgField interface to remove

mg_entity_is_writable ()

gboolean    mg_entity_is_writable           (MgEntity *iface);

Tells if the real entity (the corresponding DBMS object) represented by iface can be written to.

iface : an object implementing the MgEntity interface
Returns : TRUE if it is possible to write to iface

mg_entity_get_parameters ()

GSList*     mg_entity_get_parameters        (MgEntity *iface);

Get a list of parameters required before iface can be used. Usualy this function is used with queries to grab the required parameters before executing a query.

iface : an object implementing the MgEntity interface
Returns : a new list of MgParameter objects. iface DOES NOT hold any reference to any of the listed parameter.

mg_entity_get_exec_context ()

MgContext*  mg_entity_get_exec_context      (MgEntity *iface);

Creates a new MgContext object which contains all the parameters required to use iface.

iface : an object implementing the MgEntity interface
Returns : a new MgContext object

Signals

The "field-added" signal

void        user_function                  (MgEntity *mgentity,
                                            gpointer arg1,
                                            gpointer user_data);

mgentity : the object which received the signal.
arg1 :
user_data : user data set when the signal handler was connected.

The "field-removed" signal

void        user_function                  (MgEntity *mgentity,
                                            gpointer arg1,
                                            gpointer user_data);

mgentity : the object which received the signal.
arg1 :
user_data : user data set when the signal handler was connected.

The "field-updated" signal

void        user_function                  (MgEntity *mgentity,
                                            gpointer arg1,
                                            gpointer user_data);

mgentity : the object which received the signal.
arg1 :
user_data : user data set when the signal handler was connected.

The "fields-order-changed" signal

void        user_function                  (MgEntity *mgentity,
                                            gpointer user_data);

mgentity : the object which received the signal.
user_data : user data set when the signal handler was connected.