Midgard Collector


Typedefs

typedef MidgardCollector MidgardCollector
typedef MidgardCollectorClass MidgardCollectorClass

Functions

GType midgard_collector_get_type (void)
MidgardCollectormidgard_collector_new (MidgardConnection *mgd, const gchar *classname, const gchar *domain, GValue *value)
gboolean midgard_collector_set_key_property (MidgardCollector *collector, const gchar *key, GValue *value)
gboolean midgard_collector_add_value_property (MidgardCollector *collector, const gchar *value)
gboolean midgard_collector_set (MidgardCollector *collector, const gchar *key, const gchar *subkey, GValue *value)
GHashTable * midgard_collector_get (MidgardCollector *collector, const gchar *key)
GValue * midgard_collector_get_subkey (MidgardCollector *collector, const gchar *key, const gchar *subkey)
const gchar ** midgard_collector_list_keys (MidgardCollector *self)
gboolean midgard_collector_merge (MidgardCollector *self, MidgardCollector *mc, gboolean overwrite)
gboolean midgard_collector_remove_key (MidgardCollector *collector, const gchar *key)
void midgard_collector_destroy (MidgardCollector *collector)
gboolean midgard_collector_add_constraint (MidgardCollector *self, const gchar *name, const gchar *op, const GValue *value)
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)

Detailed Description

MidgardCollector is special limited resource data handler and is optimized for performance and data accessibility. The most important approach is to reuse the same functionality for Midgard features like style engine, objects' parameters and object's attachments.

http://www.midgard-project.org/development/mrfc/0029.html

Object Hierarchy


Typedef Documentation

typedef struct MidgardCollector MidgardCollector
 

The opaque Midgard Collector type.

Definition at line 61 of file midgard_collector.h.

typedef struct MidgardCollectorClass MidgardCollectorClass
 

The opaque Midgard Collector Class type.

Definition at line 74 of file midgard_collector.h.


Function Documentation

gboolean midgard_collector_add_constraint MidgardCollector self,
const gchar *  name,
const gchar *  op,
const GValue *  value
 

Method inherited from MidgardQueryBuilder class.

http://www.midgard-project.org/api-docs/midgard/core/html/group__qb.html#g523f6a9410a76d0f38192abcf4bc0af1

Definition at line 386 of file midgard_collector.c.

References _MidgardCollectorPrivate::builder, and MidgardCollector::private.

Referenced by midgard_object_get_languages(), and midgard_object_get_parameter().

gboolean midgard_collector_add_order MidgardCollector self,
const gchar *  name,
const gchar *  dir
 

Method inherited from MidgardQueryBuilder class.

http://www.midgard-project.org/api-docs/midgard/core/html/group__qb.html#g2f9fd0992e935498c85c0ffac15d5811

Definition at line 415 of file midgard_collector.c.

References _MidgardCollectorPrivate::builder, and MidgardCollector::private.

gboolean midgard_collector_add_value_property MidgardCollector collector,
const gchar *  value
 

Adds value property for the given MidgardCollector object.

Parameters:
collector MidgardCollector instance
[in] value property name for which value should be set
Returns:
TRUE if value has been added to MidgardCollector, FALSE otherwise
Cases to return FALSE:

  • MidgardCollector object is invalid
  • value property is not registered for the MidgardCollector's classname

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 Midgard Collector instance.

Definition at line 149 of file midgard_collector.c.

References _MidgardCollectorPrivate::keyname, MidgardCollector::private, and _MidgardCollectorPrivate::values.

Referenced by midgard_object_get_parameter().

gboolean midgard_collector_begin_group MidgardCollector self,
const gchar *  type
 

Method inherited from MidgardQueryBuilder class.

http://www.midgard-project.org/api-docs/midgard/core/html/group__qb.html#gf916e78a4f4eb90aa84278148982b734

Definition at line 397 of file midgard_collector.c.

References _MidgardCollectorPrivate::builder, and MidgardCollector::private.

void midgard_collector_count MidgardCollector self  ) 
 

Not yet re-implemented

Definition at line 452 of file midgard_collector.c.

void midgard_collector_destroy MidgardCollector collector  ) 
 

Destroys given MidgardCollector object.

Parameters:
collector MidgardCollector instance
Destroys all key, value pairs in collection. Frees memory allocated for keys and values and for collector object itself.

Definition at line 376 of file midgard_collector.c.

gboolean midgard_collector_end_group MidgardCollector self  ) 
 

Method inherited from MidgardQueryBuilder class.

http://www.midgard-project.org/api-docs/midgard/core/html/group__qb.html#g95473e600e569c9b4982501a5097b9ea

Definition at line 406 of file midgard_collector.c.

References _MidgardCollectorPrivate::builder, and MidgardCollector::private.

gboolean midgard_collector_execute MidgardCollector self  ) 
 

Executes SQL query and set internal keys&values collection.

Parameters:
self MidgardCollector instance
Returns:
TRUE on success , FALSE otherwise
Re-implementation of MidgardQueryBuilder execute method. Unlike QB's execute method this one returns boolean value. Resultset is stored inernally by MidgardCollector instance.

Cases to return FALSE:

  • Method set_key_property was not invoked
  • Method add_valye property was not invoked
  • Database engine returned SQL query syntax error
  • No record was selected from database

In any other case this method returns TRUE.

Definition at line 459 of file midgard_collector.c.

References _MidgardCollectorPrivate::keyname, MidgardCollector::private, and _MidgardCollectorPrivate::values.

Referenced by midgard_object_get_languages(), and midgard_object_get_parameter().

GHashTable* midgard_collector_get MidgardCollector collector,
const gchar *  key
 

Get key's value for the given MidgardCollector object.

Parameters:
collector MidgardCollector instance
[in] key name of the key to look for
Returns:
GHashTable for the given key or NULL if key is not found in key's collection. GHashTable's keys ( collector's subkeys ) are inserted to GHashTable as Quarks , so you must call g_quark_to_string if you need get strings ( e.g. implementing hash table for language bindings ).

Definition at line 210 of file midgard_collector.c.

References _MidgardCollectorPrivate::keyname, _MidgardCollectorPrivate::keyshash, and MidgardCollector::private.

Referenced by midgard_collector_merge().

GValue* midgard_collector_get_subkey MidgardCollector collector,
const gchar *  key,
const gchar *  subkey
 

Gets value associated with the key's subkey.

Parameters:
collector MidgardCollector instance
[in] key name of the name to look for
[in] subkey name of the subkey for which value should be found
Returns:
GValue of a subkey

Definition at line 225 of file midgard_collector.c.

References _MidgardCollectorPrivate::keyshash, and MidgardCollector::private.

Referenced by midgard_object_get_parameter().

GType midgard_collector_get_type void   ) 
 

Returns MidgardCollector type. Registers the type as a fundamental GType unless already registered.

Definition at line 656 of file midgard_collector.c.

const gchar** midgard_collector_list_keys MidgardCollector self  ) 
 

Returns all keys in collection.

Parameters:
self MidgardCollector instance
Returns:
NULL terminated array of strings or NULL
Returned array of string is newly created array with pointers to each string in array. It should be freed without any need to free each string. g_free should be used to free list keys instead of g_strfreev.

Definition at line 326 of file midgard_collector.c.

References _MidgardCollectorPrivate::keyshash, and MidgardCollector::private.

Referenced by midgard_collector_merge(), and midgard_object_get_languages().

gboolean midgard_collector_merge MidgardCollector self,
MidgardCollector mc,
gboolean  overwrite
 

Merges collection's keys and its values.

Parameters:
self MidgardCollector instance
mc MidgardCollector to get keys from
overwrite boolean which defines whether keys should be overwtitten
Returns:
TRUE if collectors has been merged, FALSE otherwise
Cases to return FALSE:

  • Second argument is not MIDGARD_COLLECTOR object type
  • Second argument object has no keys collection

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.

Definition at line 280 of file midgard_collector.c.

References _MidgardCollectorPrivate::keyshash, midgard_collector_get(), midgard_collector_list_keys(), and MidgardCollector::private.

Here is the call graph for this function:

MidgardCollector* midgard_collector_new MidgardConnection mgd,
const gchar *  classname,
const gchar *  domain,
GValue *  value
 

Creates new Midgard Collector object instance

Parameters:
[in] mgd MidgardConnection pointer
[in] domain property name for which domain should be set
[in] value value of the domain property
Returns:
MidgardCollector object or NULL
Property name used as domain must be registered property for te given classname. Given value must be the same type as type registered for domain property. 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 NULL:

  • connection handler is invalid
  • classname is not registered in schema or doesn't extend schema class
  • domain property is not registered for classname
  • value has invalid type

Definition at line 70 of file midgard_collector.c.

References _MidgardCollectorPrivate::builder, MidgardConnection::mgd, midgard_query_builder_add_constraint(), midgard_query_builder_new(), and MidgardCollector::private.

Referenced by midgard_object_get_languages(), and midgard_object_get_parameter().

Here is the call graph for this function:

gboolean midgard_collector_remove_key MidgardCollector collector,
const gchar *  key
 

Removes key and associated value for the given MidgardCollector object.

Parameters:
collector MidgardCollector instance
[in] key name of the key in key's collection
Returns:
TRUE if key and its value have been removed , FALSE if key is not found in collection.

Definition at line 355 of file midgard_collector.c.

References _MidgardCollectorPrivate::keyshash, and MidgardCollector::private.

Referenced by midgard_object_set_parameter().

gboolean midgard_collector_set MidgardCollector collector,
const gchar *  key,
const gchar *  subkey,
GValue *  value
 

Sets ( or adds new key ) and new key's subkey for the given MidgardCollector.

Parameters:
collector MidgardCollector instance
[in] key name for which value should be set
[in] subkey property name which explicitly should be defined as subkey
[in] value GValue for the given subkey property
Returns:
TRUE if key's value has been set, FALSE otherwise
Cases to return FALSE:

  • MidgardCollector object is invalid
  • subkey property name is not registered for collestor's class
  • value has 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.

Definition at line 173 of file midgard_collector.c.

References _MidgardCollectorPrivate::keyshash, and MidgardCollector::private.

Referenced by midgard_object_set_parameter().

gboolean midgard_collector_set_key_property MidgardCollector collector,
const gchar *  key,
GValue *  value
 

Sets key property for the given MidgardCollector object.

Parameters:
collector MidgardCollector instance
[in] key property name for which key should be set
[in] value value of the key property
Returns:
TRUE if key has been added to MidgardCollector , FALSE otherwise
Cases to return FALSE:

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.

Definition at line 119 of file midgard_collector.c.

References _MidgardCollectorPrivate::builder, midgard_query_builder_add_constraint(), MidgardCollector::private, and _MidgardCollectorPrivate::values.

Referenced by midgard_object_get_languages(), and midgard_object_get_parameter().

Here is the call graph for this function:

void midgard_collector_set_limit MidgardCollector self,
guint  limit
 

Method inherited from MidgardQueryBuilder class.

http://www.midgard-project.org/api-docs/midgard/core/html/group__qb.html#g5142ab9d65759a02e706d8a00902784b

Definition at line 434 of file midgard_collector.c.

References _MidgardCollectorPrivate::builder, and MidgardCollector::private.

void midgard_collector_set_offset MidgardCollector self,
guint  offset
 

Method inherited from MidgardQueryBuilder class.

http://www.midgard-project.org/api-docs/midgard/core/html/group__qb.html#g0243d37dfe9017bb3146209fbeaa23ee

Definition at line 425 of file midgard_collector.c.

References _MidgardCollectorPrivate::builder, and MidgardCollector::private.


Generated on Thu Feb 22 06:15:20 2007 for midgard-core by  doxygen 1.4.6