midgard_object_class

midgard_object_class — Reflection class for MgdObject derived ones.

Synopsis


#include <midgard/midgard.h>

MgdObject *         midgard_object_class_factory        (MidgardConnection *mgd,
                                                         MidgardObjectClass *klass,
                                                         const GValue *val);
const gchar *       midgard_object_class_get_primary_property
                                                        (MidgardObjectClass *klass);
const gchar *       midgard_object_class_get_property_parent
                                                        (MidgardObjectClass *klass);
const gchar *       midgard_object_class_get_property_up
                                                        (MidgardObjectClass *klass);
MidgardObjectClass ** midgard_object_class_list_children
                                                        (MidgardObjectClass *klass);
gboolean            midgard_object_class_is_multilang   (MidgardObjectClass *klass);
MgdObject *         midgard_object_class_get_object_by_guid
                                                        (MidgardConnection *mgd,
                                                         const gchar *guid);
MgdObject *         midgard_object_class_get_object_by_path
                                                        (MidgardConnection *mgd,
                                                         const gchar *classname,
                                                         const gchar *object_path);
gboolean            midgard_object_class_undelete       (MidgardConnection *mgd,
                                                         const gchar *guid);

Description

MidgardObjectClass is a helper and reflection like class for every MgdObject derived one. With MidgardObjectClass you may create new instances: midgard_object_class_factory(), undelete objects: midgard_object_class_undelete(), check if class is multilang, etc.

Details

midgard_object_class_factory ()

MgdObject *         midgard_object_class_factory        (MidgardConnection *mgd,
                                                         MidgardObjectClass *klass,
                                                         const GValue *val);

val should be initialized as G_TYPE_STRING or G_TYPE_UINT and should hold database id or guid value. Empty object (not fecthed from database) is returned if value is explicitly set to NULL.

mgd :

MidgardConnection instance

klass :

MidgardObjectClass

val :

GValue of string or uint type

Returns :

newly allocated MgdObject object, or NULL on failure.

midgard_object_class_get_primary_property ()

const gchar *       midgard_object_class_get_primary_property
                                                        (MidgardObjectClass *klass);

klass :

Returns :


midgard_object_class_get_property_parent ()

const gchar *       midgard_object_class_get_property_parent
                                                        (MidgardObjectClass *klass);

Returned string is a pointer to object's parent property, and you should not free it. Parent property is a property which holds value of field which points to parent object's identifier. Parent property always points to object's identifier which is not the same type as given MidgardObjectClass klass.

This is static method. NULL is returned if parent property is not found.

klass :

MidgardObjectClass

Returns :

the name of object's parent property or NULL.

midgard_object_class_get_property_up ()

const gchar *       midgard_object_class_get_property_up
                                                        (MidgardObjectClass *klass);

Returned string is a pointer to object's up property. Up property is a property which holds value of field which points to "upper" object's identifier. Up property always points to object's identifier which is the same type as given MidgardObjectClass klass.

This is static method.

NULL is returned if up property is not registered for given class.

klass :

MidgardObjectClass

Returns :

the name of object's up property or NULL.

midgard_object_class_list_children ()

MidgardObjectClass ** midgard_object_class_list_children
                                                        (MidgardObjectClass *klass);

Returns newly allocated and NULL terminated children ( in midgard tree ) classes' pointers . Returned array should be freed if no longer needed without freeing array's elements. Elements are static pointers owned by GLib.

This is static method.

klass :

MidgardObjectClass

Returns :

array of childreen ( in midgard tree ) classes of the given MidgardObjectClass.

midgard_object_class_is_multilang ()

gboolean            midgard_object_class_is_multilang   (MidgardObjectClass *klass);

Checks whether given MidgardObjectClass is multilingual.

This is static method.

klass :

MidgardObjectClass

Returns :

TRUE if MidgardObjectClass is mutlilingual, FALSE otherwise.

midgard_object_class_get_object_by_guid ()

MgdObject *         midgard_object_class_get_object_by_guid
                                                        (MidgardConnection *mgd,
                                                         const gchar *guid);

MidgardError set by this function: - MGD_ERR_NOT_EXISTS: object is not found - MGD_ERR_OBJECT_DELETED: object is already deleted - MGD_ERR_OBJECT_PURGED: object is purged - MGD_ERR_SITEGROUP_VIOLATION if more than one record exists

This is static method.

mgd :

MidgardConnection handler

guid :

guid string which should identify an object

Returns :

MgdObject object identified by given guid

midgard_object_class_get_object_by_path ()

MgdObject *         midgard_object_class_get_object_by_path
                                                        (MidgardConnection *mgd,
                                                         const gchar *classname,
                                                         const gchar *object_path);

Empty name is accepted for object_path. For example, if you need to get by path object with empty name use "/" as path. If one of object in path has empty name, the full path could look like this: "/A/B//D".

This is static method.

Cases to set NULL: - object is not found by path - object's class has neither name nor id member - object's class doesn't have both: parent and up property

MidgardError set by this method: - MGD_ERR_INTERNAL - MGD_ERR_NOT_EXISTS

mgd :

MidgardConnection holder

classname :

name of the class for which object should be returned

object_path :

a path, at which object should be found

Returns :

MgdObject instance of classname or NULL if object is not found

midgard_object_class_undelete ()

gboolean            midgard_object_class_undelete       (MidgardConnection *mgd,
                                                         const gchar *guid);

Undelete midgard object identified by given guid

MidgardError set by this method: - MGD_ERR_NOT_EXISTS - MGD_ERR_OBJECT_PURGED - MGD_ERR_INTERNAL

mgd :

MidgardConnection object

guid :

string which should identify object

Returns :

TRUE on success, FALSE otherwise

See Also

MgdObject, MidgardSchema