32 static QofLogModule log_module = QOF_MOD_OBJECT;
34 static gboolean object_is_initialized = FALSE;
35 static GList *object_modules =
nullptr;
36 static GList *book_list =
nullptr;
46 GList* get_object_modules(
void );
47 GList* get_book_list(
void );
51 get_object_modules(
void )
53 return object_modules;
69 if (!type_name)
return nullptr;
72 if (!obj)
return nullptr;
75 return (obj->create (book));
86 for (l = object_modules; l; l = l->next)
88 QofObject *obj =
static_cast<QofObject*
>(l->data);
90 obj->book_begin (book);
94 book_list = g_list_prepend (book_list, book);
98 void qof_object_book_end (QofBook *book)
104 for (l = object_modules; l; l = l->next)
106 QofObject *obj =
static_cast<QofObject*
>(l->data);
108 obj->book_end (book);
112 book_list = g_list_remove (book_list, book);
117 qof_object_is_dirty (
const QofBook *book)
121 if (!book)
return FALSE;
122 for (l = object_modules; l; l = l->next)
124 QofObject *obj =
static_cast<QofObject*
>(l->data);
129 if (obj->is_dirty (col))
return TRUE;
136 qof_object_mark_clean (QofBook *book)
141 for (l = object_modules; l; l = l->next)
143 QofObject *obj =
static_cast<QofObject*
>(l->data);
148 (obj->mark_clean) (col);
159 for (l = object_modules; l; l = l->next)
161 QofObject *obj =
static_cast<QofObject*
>(l->data);
162 (cb) (obj, user_data);
169 const QofObject *obj;
172 if ((obj->create ==
nullptr) || (obj->foreach ==
nullptr))
176 PINFO (
" Object type %s is not fully QOF compliant", obj->e_type);
189 const QofObject *obj;
191 if (!book || !type_name)
195 PINFO (
"type=%s", type_name);
200 PERR (
"No object of type %s", type_name);
210 obj->foreach (col, cb, user_data);
218 GList **list =
static_cast<GList**
>(list_p);
219 *list = g_list_prepend(*list, qof_p);
225 GList *list =
nullptr;
232 for (iter = list; iter; iter = iter->next)
234 cb(static_cast<QofInstance*>(iter->data), user_data);
250 const QofObject *b_obj;
252 if (!type_name || !obj)
return nullptr;
255 if (!b_obj)
return nullptr;
257 if (b_obj->printable)
258 return (b_obj->printable (obj));
265 const QofObject *obj;
267 if (!type_name)
return nullptr;
270 if (!obj)
return nullptr;
272 return (obj->type_label);
277 void qof_object_initialize (
void)
279 if (object_is_initialized)
return;
280 object_is_initialized = TRUE;
283 void qof_object_shutdown (
void)
285 g_return_if_fail (object_is_initialized == TRUE);
287 g_list_free (object_modules);
288 object_modules =
nullptr;
289 g_list_free (book_list);
291 object_is_initialized = FALSE;
301 g_return_val_if_fail (object_is_initialized, FALSE);
303 if (!
object)
return FALSE;
306 if (g_list_index (object_modules, (gpointer)
object) == -1)
307 object_modules = g_list_prepend (object_modules, (gpointer)
object);
312 if (object->book_begin && book_list)
315 for (node = book_list; node; node = node->next)
316 object->book_begin (static_cast<QofBook*>(node->data));
325 const QofObject *obj;
327 g_return_val_if_fail (object_is_initialized,
nullptr);
329 if (!name)
return nullptr;
331 for (iter = object_modules; iter; iter = iter->next)
333 obj =
static_cast<QofObject*
>(iter->data);
334 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.