MgBase

MgBase — The base class for many of the library'objects

Synopsis




            MgBase;
guint       mg_base_get_type                (void);
GObject*    mg_base_new                     (void);
void        mg_base_set_conf                (MgBase *base,
                                             MgConf *conf);
MgConf*     mg_base_get_conf                (MgBase *base);
void        mg_base_set_id                  (MgBase *base,
                                             guint id);
void        mg_base_set_name                (MgBase *base,
                                             const gchar *name);
void        mg_base_set_description         (MgBase *base,
                                             const gchar *descr);
void        mg_base_set_owner               (MgBase *base,
                                             const gchar *owner);
guint       mg_base_get_id                  (MgBase *base);
const gchar* mg_base_get_name               (MgBase *base);
const gchar* mg_base_get_description        (MgBase *base);
const gchar* mg_base_get_owner              (MgBase *base);
void        mg_base_nullify                 (MgBase *base);
void        mg_base_nullify_check           (MgBase *base);
void        mg_base_changed                 (MgBase *base);
void        mg_base_block_changed           (MgBase *base);
void        mg_base_unblock_changed         (MgBase *base);
void        mg_base_dump                    (MgBase *base,
                                             guint offset);

Object Hierarchy


  GObject
   +----MgBase
         +----MgCondition
         +----MgContext
         +----MgDatabase
         +----MgDbConstraint
         +----MgDbField
         +----MgDbTable
         +----MgGraphviz
         +----MgHandlerBoolean
         +----MgHandlerCidr
         +----MgHandlerNone
         +----MgHandlerNumerical
         +----MgHandlerPassmd5
         +----MgHandlerString
         +----MgHandlerTime
         +----MgHandlerText
         +----MgJoin
         +----MgParameter
         +----MgQfield
         +----MgQuery
         +----MgRefBase
         +----MgResultSet
         +----MgServerAggregate
         +----MgServerDataType
         +----MgServerFunction
         +----MgTarget
         +----MgWorkCore
         +----MgGraph
         +----MgGraphItem

Properties


  "changed-blocked"      gboolean              : Read / Write
  "conf"                 gpointer              : Read / Write

Signals


"changed"   void        user_function      (MgBase  *mgbase,
                                            gpointer user_data)      : Run first
"descr-changed"
            void        user_function      (MgBase  *mgbase,
                                            gpointer user_data)      : Run first
"id-changed"
            void        user_function      (MgBase  *mgbase,
                                            gpointer user_data)      : Run first
"name-changed"
            void        user_function      (MgBase  *mgbase,
                                            gpointer user_data)      : Run first
"nullified" void        user_function      (MgBase  *mgbase,
                                            gpointer user_data)      : Run first
"owner-changed"
            void        user_function      (MgBase  *mgbase,
                                            gpointer user_data)      : Run first

Description

This class defines a common behaviour for most of the objects of this library. As the data dictionnary is quite dynamic, the default way by which GObjects are managed (referenced and unreferenced when not needed anymore using g_object_[un]ref()) is not enough: sometimes this behaviour should be kept, and sometimes an object's destruction should be forced and all the other reference holders of that object should take appropriate actions and drop their reference on that object.

Just an example to illustrate this: suppose a data type has been removed from the database itself, then the corresponding MgServerDataType must be destroyed since it does not represent a valid data type anymore. MgServerDataType object are all managed by the corresponding MgServer (it has a reference on them); so the mg_base_nullify() method is called on that object which will tell all the other users of that object (MgDbField, MgParameter, etc) to drop their reference on it (if they had one) and take the appropriate actions (both MgDbField and MgParameter will destroy themselves in the same way).

Details

MgBase

typedef struct _MgBase MgBase;


mg_base_get_type ()

guint       mg_base_get_type                (void);

Returns :

mg_base_new ()

GObject*    mg_base_new                     (void);

Creates a new MgBase object. This object class is normally not instantiated directly but through child classes objects' intantiation

Returns : the newly created object

mg_base_set_conf ()

void        mg_base_set_conf                (MgBase *base,
                                             MgConf *conf);

Sets the MgConf to which base is attached to. It has no other action than to store it to easily be able to retreive it.

base : a MgBase object
conf : the MgConf to which base is attached

mg_base_get_conf ()

MgConf*     mg_base_get_conf                (MgBase *base);

Fetch the corresponding MgConf object.

base : a MgBase object
Returns : the MgConf object to which base is attached to

mg_base_set_id ()

void        mg_base_set_id                  (MgBase *base,
                                             guint id);

Sets the id of the object. The id is set to 0 by default (which means the object does not use the id at all). WARNING: the id is not checked which means no search is made to see if the id is already used

base : a MgBase object
id :

mg_base_set_name ()

void        mg_base_set_name                (MgBase *base,
                                             const gchar *name);

Sets the name of the MgBase object. If the name is changed, then the "name_changed" signal is emitted.

base : a MgBase object
name :

mg_base_set_description ()

void        mg_base_set_description         (MgBase *base,
                                             const gchar *descr);

Sets the description of the MgBase object. If the description is changed, then the "descr_changed" signal is emitted.

base : a MgBase object
descr :

mg_base_set_owner ()

void        mg_base_set_owner               (MgBase *base,
                                             const gchar *owner);

Sets the owner of the MgBase object. If the owner is changed, then the "owner_changed" signal is emitted.

base : a MgBase object
owner :

mg_base_get_id ()

guint       mg_base_get_id                  (MgBase *base);

Fetch the id of the MgBase object.

base : a MgBase object
Returns : the id.

mg_base_get_name ()

const gchar* mg_base_get_name               (MgBase *base);

Fetch the name of the MgBase object.

base : a MgBase object
Returns : the object's name.

mg_base_get_description ()

const gchar* mg_base_get_description        (MgBase *base);

Fetch the description of the MgBase object.

base : a MgBase object
Returns : the object's description.

mg_base_get_owner ()

const gchar* mg_base_get_owner              (MgBase *base);

Fetch the owner of the MgBase object.

base : a MgBase object
Returns : the object's owner.

mg_base_nullify ()

void        mg_base_nullify                 (MgBase *base);

Force the base object to be destroyed, even if we don't have a reference on it (we can't call g_object_unref() then) and even if the object is referenced multiple times by other objects.

The "nullified" signal is then emitted to tell the other reference holders that the object must be destroyed and that they should give back their reference (using g_object_unref()). However if a reference is still present, the object will not actually be destroyed and will still be alive, but its state may not be deterministic.

This is usefull because sometimes objects need to disappear even if they are referenced by other objects. This usage is the same as with the gtk_widget_destroy() function on widgets.

base : a MgBase object

mg_base_nullify_check ()

void        mg_base_nullify_check           (MgBase *base);

Checks that the object has been nullified, and if not, then calls mg_base_nullify() on it. This is usefull for objects inheriting the MGBase object to be called first line in their dispose() method.

base : a MgBase object

mg_base_changed ()

void        mg_base_changed                 (MgBase *base);

Force emission of the "changed" signal, except if mg_base_block_changed() has been called.

base : a MgBase object

mg_base_block_changed ()

void        mg_base_block_changed           (MgBase *base);

No "changed" signal will be emitted.

base : a MgBase object

mg_base_unblock_changed ()

void        mg_base_unblock_changed         (MgBase *base);

The "changed" signal will again be emitted.

base : a MgBase object

mg_base_dump ()

void        mg_base_dump                    (MgBase *base,
                                             guint offset);

Writes a textual description of the object to STDOUT. This function only exists if libergeant is compiled with the "--enable-debug" option. This is a virtual function.

base : a MgBase object
offset : the offset (in caracters) at which the dump will start

Property Details

The "changed-blocked" property

  "changed-blocked"      gboolean              : Read / Write

Default value: FALSE


The "conf" property

  "conf"                 gpointer              : Read / Write

Signal Details

The "changed" signal

void        user_function                  (MgBase  *mgbase,
                                            gpointer user_data)      : Run first

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

The "descr-changed" signal

void        user_function                  (MgBase  *mgbase,
                                            gpointer user_data)      : Run first

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

The "id-changed" signal

void        user_function                  (MgBase  *mgbase,
                                            gpointer user_data)      : Run first

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

The "name-changed" signal

void        user_function                  (MgBase  *mgbase,
                                            gpointer user_data)      : Run first

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

The "nullified" signal

void        user_function                  (MgBase  *mgbase,
                                            gpointer user_data)      : Run first

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

The "owner-changed" signal

void        user_function                  (MgBase  *mgbase,
                                            gpointer user_data)      : Run first

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