|
typedef struct _QofObject | QofObject |
|
typedef void(* | QofForeachCB) (gpointer obj, gpointer user_data) |
|
typedef void(* | QofForeachTypeCB) (QofObject *type, gpointer user_data) |
|
typedef void(* | QofForeachBackendTypeCB) (QofIdTypeConst type, gpointer backend_data, gpointer user_data) |
|
|
gboolean | qof_object_register (const QofObject *object) |
|
const QofObject * | qof_object_lookup (QofIdTypeConst type_name) |
|
gpointer | qof_object_new_instance (QofIdTypeConst type_name, QofBook *book) |
|
const gchar * | qof_object_get_type_label (QofIdTypeConst type_name) |
|
const gchar * | qof_object_printable (QofIdTypeConst type_name, gpointer instance) |
|
void | qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data) |
|
void | qof_object_foreach (QofIdTypeConst type_name, QofBook *book, QofEntityForeachCB cb, gpointer user_data) |
|
gboolean | qof_object_register_backend (QofIdTypeConst type_name, const gchar *backend_name, gpointer be_data) |
|
gpointer | qof_object_lookup_backend (QofIdTypeConst type_name, const gchar *backend_name) |
|
void | qof_object_foreach_backend (const char *backend_name, QofForeachBackendTypeCB cb, gpointer user_data) |
|
|
void | qof_object_initialize (void) |
|
void | qof_object_shutdown (void) |
|
QOF Objects provide the means for describing a QofEntity to allow a storage backend to load and write a QofBook. While an entity can be thought of as an identified instance of some thing, the QOF Object describes how that entity can be created, how to find other entities of the same type, whether the object can be cached in the backend and how to compare entities of the same type.
- QofObject describes how to relate one entity to another.
- QofClass describes how to get and set data within the entity.
To work with your own QOF Objects, you can use the QOF Generator to create sample objects and a mini-application with the SQL-type query interface. http://qof-gen.sourceforge.net/
#define QOF_OBJECT_VERSION 4 |
Defines the version of the core object object registration interface. Only object modules compiled against this version of the interface will load properly
Definition at line 57 of file qofobject.h.
Invoke the callback 'cb' on every instance ov a particular object type. It is presumed that the 'book' stores or somehow identifies a colllection of instances; thus the callback will be invoked only for those instances stored in the book.
Definition at line 174 of file qofobject.c.
180 if (!book || !type_name)
184 PINFO (
"type=%s", type_name);
189 PERR (
"No object of type %s", type_name);
199 obj->
foreach (col, cb, user_data);
#define PERR(format, args...)
#define PINFO(format, args...)
QofCollection * qof_book_get_collection(QofBook *book, QofIdType entity_type)
const QofObject * qof_object_lookup(QofIdTypeConst name)
struct QofCollection_s QofCollection
void(* foreach)(QofCollection *, QofEntityForeachCB, gpointer)
void qof_object_foreach_type |
( |
QofForeachTypeCB |
cb, |
|
|
gpointer |
user_data |
|
) |
| |
Invoke the callback 'cb' on every object class definition. The user_data pointer is passed back to the callback.
Definition at line 140 of file qofobject.c.
147 for (l = object_modules; l; l = l->next)
150 (cb) (obj, user_data);
Get the printable label for a type. This label is not translated; you must use _() on it if you want a translated version.
Definition at line 223 of file qofobject.c.
234 return (obj->type_label);
const QofObject * qof_object_lookup(QofIdTypeConst name)
Lookup an object definition
Definition at line 305 of file qofobject.c.
310 g_return_val_if_fail (object_is_initialized, NULL);
315 for (qiter = object_modules; qiter; qiter = qiter->next)
gint safe_strcmp(const gchar *da, const gchar *db)
Create an instance of the indicated type, returning a pointer to that instance. This routine just calls the (*new) callback on the object definition.
Definition at line 42 of file qofobject.c.
54 return (obj->
create (book));
const QofObject * qof_object_lookup(QofIdTypeConst name)
gpointer(* create)(QofBook *)
const gchar* qof_object_printable |
( |
QofIdTypeConst |
type_name, |
|
|
gpointer |
instance |
|
) |
| |
- Returns
- a Human-readable string name for an instance
Definition at line 205 of file qofobject.c.
209 if (!type_name || !obj)
const QofObject * qof_object_lookup(QofIdTypeConst name)
const gchar *(* printable)(gpointer instance)
gboolean qof_object_register |
( |
const QofObject * |
object | ) |
|
Register new types of object objects
Definition at line 278 of file qofobject.c.
280 g_return_val_if_fail (object_is_initialized, FALSE);
287 if (g_list_index (object_modules, (gpointer)
object) == -1)
289 g_list_prepend (object_modules, (gpointer)
object);
294 if (object->book_begin && book_list)
297 for (node = book_list; node; node = node->next)
298 object->book_begin (node->data);
#define QOF_OBJECT_VERSION
gboolean qof_object_register_backend |
( |
QofIdTypeConst |
type_name, |
|
|
const gchar * |
backend_name, |
|
|
gpointer |
be_data |
|
) |
| |
Register and lookup backend-specific data for this particular object
Definition at line 325 of file qofobject.c.
329 g_return_val_if_fail (object_is_initialized, FALSE);
331 if (!type_name || *type_name ==
'\0' ||
332 !backend_name || *backend_name ==
'\0' || !be_data)
335 ht = g_hash_table_lookup (backend_data, backend_name);
340 ht = g_hash_table_new (g_str_hash, g_str_equal);
341 g_hash_table_insert (backend_data, (gchar *) backend_name, ht);
345 g_hash_table_insert (ht, (gchar *) type_name, be_data);