MgDatabase

Name

MgDatabase -- Represents a database in the DBMS server

Synopsis



#define     MG_DATABASE_TYPE
#define     MG_DATABASE                     (obj)
#define     IS_MG_DATABASE                  (obj)
#define     MG_DATABASE_CLASS               (klass)
struct      MgDatabase;
guint       mg_database_get_type            (void);
GObject*    mg_database_new                 (MgConf *conf);
MgConf*     mg_database_get_conf            (MgDatabase *mgdb);
gboolean    mg_database_update_dbms_data    (MgDatabase *mgdb,
                                             GError **error);
void        mg_database_stop_update_dbms_data
                                            (MgDatabase *mgdb);
GSList*     mg_database_get_tables          (MgDatabase *mgdb);
MgDbTable*  mg_database_get_table_by_name   (MgDatabase *mgdb,
                                             const gchar *name);
MgDbTable*  mg_database_get_table_by_xml_id (MgDatabase *mgdb,
                                             const gchar *xml_id);
MgDbField*  mg_database_get_field_by_name   (MgDatabase *mgdb,
                                             const gchar *fullname);
MgDbField*  mg_database_get_field_by_xml_id (MgDatabase *mgdb,
                                             const gchar *xml_id);
MgDbSequence* mg_database_get_sequence_by_name
                                            (MgDatabase *mgdb,
                                             const gchar *name);
MgDbSequence* mg_database_get_sequence_by_xml_id
                                            (MgDatabase *mgdb,
                                             const gchar *xml_id);
MgDbSequence* mg_database_get_sequence_to_field
                                            (MgDatabase *mgdb,
                                             MgDbField *field);
void        mg_database_link_sequence       (MgDatabase *mgdb,
                                             MgDbSequence *seq,
                                             MgDbField *field);
void        mg_database_unlink_sequence     (MgDatabase *mgdb,
                                             MgDbSequence *seq,
                                             MgDbField *field);
GSList*     mg_database_get_all_constraints (MgDatabase *mgdb);
GSList*     mg_database_get_all_fk_constraints
                                            (MgDatabase *mgdb);
GSList*     mg_database_get_table_constraints
                                            (MgDatabase *mgdb,
                                             MgDbTable *table);
GSList*     mg_database_get_tables_fk_constraints
                                            (MgDatabase *mgdb,
                                             MgDbTable *table1,
                                             MgDbTable *table2,
                                             gboolean table1_has_fk);

Object Hierarchy


  GObject
   +----MgBase
         +----MgDatabase

Implemented Interfaces

MgDatabase implements MgXmlStorage.

Properties


  "prop"                 gpointer             : Read / Write

Signal Prototypes


"constraint-added"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"constraint-removed"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"constraint-updated"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"data-update-finished"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer user_data);
"data-update-started"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer user_data);
"field-added"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"field-removed"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"field-updated"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"fs-link-added"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer arg2,
                                            gpointer user_data);
"fs-link-removed"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer arg2,
                                            gpointer user_data);
"sequence-added"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"sequence-removed"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"sequence-updated"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"table-added"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"table-removed"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"table-updated"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);
"update-progress"
            void        user_function      (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            guint arg2,
                                            guint arg3,
                                            gpointer user_data);

Description

This object manages an internal dictionnary mirroring the real database structure with objects such as MgDbTable (composed of MgDbfield objects) and MgDbConstraint.

Implements the MgXmlStorage interface.

Details

MG_DATABASE_TYPE

#define MG_DATABASE_TYPE          (mg_database_get_type())


MG_DATABASE()

#define MG_DATABASE(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, mg_database_get_type(), MgDatabase)

obj :


IS_MG_DATABASE()

#define IS_MG_DATABASE(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, mg_database_get_type ())

obj :


MG_DATABASE_CLASS()

#define MG_DATABASE_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, mg_database_get_type (), MgDatabaseClass)

klass :


struct MgDatabase

struct MgDatabase;


mg_database_get_type ()

guint       mg_database_get_type            (void);

Returns :

the type id


mg_database_new ()

GObject*    mg_database_new                 (MgConf *conf);

Creates a new MgDatabase object

conf :

a MgConf object

Returns :

the new object


mg_database_get_conf ()

MgConf*     mg_database_get_conf            (MgDatabase *mgdb);

Fetch the MgConf object to which the MgDatabase belongs.

mgdb :

a MgDatabase object

Returns :

the MgConf object


mg_database_update_dbms_data ()

gboolean    mg_database_update_dbms_data    (MgDatabase *mgdb,
                                             GError **error);

Synchronises the Table representation with the table structure which is stored in the DBMS. For this operation to succeed, the connection to the DBMS server MUST be opened (using the corresponding MgServer object).

mgdb :

error :

location to store error, or NULL

Returns :

TRUE if no error


mg_database_stop_update_dbms_data ()

void        mg_database_stop_update_dbms_data
                                            (MgDatabase *mgdb);

When the database updates its internal lists of DBMS objects, a call to this function will stop that update process. It has no effect when the database is not updating its DBMS data.

mgdb :

a MgDatabase object


mg_database_get_tables ()

GSList*     mg_database_get_tables          (MgDatabase *mgdb);

Get a list of all the tables within mgdb

mgdb :

a MgDatabase object

Returns :

a new list of all the MgDbTable objects


mg_database_get_table_by_name ()

MgDbTable*  mg_database_get_table_by_name   (MgDatabase *mgdb,
                                             const gchar *name);

Get a reference to a MgDbTable using its name.

mgdb :

a MgDatabase object

name :

the name of the requested table

Returns :

The MgDbTable pointer or NULL if the requested table does not exist.


mg_database_get_table_by_xml_id ()

MgDbTable*  mg_database_get_table_by_xml_id (MgDatabase *mgdb,
                                             const gchar *xml_id);

Get a reference to a MgDbTable using its XML id.

mgdb :

a MgDatabase object

xml_id :

the XML id of the requested table

Returns :

The MgDbTable pointer or NULL if the requested table does not exist.


mg_database_get_field_by_name ()

MgDbField*  mg_database_get_field_by_name   (MgDatabase *mgdb,
                                             const gchar *fullname);

Get a reference to a MgDbField specifying the full name (table_name.field_name) of the requested field.

mgdb :

a MgDatabase object

fullname :

the name of the requested table field

Returns :

The MgDbField pointer or NULL if the requested field does not exist.


mg_database_get_field_by_xml_id ()

MgDbField*  mg_database_get_field_by_xml_id (MgDatabase *mgdb,
                                             const gchar *xml_id);

Get a reference to a MgDbField specifying its XML id

mgdb :

a MgDatabase object

xml_id :

the XML id of the requested table field

Returns :

The MgDbField pointer or NULL if the requested field does not exist.


mg_database_get_sequence_by_name ()

MgDbSequence* mg_database_get_sequence_by_name
                                            (MgDatabase *mgdb,
                                             const gchar *name);

Get a reference to a MgDbSequence specifying its name

mgdb :

a MgDatabase object

name :

the name of the requested sequence

Returns :

The MgDbSequence pointer or NULL if the requested sequence does not exist.


mg_database_get_sequence_by_xml_id ()

MgDbSequence* mg_database_get_sequence_by_xml_id
                                            (MgDatabase *mgdb,
                                             const gchar *xml_id);

Get a reference to a MgDbSequence specifying its XML id.

mgdb :

a MgDatabase object

xml_id :

the XML id of the requested sequence

Returns :

The MgDbSequence pointer or NULL if the requested sequence does not exist.


mg_database_get_sequence_to_field ()

MgDbSequence* mg_database_get_sequence_to_field
                                            (MgDatabase *mgdb,
                                             MgDbField *field);

Get a reference to a MgDbSequence which is "linked" to the MgDbField given as parameter. This "link" means that each new value of the field will be given by the returned sequence

mgdb :

a MgDatabase object

field :

a MgDbField object

Returns :

The MgDbSequence pointer or NULL if there is no sequence for this job.


mg_database_link_sequence ()

void        mg_database_link_sequence       (MgDatabase *mgdb,
                                             MgDbSequence *seq,
                                             MgDbField *field);

Tells the database that each new value of the field given as argument should be obtained from the specified sequence (this is usefull when the field is a simple primary key for example).

mgdb :

a MgDatabase object

seq :

field :


mg_database_unlink_sequence ()

void        mg_database_unlink_sequence     (MgDatabase *mgdb,
                                             MgDbSequence *seq,
                                             MgDbField *field);

Tells the database that each new value of the field given as argument should not be obtained from the specified sequence (this is usefull when the field is a simple primary key for example). This is the opposite of the mg_database_link_sequence() method.

mgdb :

a MgDatabase object

seq :

field :


mg_database_get_all_constraints ()

GSList*     mg_database_get_all_constraints (MgDatabase *mgdb);

Get a list of all the constraints applied to the database. Constraints are represented as MgDbConstraint objects and represent any type of constraint.

mgdb :

a MgDatabase object

Returns :

a new list of the constraints


mg_database_get_all_fk_constraints ()

GSList*     mg_database_get_all_fk_constraints
                                            (MgDatabase *mgdb);

Get a list of all the constraints applied to the database which represent a foreign constrains. Constraints are represented as MgDbConstraint objects.

mgdb :

a MgDatabase object

Returns :

a new list of the constraints


mg_database_get_table_constraints ()

GSList*     mg_database_get_table_constraints
                                            (MgDatabase *mgdb,
                                             MgDbTable *table);

Get all the constraints applicable to table

mgdb :

a MgDatabase object

table :

a MgDbTable, part of mgdb

Returns :

a new GSList of MgDbConstraint objects


mg_database_get_tables_fk_constraints ()

GSList*     mg_database_get_tables_fk_constraints
                                            (MgDatabase *mgdb,
                                             MgDbTable *table1,
                                             MgDbTable *table2,
                                             gboolean table1_has_fk);

Get a list of all the constraints applied to the database which represent a foreign constrains, between table1 and table2.

Constraints are represented as MgDbConstraint objects.

mgdb :

a MgDatabase object

table1 :

a MgDbTable

table2 :

a MgDbTable

table1_has_fk :

TRUE if the returned constraints are the one for which table1 contains the foreign key

Returns :

a new list of the constraints

Properties

"prop" (gpointer : Read / Write)

Signals

The "constraint-added" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "constraint-removed" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "constraint-updated" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "data-update-finished" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

user_data :

user data set when the signal handler was connected.


The "data-update-started" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

user_data :

user data set when the signal handler was connected.


The "field-added" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

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                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

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                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "fs-link-added" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer arg2,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

arg2 :

user_data :

user data set when the signal handler was connected.


The "fs-link-removed" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer arg2,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

arg2 :

user_data :

user data set when the signal handler was connected.


The "sequence-added" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "sequence-removed" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "sequence-updated" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "table-added" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "table-removed" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "table-updated" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.


The "update-progress" signal

void        user_function                  (MgDatabase *mgdatabase,
                                            gpointer arg1,
                                            guint arg2,
                                            guint arg3,
                                            gpointer user_data);

mgdatabase :

the object which received the signal.

arg1 :

arg2 :

arg3 :

user_data :

user data set when the signal handler was connected.