| Midgard2 Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
midgard_object_classmidgard_object_class — Reflection class for MgdObject derived ones. |
#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);
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.
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.
const gchar * midgard_object_class_get_primary_property (MidgardObjectClass *klass);
|
|
Returns : |
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.
|
MidgardObjectClass |
Returns : |
the name of object's parent property or NULL.
|
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.
|
MidgardObjectClass |
Returns : |
the name of object's up property or NULL.
|
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.
|
MidgardObjectClass |
Returns : |
array of childreen ( in midgard tree ) classes of the given MidgardObjectClass. |
gboolean midgard_object_class_is_multilang (MidgardObjectClass *klass);
Checks whether given MidgardObjectClass is multilingual.
This is static method.
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.
|
MidgardConnection handler |
|
guid string which should identify an object |
Returns : |
MgdObject object identified by given guid
|
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