| Midgard2 Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | ||||
#include <midgard/midgard.h> struct MidgardCollector; typedef MidgardCollectorClass; MidgardCollector * midgard_collector_new (MidgardConnection *mgd,const gchar *typename,const gchar *domain,GValue *value); gboolean midgard_collector_set_key_property (MidgardCollector *self,const gchar *key,GValue *value); gboolean midgard_collector_add_value_property (MidgardCollector *self,const gchar *value); gboolean midgard_collector_set (MidgardCollector *self,const gchar *key,const gchar *subkey,GValue *value); GData * midgard_collector_get (MidgardCollector *self,const gchar *key); GValue * midgard_collector_get_subkey (MidgardCollector *self,const gchar *key,const gchar *subkey); gchar ** midgard_collector_list_keys (MidgardCollector *self); gboolean midgard_collector_merge (MidgardCollector *self,MidgardCollector *mc,gboolean overwrite); gboolean midgard_collector_remove_key (MidgardCollector *self,const gchar *key); gboolean midgard_collector_add_constraint (MidgardCollector *self,const gchar *name,const gchar *op,const GValue *value); gboolean midgard_collector_add_constraint_with_property (MidgardCollector *self,const gchar *property_a,const gchar *op,const gchar *property_b); gboolean midgard_collector_begin_group (MidgardCollector *self,const gchar *type); gboolean midgard_collector_end_group (MidgardCollector *self); gboolean midgard_collector_add_order (MidgardCollector *self,const gchar *name,const gchar *dir); void midgard_collector_set_offset (MidgardCollector *self,guint offset); void midgard_collector_set_limit (MidgardCollector *self,guint limit); void midgard_collector_count (MidgardCollector *self); gboolean midgard_collector_execute (MidgardCollector *self);
The main idea of MidgardCollector is code, resources and data reusability for all data values which are not objects itself and as part of any object could be retrieved from Midgard database without any need to retrieve full objects' records. MidgardCollector is special limited resource data handler and is optimized for performance and data accessibility.
MidgardCollector * midgard_collector_new (MidgardConnection *mgd,const gchar *typename,const gchar *domain,GValue *value);
typename should be any MidgardDBObject derived class name.
domain is property name which is registered for given class, and should not be
unique per object or record. In other words, domain is a common property (and value)
for group of objects expected in collection.
value must be of domain property type, and is owned by MidgardCollector instance.
If you need reuse given value, make a copy.
Cases to return NULL:
mgd MidgardConnection instance is invalid
typename is not registered in GType system or it's not MidgardDBObject derived
domain property is not registered for given typename class
value is of invalid type
|
MidgardConnection instance |
|
name of given class, which collector is initialized for |
|
collection' domain |
|
domain's constraint value |
Returns : |
MidgardCollector instance, or NULL on failure |
gboolean midgard_collector_set_key_property (MidgardCollector *self,const gchar *key,GValue *value);
If value is explicitly set to NULL , then all key property name's records
are selected from database and set in internal collector's resultset.
If not, key property name and its value is used as constraint to limit selected
records from database. In latter case add_value_property method should be invoked.
GValue value passed as third argument is owned by Midgard Collector. If value
should be reused, its copy should be passed to constructor.
Cases to return FALSE:
self MidgardCollector instance is invalid
key property is not registered for the typename class
value is of invalid type
key property is already set for self MidgardCollector
|
MidgardCollector instance |
|
property name which must be a key |
|
optional value of key's constraint |
Returns : |
TRUE if key has been set, FALSE otherwise |
gboolean midgard_collector_add_value_property (MidgardCollector *self,const gchar *value);
Cases to return FALSE:
self, MidgardCollector object is invalid
value property is not registered for the class, which has been initialized for given MidgardCollector
Number of value properties added to Midgard Collector is limited by the number of properties registered for type which has been initialized for the given MidgardCollector instance.
See: midgard_query_builder_add_constraint() for available property name pattern
|
MidgardCollector instance |
|
property name |
Returns : |
TRUE if named value property has been added, FALSE otherwise |
gboolean midgard_collector_set (MidgardCollector *self,const gchar *key,const gchar *subkey,GValue *value);
Cases to return FALSE:
self, MidgardCollector instance is invalid
subkey property name is not registered for collestor's class
value is of invalid type
If the key is already added to MidgardCollector then its value (as subkey&value pair) is destroyed and new one is set. In other case new key and its subkey&value pair is added to collector.
Key used in this function is a value returned ( or set ) for collector's key. Keys are collection of values returned from property fields. Subkey is an explicit property name.
GValue value argument is owned by MidgardCollector.
If value should be reused, its copy should be passed as method argument.
|
MidgardCollector instance |
|
key name for which subkey&value pair should be set |
|
property name which is a subkey |
|
value for given subkey
|
Returns : |
TRUE, if key's value has been set, FALSE otherwise |
GData * midgard_collector_get (MidgardCollector *self,const gchar *key);
GData keys ( collector's subkeys ) are inserted to GData as Quarks , so you must call g_quark_to_string if you need to get strings ( e.g. implementing hash table for language bindings ).
|
MidgardCollector instance |
|
name of the key to look for |
Returns : |
GData for the given key or NULL if key is not found in collection. [transfer full]
|
GValue * midgard_collector_get_subkey (MidgardCollector *self,const gchar *key,const gchar *subkey);
|
MidgardCollector instance |
|
name of the key |
|
name of key's subkey to look for |
Returns : |
subkey's GValue value or NULL if not found |
gboolean midgard_collector_merge (MidgardCollector *self,MidgardCollector *mc,gboolean overwrite);
If third overwrite parameter is set as TRUE then all keys which exists
in self and mc collector's instance will be oberwritten in self colection
instance. If set as FALSE , only those keys will be added, which do not exist
in self collection and exist in mc collection.
Cases to return FALSE:
Second argument is not valid MidgardCollector
mc, MidgardCollector has no keys collection
|
MidgardCollector instance |
|
MidgardCollector instance |
|
whether overwrite collector's keys |
Returns : |
TRUE if collections has been merged, FALSE otherwise |
gboolean midgard_collector_remove_key (MidgardCollector *self,const gchar *key);
Removes key and associated value from the given MidgardCollector instance.
|
MidgardCollector instance |
|
name of the key in collector's collection |
Returns : |
TRUE if key (and its value) has been removed from collection, FALSE otherwise |
gboolean midgard_collector_add_constraint (MidgardCollector *self,const gchar *name,const gchar *op,const GValue *value);
gboolean midgard_collector_add_constraint_with_property (MidgardCollector *self,const gchar *property_a,const gchar *op,const gchar *property_b);
gboolean midgard_collector_begin_group (MidgardCollector *self,const gchar *type);
gboolean midgard_collector_add_order (MidgardCollector *self,const gchar *name,const gchar *dir);
void midgard_collector_set_offset (MidgardCollector *self,guint offset);
void midgard_collector_set_limit (MidgardCollector *self,guint limit);