MgEntity

Name

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

Synopsis



#define     MG_ENTITY_TYPE
#define     MG_ENTITY                       (obj)
#define     IS_MG_ENTITY                    (obj)
#define     MG_ENTITY_GET_IFACE             (obj)
struct      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

Implementations

MgEntity is implemented by MgQuery and MgDbTable.

Prerequisites

MgEntity requires GObject.

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

MG_ENTITY_TYPE

#define MG_ENTITY_TYPE          (mg_entity_get_type())


MG_ENTITY()

#define MG_ENTITY(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, mg_entity_get_type(), MgEntity)

obj :


IS_MG_ENTITY()

#define IS_MG_ENTITY(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, mg_entity_get_type ())

obj :


MG_ENTITY_GET_IFACE()

#define MG_ENTITY_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MG_ENTITY_TYPE, MgEntityIface))

obj :


struct MgEntity

struct 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

iface :

an object implementing the MgEntity interface

name :

Returns :

the requested MgField


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


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.