41 #include "qofbook-p.h" 43 #include "kvp-frame.hpp" 44 #include "qofinstance-p.h" 45 #include "qof-backend.hpp" 47 static QofLogModule log_module = QOF_MOD_ENGINE;
107 guint32 version_check;
114 #define GET_PRIVATE(o) \ 115 ((QofInstancePrivate*)g_type_instance_get_private((GTypeInstance*)o, QOF_TYPE_INSTANCE)) 117 G_DEFINE_TYPE_WITH_PRIVATE(
QofInstance, qof_instance, G_TYPE_OBJECT);
118 QOF_GOBJECT_FINALIZE(qof_instance);
119 #undef G_PARAM_READWRITE 120 #define G_PARAM_READWRITE static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE) 122 static void qof_instance_get_property (GObject *
object,
126 static void qof_instance_set_property (GObject *
object,
130 static void qof_instance_dispose(GObject*);
131 static void qof_instance_class_init(QofInstanceClass *klass)
133 GObjectClass *object_class = G_OBJECT_CLASS(klass);
134 object_class->finalize = qof_instance_finalize;
135 object_class->dispose = qof_instance_dispose;
136 object_class->set_property = qof_instance_set_property;
137 object_class->get_property = qof_instance_get_property;
139 klass->get_display_name = NULL;
140 klass->refers_to_object = NULL;
141 klass->get_typed_referring_object_list = NULL;
143 g_object_class_install_property
146 g_param_spec_boxed (
"guid",
148 "The object Globally Unique ID.",
152 g_object_class_install_property
155 g_param_spec_pointer (
"collection",
157 "A collection of like objects of which this " 158 "particular object is amember. E.g.. A " 159 "collection of accounts, or a collection of " 163 g_object_class_install_property
166 g_param_spec_object (
"book",
168 "The book that contains this object.",
172 g_object_class_install_property
175 g_param_spec_pointer (
"last-update",
176 "Object Last Update",
177 "A pointer to the last time this object was " 178 "updated. This value is present for use by " 179 "backends and shouldnot be written by other " 183 g_object_class_install_property
186 g_param_spec_int (
"editlevel",
188 "The object edit level.",
192 g_object_class_install_property
195 g_param_spec_boolean (
"destroying",
197 "This flag is set to TRUE if the object is " 198 "about to be destroyed.",
202 g_object_class_install_property
205 g_param_spec_boolean (
"dirty",
207 "This flag is set to TRUE if the object has " 212 g_object_class_install_property
215 g_param_spec_boolean (
"infant",
217 "This flag is set to TRUE if the object has " 218 "never been added to a book. This implies " 219 "that its destruction does not affect the " 220 "state of the book, and therefore the saved " 221 "state of the data file.",
225 g_object_class_install_property
228 g_param_spec_int (
"version",
230 "The version number of the current instance state.",
236 g_object_class_install_property
239 g_param_spec_uint (
"version-check",
241 "The version check number of the current instance state.",
247 g_object_class_install_property
250 g_param_spec_uint (
"idata",
252 "Per instance backend private data.",
262 priv = GET_PRIVATE(inst);
264 inst->kvp_data =
new KvpFrame;
265 priv->last_update = 0;
267 priv->do_free = FALSE;
279 g_return_if_fail(QOF_IS_INSTANCE(inst));
280 priv = GET_PRIVATE(inst);
281 g_return_if_fail(!priv->book);
285 g_return_if_fail(col != NULL);
291 if (g_strcmp0(col_type, type))
293 PERR (
"attempt to insert \"%s\" into \"%s\"", type, col_type);
296 priv = GET_PRIVATE(inst);
306 PWARN(
"duplicate id created, trying again");
316 qof_instance_dispose (GObject *instp)
321 priv = GET_PRIVATE(instp);
323 qof_collection_remove_entity(inst);
325 CACHE_REMOVE(inst->
e_type);
328 G_OBJECT_CLASS(qof_instance_parent_class)->dispose(instp);
332 qof_instance_finalize_real (GObject *instp)
337 delete inst->kvp_data;
338 inst->kvp_data =
nullptr;
340 priv = GET_PRIVATE(inst);
342 priv->do_free = FALSE;
353 qof_instance_get_property (GObject *
object,
361 g_return_if_fail(QOF_IS_INSTANCE(
object));
363 inst = QOF_INSTANCE(
object);
364 priv = GET_PRIVATE(inst);
369 g_value_set_boxed(value, &priv->
guid);
371 case PROP_COLLECTION:
375 g_value_take_object(value, priv->book);
377 case PROP_LAST_UPDATE:
378 g_value_set_pointer(value, &priv->last_update);
381 g_value_set_int(value, priv->editlevel);
383 case PROP_DESTROYING:
384 g_value_set_boolean(value, priv->do_free);
387 g_value_set_boolean(value, qof_instance_get_dirty(inst));
390 g_value_set_boolean(value, priv->infant);
393 g_value_set_int(value, priv->version);
395 case PROP_VERSION_CHECK:
396 g_value_set_uint(value, priv->version_check);
399 g_value_set_uint(value, priv->idata);
402 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
408 qof_instance_set_property (GObject *
object,
416 g_return_if_fail(QOF_IS_INSTANCE(
object));
418 inst = QOF_INSTANCE(
object);
424 static_cast<GncGUID*>(g_value_get_boxed(value)));
426 case PROP_COLLECTION:
427 qof_instance_set_collection(inst, static_cast<QofCollection*>(g_value_get_pointer(value)));
431 static_cast<QofBook*>(g_value_get_object(value)));
433 case PROP_LAST_UPDATE:
434 t = *(
static_cast<Time64*
>(g_value_get_pointer(value)));
435 qof_instance_set_last_update(inst, t.t);
437 case PROP_DESTROYING:
438 qof_instance_set_destroying(inst, g_value_get_boolean(value));
441 qof_instance_set_dirty(inst);
444 qof_instance_set_version(inst, g_value_get_int(value));
446 case PROP_VERSION_CHECK:
447 qof_instance_set_version_check(inst, g_value_get_uint(value));
450 qof_instance_set_idata(inst, g_value_get_uint(value));
453 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
463 if (!inst)
return NULL;
464 g_return_val_if_fail(QOF_IS_INSTANCE(inst),
guid_null());
465 priv = GET_PRIVATE(inst);
466 return &(priv->
guid);
482 g_return_if_fail(QOF_IS_INSTANCE(ptr));
484 inst = QOF_INSTANCE(ptr);
485 priv = GET_PRIVATE(inst);
490 qof_collection_remove_entity(inst);
496 qof_instance_copy_guid (gpointer to, gconstpointer from)
498 g_return_if_fail(QOF_IS_INSTANCE(to));
499 g_return_if_fail(QOF_IS_INSTANCE(from));
501 GET_PRIVATE(to)->guid = GET_PRIVATE(from)->guid;
509 g_return_val_if_fail(QOF_IS_INSTANCE(ptr1), -1);
510 g_return_val_if_fail(QOF_IS_INSTANCE(ptr2), 1);
512 priv1 = GET_PRIVATE(ptr1);
513 priv2 = GET_PRIVATE(ptr2);
515 return guid_compare(&priv1->
guid, &priv2->
guid);
522 g_return_val_if_fail(QOF_IS_INSTANCE(ptr), NULL);
523 return GET_PRIVATE(ptr)->collection;
527 qof_instance_set_collection (gconstpointer ptr, QofCollection *col)
529 g_return_if_fail(QOF_IS_INSTANCE(ptr));
530 GET_PRIVATE(ptr)->collection = col;
536 if (!inst)
return NULL;
537 g_return_val_if_fail(QOF_IS_INSTANCE(inst), NULL);
538 return GET_PRIVATE(inst)->book;
544 g_return_if_fail(QOF_IS_INSTANCE(inst));
545 GET_PRIVATE(inst)->book = book;
551 g_return_if_fail(QOF_IS_INSTANCE(ptr1));
552 g_return_if_fail(QOF_IS_INSTANCE(ptr2));
554 GET_PRIVATE(ptr1)->book = GET_PRIVATE(ptr2)->book;
562 g_return_val_if_fail(QOF_IS_INSTANCE(ptr1), FALSE);
563 g_return_val_if_fail(QOF_IS_INSTANCE(ptr2), FALSE);
565 priv1 = GET_PRIVATE(ptr1);
566 priv2 = GET_PRIVATE(ptr2);
568 return (priv1->book == priv2->book);
575 if (!inst)
return NULL;
576 return inst->kvp_data;
580 qof_instance_set_slots (
QofInstance *inst, KvpFrame *frm)
586 priv = GET_PRIVATE(inst);
587 if (inst->kvp_data && (inst->kvp_data != frm))
589 delete inst->kvp_data;
593 inst->kvp_data = frm;
600 GET_PRIVATE(inst)->last_update = t;
604 qof_instance_get_editlevel (gconstpointer ptr)
606 g_return_val_if_fail(QOF_IS_INSTANCE(ptr), 0);
607 return GET_PRIVATE(ptr)->editlevel;
610 void qof_instance_increase_editlevel (gpointer ptr)
612 g_return_if_fail(QOF_IS_INSTANCE(ptr));
613 GET_PRIVATE(ptr)->editlevel++;
616 void qof_instance_decrease_editlevel (gpointer ptr)
618 g_return_if_fail(QOF_IS_INSTANCE(ptr));
619 GET_PRIVATE(ptr)->editlevel--;
622 void qof_instance_reset_editlevel (gpointer ptr)
624 g_return_if_fail(QOF_IS_INSTANCE(ptr));
625 GET_PRIVATE(ptr)->editlevel = 0;
633 if (!left && !right)
return 0;
634 if (!left)
return -1;
635 if (!right)
return +1;
637 lpriv = GET_PRIVATE(left);
638 rpriv = GET_PRIVATE(right);
639 return lpriv->last_update < rpriv->last_update ? -1 :
640 lpriv->last_update > rpriv->last_update ? 1 : 0;
646 g_return_val_if_fail(QOF_IS_INSTANCE(ptr), FALSE);
647 return GET_PRIVATE(ptr)->do_free;
651 qof_instance_set_destroying (gpointer ptr, gboolean value)
653 g_return_if_fail(QOF_IS_INSTANCE(ptr));
654 GET_PRIVATE(ptr)->do_free = value;
660 g_return_val_if_fail(QOF_IS_INSTANCE(ptr), FALSE);
661 return GET_PRIVATE(ptr)->dirty;
665 qof_instance_set_dirty_flag (gconstpointer inst, gboolean flag)
667 g_return_if_fail(QOF_IS_INSTANCE(inst));
668 GET_PRIVATE(inst)->dirty = flag;
675 GET_PRIVATE(inst)->dirty = FALSE;
679 qof_instance_print_dirty (
const QofInstance *inst, gpointer dummy)
683 priv = GET_PRIVATE(inst);
688 printf(
"%s instance %s is dirty.\n", inst->
e_type, guidstr);
703 priv = GET_PRIVATE(inst);
713 priv = GET_PRIVATE(inst);
720 g_return_val_if_fail(QOF_IS_INSTANCE(inst), FALSE);
721 return GET_PRIVATE(inst)->infant;
725 qof_instance_get_version (gconstpointer inst)
727 g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
728 return GET_PRIVATE(inst)->version;
732 qof_instance_set_version (gpointer inst, gint32 vers)
734 g_return_if_fail(QOF_IS_INSTANCE(inst));
735 GET_PRIVATE(inst)->version = vers;
739 qof_instance_copy_version (gpointer to, gconstpointer from)
741 g_return_if_fail(QOF_IS_INSTANCE(to));
742 g_return_if_fail(QOF_IS_INSTANCE(from));
743 GET_PRIVATE(to)->version = GET_PRIVATE(from)->version;
747 qof_instance_get_version_check (gconstpointer inst)
749 g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
750 return GET_PRIVATE(inst)->version_check;
754 qof_instance_set_version_check (gpointer inst, guint32 value)
756 g_return_if_fail(QOF_IS_INSTANCE(inst));
757 GET_PRIVATE(inst)->version_check = value;
761 qof_instance_copy_version_check (gpointer to, gconstpointer from)
763 g_return_if_fail(QOF_IS_INSTANCE(to));
764 g_return_if_fail(QOF_IS_INSTANCE(from));
765 GET_PRIVATE(to)->version_check = GET_PRIVATE(from)->version_check;
774 g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
775 return GET_PRIVATE(inst)->idata;
778 void qof_instance_set_idata(gpointer inst, guint32 idata)
784 g_return_if_fail(QOF_IS_INSTANCE(inst));
785 GET_PRIVATE(inst)->idata = idata;
793 g_return_val_if_fail( inst != NULL, NULL );
795 if ( QOF_INSTANCE_GET_CLASS(inst)->get_display_name != NULL )
797 return QOF_INSTANCE_GET_CLASS(inst)->get_display_name(inst);
802 return g_strdup_printf(
"Object %s %p",
815 get_referring_object_instance_helper(
QofInstance* inst, gpointer user_data)
826 get_referring_object_helper(QofCollection* coll, gpointer user_data)
833 if (first_instance != NULL)
836 data->list = g_list_concat(data->list, new_list);
845 g_return_val_if_fail( inst != NULL, NULL );
852 get_referring_object_helper,
858 get_typed_referring_object_instance_helper(
QofInstance* inst, gpointer user_data)
864 data->list = g_list_prepend(data->list, inst);
873 g_return_val_if_fail( coll != NULL, NULL );
874 g_return_val_if_fail( ref != NULL, NULL );
886 g_return_val_if_fail( inst != NULL, NULL );
887 g_return_val_if_fail( ref != NULL, NULL );
889 if ( QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list != NULL )
891 return QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list(inst, ref);
907 g_return_val_if_fail( inst != NULL, FALSE );
908 g_return_val_if_fail( ref != NULL, FALSE );
910 if ( QOF_INSTANCE_GET_CLASS(inst)->refers_to_object != NULL )
912 return QOF_INSTANCE_GET_CLASS(inst)->refers_to_object(inst, ref);
926 g_return_if_fail (QOF_IS_INSTANCE (inst));
928 va_start (ap, first_prop);
929 g_object_get_valist (G_OBJECT (inst), first_prop, ap);
937 g_return_if_fail (QOF_IS_INSTANCE (inst));
939 qof_instance_set_dirty (inst);
940 va_start (ap, first_prop);
941 g_object_set_valist (G_OBJECT (inst), first_prop, ap);
955 if (!inst)
return FALSE;
957 priv = GET_PRIVATE(inst);
959 if (1 < priv->editlevel)
return FALSE;
960 if (0 >= priv->editlevel)
976 if (!inst)
return FALSE;
978 priv = GET_PRIVATE(inst);
980 if (0 < priv->editlevel)
return FALSE;
982 if (0 > priv->editlevel)
984 PERR (
"unbalanced call - resetting (was %d)", priv->editlevel);
998 priv = GET_PRIVATE(inst);
1001 !(priv->infant && priv->do_free)) {
1015 errcode = be->get_error();
1017 while (errcode != ERR_BACKEND_NO_ERR);
1020 errcode = be->get_error();
1021 if (errcode != ERR_BACKEND_NO_ERR)
1024 priv->do_free = FALSE;
1027 be->set_error (errcode);
1029 on_error(inst, errcode);
1033 priv->infant = FALSE;
1051 return (inst->kvp_data != NULL && !inst->kvp_data->empty());
1054 void qof_instance_set_path_kvp (
QofInstance * inst, GValue
const * value, std::vector<std::string>
const & path)
1062 std::vector<std::string> path;
1064 va_start (args, count);
1065 for (
unsigned i{0}; i < count; ++i)
1066 path.push_back (va_arg (args,
char const *));
1071 void qof_instance_get_path_kvp (
QofInstance * inst, GValue * value, std::vector<std::string>
const & path)
1074 if (G_IS_VALUE (temp))
1076 if (G_IS_VALUE (value))
1077 g_value_unset (value);
1078 g_value_init (value, G_VALUE_TYPE (temp));
1079 g_value_copy (temp, value);
1087 std::vector<std::string> path;
1089 va_start (args, count);
1090 for (
unsigned i{0}; i < count; ++i)
1091 path.push_back (va_arg (args,
char const *));
1094 if (G_IS_VALUE (temp))
1096 if (G_IS_VALUE (value))
1097 g_value_unset (value);
1098 g_value_init (value, G_VALUE_TYPE (temp));
1099 g_value_copy (temp, value);
1107 delete to->kvp_data;
1108 to->kvp_data =
new KvpFrame(*from->kvp_data);
1114 std::swap(a->kvp_data, b->kvp_data);
1120 return compare(a->kvp_data, b->kvp_data);
1124 qof_instance_kvp_as_string (
const QofInstance *inst)
1127 return g_strdup(inst->kvp_data->to_string().c_str());
1131 qof_instance_kvp_add_guid (
const QofInstance *inst,
const char* path,
1132 time64 time,
const char *key,
1135 g_return_if_fail (inst->kvp_data != NULL);
1137 auto container =
new KvpFrame;
1139 container->set({key},
new KvpValue(const_cast<GncGUID*>(guid)));
1140 container->set({
"date"},
new KvpValue(t));
1141 delete inst->kvp_data->set_path({path},
new KvpValue(container));
1144 inline static gboolean
1145 kvp_match_guid (KvpValue *v, std::vector<std::string>
const & path,
const GncGUID *guid)
1147 if (v->get_type() != KvpValue::Type::FRAME)
1149 auto frame = v->get<KvpFrame*>();
1150 auto val = frame->get_slot(path);
1151 if (val ==
nullptr || val->get_type() != KvpValue::Type::GUID)
1153 auto this_guid = val->get<
GncGUID*>();
1159 qof_instance_kvp_has_guid (
const QofInstance *inst,
const char *path,
1160 const char* key,
const GncGUID *guid)
1162 g_return_val_if_fail (inst->kvp_data != NULL, FALSE);
1163 g_return_val_if_fail (guid != NULL, FALSE);
1165 auto v = inst->kvp_data->get_slot({path});
1166 if (v ==
nullptr)
return FALSE;
1168 switch (v->get_type())
1170 case KvpValue::Type::FRAME:
1171 return kvp_match_guid (v, {key}, guid);
1173 case KvpValue::Type::GLIST:
1175 auto list = v->get<GList*>();
1176 for (
auto node = list; node != NULL; node = node->next)
1178 auto val =
static_cast<KvpValue*
>(node->data);
1179 if (kvp_match_guid (val, {key}, guid))
1187 PWARN (
"Instance KVP on path %s contains the wrong type.", path);
1194 qof_instance_kvp_remove_guid (
const QofInstance *inst,
const char *path,
1195 const char *key,
const GncGUID *guid)
1197 g_return_if_fail (inst->kvp_data != NULL);
1198 g_return_if_fail (guid != NULL);
1200 auto v = inst->kvp_data->get_slot({path});
1201 if (v == NULL)
return;
1203 switch (v->get_type())
1205 case KvpValue::Type::FRAME:
1206 if (kvp_match_guid (v, {key}, guid))
1208 delete inst->kvp_data->set_path({path},
nullptr);
1212 case KvpValue::Type::GLIST:
1214 auto list = v->get<GList*>();
1215 for (
auto node = list; node !=
nullptr; node = node->next)
1217 auto val =
static_cast<KvpValue*
>(node->data);
1218 if (kvp_match_guid (val, {key}, guid))
1220 list = g_list_delete_link (list, node);
1229 PWARN (
"Instance KVP on path %s contains the wrong type.", path);
1236 qof_instance_kvp_merge_guids (
const QofInstance *target,
1239 g_return_if_fail (target != NULL);
1240 g_return_if_fail (donor != NULL);
1242 if (! qof_instance_has_slot (donor, path))
return;
1243 auto v = donor->kvp_data->get_slot({path});
1244 if (v == NULL)
return;
1246 auto target_val = target->kvp_data->get_slot({path});
1247 switch (v->get_type())
1249 case KvpValue::Type::FRAME:
1253 target->kvp_data->set_path({path}, v);
1254 donor->kvp_data->set({path},
nullptr);
1256 case KvpValue::Type::GLIST:
1259 auto list = target_val->get<GList*>();
1260 list = g_list_concat(list, v->get<GList*>());
1261 target_val->set(list);
1264 target->kvp_data->set({path}, v);
1265 donor->kvp_data->set({path},
nullptr);
1268 PWARN (
"Instance KVP on path %s contains the wrong type.", path);
1273 bool qof_instance_has_path_slot (
QofInstance const * inst, std::vector<std::string>
const & path)
1275 return inst->kvp_data->get_slot (path) !=
nullptr;
1279 qof_instance_has_slot (
const QofInstance *inst,
const char *path)
1281 return inst->kvp_data->get_slot({path}) != NULL;
1284 void qof_instance_slot_path_delete (
QofInstance const * inst, std::vector<std::string>
const & path)
1286 delete inst->kvp_data->set (path,
nullptr);
1290 qof_instance_slot_delete (
QofInstance const *inst,
char const * path)
1292 delete inst->kvp_data->set ({path},
nullptr);
1295 void qof_instance_slot_path_delete_if_empty (
QofInstance const * inst, std::vector<std::string>
const & path)
1297 auto slot = inst->kvp_data->get_slot (path);
1300 auto frame = slot->get <KvpFrame*> ();
1301 if (frame && frame->empty())
1302 delete inst->kvp_data->set (path,
nullptr);
1307 qof_instance_slot_delete_if_empty (
QofInstance const *inst,
char const * path)
1309 auto slot = inst->kvp_data->get_slot ({path});
1312 auto frame = slot->get <KvpFrame*> ();
1313 if (frame && frame->empty ())
1314 delete inst->kvp_data->set ({path},
nullptr);
1318 std::vector <std::pair <std::string, KvpValue*>>
1319 qof_instance_get_slots_prefix (
QofInstance const * inst, std::string
const & prefix)
1321 std::vector <std::pair <std::string, KvpValue*>> ret;
1322 inst->kvp_data->for_each_slot_temp ([&prefix, &ret] (std::string
const & key, KvpValue * val) {
1323 if (key.find (prefix) == 0)
1324 ret.emplace_back (key, val);
1332 void (*proc)(
const char*,
const GValue*,
void*);
1338 wrap_gvalue_function (
const char* key, KvpValue *val, wrap_param & param)
1341 if (val->get_type() != KvpValue::Type::FRAME)
1345 gv = g_slice_new0 (GValue);
1346 g_value_init (gv, G_TYPE_STRING);
1347 g_value_set_string (gv,
nullptr);
1349 param.proc(key, gv, param.user_data);
1350 g_slice_free (GValue, gv);
1354 qof_instance_foreach_slot (
const QofInstance *inst,
const char* head,
const char* category,
1355 void (*proc)(
const char*,
const GValue*,
void*),
void* data)
1357 std::vector<std::string> path {head};
1359 path.emplace_back (category);
1361 auto slot = inst->kvp_data->get_slot(path);
1362 if (slot ==
nullptr || slot->get_type() != KvpValue::Type::FRAME)
1364 auto frame = slot->get<KvpFrame*>();
1365 wrap_param new_data {proc, data};
1366 frame->for_each_slot_temp(&wrap_gvalue_function, new_data);
int qof_instance_version_cmp(const QofInstance *left, const QofInstance *right)
Compare two instances, based on their last update times.
void guid_replace(GncGUID *guid)
Generate a new guid.
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
void qof_instance_set_kvp(QofInstance *, GValue const *value, unsigned count,...)
Sets a KVP slot to a value from a GValue.
void qof_instance_set_guid(gpointer ptr, const GncGUID *guid)
Set the GncGUID of this instance.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
GncGUID guid
GncGUID for the entity.
GList * qof_instance_get_referring_object_list_from_collection(const QofCollection *coll, const QofInstance *ref)
Returns a list of objects from the collection which refer to the specific object. ...
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.
void qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
KvpValue * kvp_value_from_gvalue(const GValue *gval)
Convert a gvalue into a kvpvalue.
QofCollection * qof_instance_get_collection(gconstpointer ptr)
Return the collection this instance belongs to.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers
#define PERR(format, args...)
Log a serious error.
void qof_collection_foreach(const QofCollection *col, QofInstanceForeachCB cb_func, gpointer user_data)
Call the callback for each entity in the collection.
void qof_instance_get_kvp(QofInstance *, GValue *value, unsigned count,...)
Retrieves the contents of a KVP slot into a provided GValue.
#define PWARN(format, args...)
Log a warning.
const gchar * QofIdType
QofIdType declaration.
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.
void gnc_gvalue_free(GValue *value)
Convenience function to release the value in a GValue acquired by kvp_frame_get_gvalue and to free th...
gboolean qof_begin_edit(QofInstance *inst)
begin_edit
guint32 qof_instance_get_idata(gconstpointer inst)
get the instance tag number used for kvp management in sql backends.
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
gboolean qof_instance_get_dirty_flag(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object has been modified.
void qof_instance_copy_book(gpointer ptr1, gconstpointer ptr2)
Copy the book from one QofInstances to another.
GList * qof_instance_get_typed_referring_object_list(const QofInstance *inst, const QofInstance *ref)
Returns a list of my type of object which refers to an object.
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
void qof_collection_insert_entity(QofCollection *, QofInstance *)
Take entity, remove it from whatever collection its currently in, and place it in a new collection...
const GncGUID * qof_entity_get_guid(gconstpointer ent)
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
See if two QofInstances share the same book.
void qof_book_mark_session_dirty(QofBook *book)
The qof_book_mark_dirty() routine marks the book as having been modified.
GList * qof_instance_get_referring_object_list(const QofInstance *inst)
Returns a list of objects which refer to a specific object.
QofIdType qof_collection_get_type(const QofCollection *col)
return the type that the collection stores
QofIdType e_type
Entity type.
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
void qof_instance_set_book(gconstpointer inst, QofBook *book)
Set the book pointer.
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
gboolean qof_instance_refers_to_object(const QofInstance *inst, const QofInstance *ref)
Does this object refer to a specific object.
gboolean qof_instance_has_kvp(QofInstance *inst)
Report whether a QofInstance has anything stored in KVP.
QofBackend * qof_book_get_backend(const QofBook *book)
Retrieve the backend used by this book.
GValue * gvalue_from_kvp_value(const KvpValue *kval)
Convert a kvp_value into a GValue.
The type used to store guids in C.
QofCollection * collection
Entity collection.
gchar * qof_instance_get_display_name(const QofInstance *inst)
Returns a displayable name for this object.