32 static QofLogModule log_module = QOF_MOD_OBJECT;
34 static gboolean object_is_initialized = FALSE;
35 static GList *object_modules = NULL;
36 static GList *book_list = NULL;
48 gboolean get_object_is_initialized(
void );
49 GList* get_object_modules(
void );
50 GList* get_book_list(
void );
57 get_object_is_initialized(
void )
59 return object_is_initialized;
63 get_object_modules(
void )
65 return object_modules;
81 if (!type_name)
return NULL;
84 if (!obj)
return NULL;
87 return (obj->create (book));
98 for (l = object_modules; l; l = l->next)
100 QofObject *obj =
static_cast<QofObject*
>(l->data);
102 obj->book_begin (book);
106 book_list = g_list_prepend (book_list, book);
110 void qof_object_book_end (QofBook *book)
116 for (l = object_modules; l; l = l->next)
118 QofObject *obj =
static_cast<QofObject*
>(l->data);
120 obj->book_end (book);
124 book_list = g_list_remove (book_list, book);
129 qof_object_is_dirty (
const QofBook *book)
133 if (!book)
return FALSE;
134 for (l = object_modules; l; l = l->next)
136 QofObject *obj =
static_cast<QofObject*
>(l->data);
141 if (obj->is_dirty (col))
return TRUE;
148 qof_object_mark_clean (QofBook *book)
153 for (l = object_modules; l; l = l->next)
155 QofObject *obj =
static_cast<QofObject*
>(l->data);
160 (obj->mark_clean) (col);
171 for (l = object_modules; l; l = l->next)
173 QofObject *obj =
static_cast<QofObject*
>(l->data);
174 (cb) (obj, user_data);
181 const QofObject *obj;
184 if ((obj->create == NULL) || (obj->foreach == NULL))
188 PINFO (
" Object type %s is not fully QOF compliant", obj->e_type);
201 const QofObject *obj;
203 if (!book || !type_name)
207 PINFO (
"type=%s", type_name);
212 PERR (
"No object of type %s", type_name);
222 obj->foreach (col, cb, user_data);
230 GList **list =
static_cast<GList**
>(list_p);
231 *list = g_list_prepend(*list, qof_p);
244 for (iter = list; iter; iter = iter->next)
246 cb(static_cast<QofInstance*>(iter->data), user_data);
262 const QofObject *b_obj;
264 if (!type_name || !obj)
return NULL;
267 if (!b_obj)
return NULL;
269 if (b_obj->printable)
270 return (b_obj->printable (obj));
277 const QofObject *obj;
279 if (!type_name)
return NULL;
282 if (!obj)
return NULL;
284 return (obj->type_label);
287 static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
289 g_hash_table_destroy (static_cast<GHashTable*>(value));
295 void qof_object_initialize (
void)
297 if (object_is_initialized)
return;
298 object_is_initialized = TRUE;
301 void qof_object_shutdown (
void)
303 g_return_if_fail (object_is_initialized == TRUE);
305 g_list_free (object_modules);
306 object_modules = NULL;
307 g_list_free (book_list);
309 object_is_initialized = FALSE;
319 g_return_val_if_fail (object_is_initialized, FALSE);
321 if (!
object)
return FALSE;
324 if (g_list_index (object_modules, (gpointer)
object) == -1)
325 object_modules = g_list_prepend (object_modules, (gpointer)
object);
330 if (object->book_begin && book_list)
333 for (node = book_list; node; node = node->next)
334 object->book_begin (static_cast<QofBook*>(node->data));
343 const QofObject *obj;
345 g_return_val_if_fail (object_is_initialized, NULL);
347 if (!name)
return NULL;
349 for (iter = object_modules; iter; iter = iter->next)
351 obj =
static_cast<QofObject*
>(iter->data);
352 if (!g_strcmp0 (obj->e_type, name))
const char * qof_object_get_type_label(QofIdTypeConst type_name)
Get the printable label for a type.
#define PINFO(format, args...)
Print an informational note.
void qof_object_book_begin(QofBook *book)
To be called from within the book.
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
gboolean qof_object_compliance(QofIdTypeConst type_name, gboolean warn)
check an object can be created and supports iteration
void(* QofInstanceForeachCB)(QofInstance *, gpointer user_data)
Callback type for qof_collection_foreach.
#define QOF_OBJECT_VERSION
Defines the version of the core object object registration interface.
#define PERR(format, args...)
Log a serious error.
#define ENTER(format, args...)
Print a function entry debugging message.
the Core Object Registration/Lookup Private Interface
void qof_object_foreach_type(QofForeachTypeCB cb, gpointer user_data)
Invoke the callback 'cb' on every object class definition.
void qof_object_foreach_sorted(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke callback 'cb' on each instance in guid orted order.
const QofObject * qof_object_lookup(QofIdTypeConst name)
Lookup an object definition.
void qof_object_foreach(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke the callback 'cb' on every instance ov a particular object type.
gpointer qof_object_new_instance(QofIdTypeConst type_name, QofBook *book)
Create an instance of the indicated type, returning a pointer to that instance.
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.
const char * qof_object_printable(QofIdTypeConst type_name, gpointer obj)
#define LEAVE(format, args...)
Print a function exit debugging message.
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.