![]() | ![]() | ![]() | Libmergeant Reference Manual | ![]() |
---|
#define MG_CONF_TYPE #define MG_CONF (obj) #define MG_CONF_CLASS (klass) #define IS_MG_CONF (obj) struct MgConf; struct MgConfPrivate; guint mg_conf_get_type (void); GObject* mg_conf_new (void); gchar* mg_conf_compute_xml_filename (MgConf *conf, const gchar *datasource, const gchar *app_id, GError **error); void mg_conf_set_xml_filename (MgConf *conf, const gchar *xmlfile); const gchar* mg_conf_get_xml_filename (MgConf *conf); gboolean mg_conf_load_xml (MgConf *conf, GError **error); gboolean mg_conf_save_xml (MgConf *conf, GError **error); gboolean mg_conf_load_xml_file (MgConf *conf, const gchar *xmlfile, GError **error); gboolean mg_conf_save_xml_file (MgConf *conf, const gchar *xmlfile, GError **error); void mg_conf_declare_query (MgConf *conf, MgQuery *query); void mg_conf_assume_query (MgConf *conf, MgQuery *query); void mg_conf_unassume_query (MgConf *conf, MgQuery *query); GSList* mg_conf_get_queries (MgConf *conf); MgQuery* mg_conf_get_query_by_xml_id (MgConf *conf, const gchar *xml_id); MgServer* mg_conf_get_server (MgConf *conf); MgDatabase* mg_conf_get_database (MgConf *conf); GSList* mg_conf_get_entities_fk_constraints (MgConf *conf, MgEntity *entity1, MgEntity *entity2, gboolean entity1_has_fk); void mg_conf_dump (MgConf *conf);
"query-added" void user_function (MgConf *mgconf, gpointer arg1, gpointer user_data); "query-removed" void user_function (MgConf *mgconf, gpointer arg1, gpointer user_data);
This object is a "container" for all the objects which are used within the libmergeant library: connection to the DBMS server (through a MgServer object), database structure (through a MgDatabase object) and queries (MgQuery objects).
There MUST be a MgConf object for each connection to a DBMS, and there can be several ones at the same time. The MgConf object, when instantiated, will create a MgServer and a MgDatabase objects; the other objects will be created as necessary when an XML file is loaded.
#define MG_CONF_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, mg_conf_get_type (), MgConfClass)
klass : |
|
GObject* mg_conf_new (void);
Create a new MgConf object.
Returns : | the newly created object. |
gchar* mg_conf_compute_xml_filename (MgConf *conf, const gchar *datasource, const gchar *app_id, GError **error);
Get the prefered filename which represents the data dictionnary associated to the datasource data source. Using the returned value in conjunction with mg_conf_load_xml_file() and mg_conf_save_xml_file has the advantage of letting the library handle file naming onventions.
The app_id argument allows to give an extra identification to the request, when some special features must be saved but not interfere with the default dictionnary.
conf : | a MgConf object |
datasource : | a data source |
app_id : | an extra identification, or NULL |
error : | location to store error, or NULL |
Returns : |
|
void mg_conf_set_xml_filename (MgConf *conf, const gchar *xmlfile);
Sets the filename conf will use when mg_conf_save_xml() and mg_conf_load_xml() are called.
conf : | a MgConf object |
xmlfile : | a file name |
const gchar* mg_conf_get_xml_filename (MgConf *conf);
Get the filename conf will use when mg_conf_save_xml() and mg_conf_load_xml() are called.
conf : | a MgConf object |
Returns : | the filename, or NULL if none have been set. |
gboolean mg_conf_load_xml (MgConf *conf, GError **error);
Loads an XML file which respects the Mergeant DTD, and creates all the necessary objects that are defined within the XML file. During the creation of the other objects, all the normal signals are emitted.
If the MgConf object already has some contents, then it is first of all nullified (to return its state as when it was first created).
If an error occurs during loading then the MgConf object is left as empty as when it is first created.
conf : | a MgConf object |
error : | location to store error, or NULL |
Returns : | TRUE if loading was successfull and FALSE otherwise. |
gboolean mg_conf_save_xml (MgConf *conf, GError **error);
Saves the contents of a MgConf object to a file which is given as argument.
conf : | a MgConf object |
error : | location to store error, or NULL |
Returns : | TRUE if saving was successfull and FALSE otherwise. |
gboolean mg_conf_load_xml_file (MgConf *conf, const gchar *xmlfile, GError **error);
Loads an XML file which respects the Mergeant DTD, and creates all the necessary objects that are defined within the XML file. During the creation of the other objects, all the normal signals are emitted.
If the MgConf object already has some contents, then it is first of all nullified (to return its state as when it was first created).
If an error occurs during loading then the MgConf object is left as empty as when it is first created.
conf : | a MgConf object |
xmlfile : | the name of the file to which the XML will be written to |
error : | location to store error, or NULL |
Returns : | TRUE if loading was successfull and FALSE otherwise. |
gboolean mg_conf_save_xml_file (MgConf *conf, const gchar *xmlfile, GError **error);
Saves the contents of a MgConf object to a file which is given as argument.
conf : | a MgConf object |
xmlfile : | the name of the file to which the XML will be written to |
error : | location to store error, or NULL |
Returns : | TRUE if saving was successfull and FALSE otherwise. |
void mg_conf_declare_query (MgConf *conf, MgQuery *query);
Declares the existance of a new query to conf. All the MgQuery objects MUST be declared to the corresponding MgConf object for the library to work correctly. Once query has been declared, conf does not hold any reference to query. If conf must hold such a reference, then use mg_conf_assume_query().
This functions is called automatically from each mg_query_new* function, and it should not be necessary to call it except for classes extending the MgQuery class.
conf : | a MgConf object |
query : | a MgQuery object |
void mg_conf_assume_query (MgConf *conf, MgQuery *query);
Force conf to manage query: it will get a reference to it.
conf : | a MgConf object |
query : | a MgQuery object |
void mg_conf_unassume_query (MgConf *conf, MgQuery *query);
Forces conf to lose a reference it has on query
conf : | a MgConf object |
query : | a MgQuery object |
GSList* mg_conf_get_queries (MgConf *conf);
Get a list of all the non interdependant queries managed by conf (only queries with no parent query are listed)
conf : | a MgConf object |
Returns : | a new list of MgQuery objects |
MgQuery* mg_conf_get_query_by_xml_id (MgConf *conf, const gchar *xml_id);
Find a MgQuery object from its XML Id
conf : | a MgConf object |
xml_id : | the XML Id of the query being searched |
Returns : | the MgQuery object, or NULL if not found |
MgServer* mg_conf_get_server (MgConf *conf);
Fetch a pointer to the MgServer used by the MgConf object.
conf : | a MgConf object |
Returns : | a pointer to the MgServer |
MgDatabase* mg_conf_get_database (MgConf *conf);
Fetch a pointer to the MgDatabase used by the MgConf object.
conf : | a MgConf object |
Returns : | a pointer to the MgDatabase |
GSList* mg_conf_get_entities_fk_constraints (MgConf *conf, MgEntity *entity1, MgEntity *entity2, gboolean entity1_has_fk);
Get a list of all the constraints which represent a foreign constrains, between entity1 and entity2. If entity1 and entity2 are MgDbTable objects, then the constraints are the ones from the database.
Constraints are represented as MgDbConstraint objects.
conf : | a MgConf object |
entity1 : | an object implementing the MgEntity interface |
entity2 : | an object implementing the MgEntity interface |
entity1_has_fk : | TRUE if the returned constraints are the one for which entity1 contains the foreign key |
Returns : | a new list of the constraints |
void user_function (MgConf *mgconf, gpointer arg1, gpointer user_data);
Emitted when a MgQuery object has been added to the list of queries assumed by mgconf (using the mg_conf_assume_query()).
mgconf : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
void user_function (MgConf *mgconf, gpointer arg1, gpointer user_data);
Emitted when a MgQuery object has been removed from the list of queries assumed by mgconf (using the mg_conf_unassume_query()).
mgconf : | the object which received the signal. |
arg1 : | |
user_data : | user data set when the signal handler was connected. |
<<< Objects related to the DBMS server | MgServer >>> |