* Merge QofEntity into QofInstance

- QofEntity -> QofInstance
  - qof_entity -> qof_instance
  - QOF_ENTITY -> QOF_INSTANCE
* remove references to instance.entity
* keep qof_entity_init() and qof_entity_release() for now


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/gobject-engine-dev-warlord@15773 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2007-04-01 22:18:50 +00:00
parent 4e43ae10f3
commit 12461c5b30
130 changed files with 845 additions and 861 deletions

View File

@ -80,7 +80,7 @@ in the QSF QofBackend to contain the reference data so that when the book is
written out, the reference can be included. When the file is imported back in, a
little extra code then rebuilds those references during the merge.
Copying entites from an existing QofBook using the qof_entity_copy routines will
Copying entites from an existing QofBook using the qof_instance_copy routines will
automatically create the reference table. If your QOF objects use references to other
entities, books that are created manually also need to create a reference table.

View File

@ -295,12 +295,12 @@ qsf_destroy_backend (QofBackend *be)
}
static void
ent_ref_cb (QofEntity* ent, gpointer user_data)
ent_ref_cb (QofInstance* ent, gpointer user_data)
{
qsf_param *params;
QofEntityReference *ref;
void (*reference_setter) (QofEntity*, QofEntity*);
QofEntity *reference;
QofInstanceReference *ref;
void (*reference_setter) (QofInstance*, QofInstance*);
QofInstance *reference;
QofCollection *coll;
QofIdType type;
@ -308,12 +308,12 @@ ent_ref_cb (QofEntity* ent, gpointer user_data)
g_return_if_fail(params);
while(params->referenceList)
{
ref = (QofEntityReference*)params->referenceList->data;
ref = (QofInstanceReference*)params->referenceList->data;
if(qof_object_is_choice(ent->e_type)) { type = ref->choice_type; }
else { type = ref->type; }
coll = qof_book_get_collection(params->book, type);
reference = qof_collection_lookup_entity(coll, ref->ref_guid);
reference_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
reference_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
if(reference_setter != NULL)
{
qof_begin_edit((QofInstance*)ent);
@ -337,7 +337,7 @@ insert_ref_cb(QofObject *obj, gpointer user_data)
}
/*================================================
Load QofEntity into QofBook from XML in memory
Load QofInstance into QofBook from XML in memory
==================================================*/
static gboolean
@ -370,7 +370,7 @@ qsfdoc_to_qofbook(xmlDocPtr doc, qsf_param *params)
if(!qof_class_is_registered(params->object_set->object_type)) { continue; }
inst = (QofInstance*)qof_object_new_instance(params->object_set->object_type, book);
g_return_val_if_fail(inst != NULL, FALSE);
params->qsf_ent = &inst->entity;
params->qsf_ent = inst;
qof_begin_edit(inst);
g_hash_table_foreach(params->qsf_parameter_hash, qsf_object_commitCB, params);
qof_commit_edit(inst);
@ -644,7 +644,7 @@ qsf_from_kvp_helper(const gchar *path, KvpValue *content, gpointer data)
}
static void
qsf_from_coll_cb (QofEntity *ent, gpointer user_data)
qsf_from_coll_cb (QofInstance *ent, gpointer user_data)
{
qsf_param *params;
QofParam *qof_param;
@ -654,7 +654,7 @@ qsf_from_coll_cb (QofEntity *ent, gpointer user_data)
params = (qsf_param*)user_data;
if(!ent || !params) { return; }
qof_param = params->qof_param;
guid_to_string_buff(qof_entity_get_guid(ent), qsf_guid);
guid_to_string_buff(qof_instance_get_guid(ent), qsf_guid);
node = xmlAddChild(params->output_node, xmlNewNode(params->qsf_ns,
BAD_CAST qof_param->param_type));
xmlNodeAddContent(node, BAD_CAST qsf_guid);
@ -666,11 +666,11 @@ qsf_from_coll_cb (QofEntity *ent, gpointer user_data)
static gint
qof_reference_list_cb(gconstpointer a, gconstpointer b)
{
const QofEntityReference *aa;
const QofEntityReference *bb;
const QofInstanceReference *aa;
const QofInstanceReference *bb;
aa = (QofEntityReference*) a;
bb = (QofEntityReference*) b;
aa = (QofInstanceReference*) a;
bb = (QofInstanceReference*) b;
if(aa == NULL) { return 1; }
g_return_val_if_fail((bb != NULL), 1);
g_return_val_if_fail((aa->type != NULL), 1);
@ -683,11 +683,11 @@ qof_reference_list_cb(gconstpointer a, gconstpointer b)
return 1;
}
static QofEntityReference*
qof_reference_lookup(GList *referenceList, QofEntityReference *find)
static QofInstanceReference*
qof_reference_lookup(GList *referenceList, QofInstanceReference *find)
{
GList *single_ref;
QofEntityReference *ent_ref;
QofInstanceReference *ent_ref;
if(referenceList == NULL) { return NULL; }
g_return_val_if_fail(find != NULL, NULL);
@ -695,7 +695,7 @@ qof_reference_lookup(GList *referenceList, QofEntityReference *find)
ent_ref = NULL;
single_ref = g_list_find_custom(referenceList, find, qof_reference_list_cb);
if(single_ref == NULL) { return ent_ref; }
ent_ref = (QofEntityReference*)single_ref->data;
ent_ref = (QofInstanceReference*)single_ref->data;
g_list_free(single_ref);
return ent_ref;
}
@ -703,9 +703,9 @@ qof_reference_lookup(GList *referenceList, QofEntityReference *find)
static void
reference_list_lookup(gpointer data, gpointer user_data)
{
QofEntity *ent;
QofInstance *ent;
QofParam *ref_param;
QofEntityReference *reference, *starter;
QofInstanceReference *reference, *starter;
qsf_param *params;
const GUID *guid;
xmlNodePtr node, object_node;
@ -718,8 +718,8 @@ reference_list_lookup(gpointer data, gpointer user_data)
object_node = params->output_node;
ent = params->qsf_ent;
ns = params->qsf_ns;
starter = g_new(QofEntityReference, 1);
starter->ent_guid = qof_entity_get_guid(ent);
starter = g_new(QofInstanceReference, 1);
starter->ent_guid = qof_instance_get_guid(ent);
starter->type = g_strdup(ent->e_type);
starter->param = ref_param;
starter->ref_guid = NULL;
@ -739,13 +739,13 @@ reference_list_lookup(gpointer data, gpointer user_data)
g_free(ref_name);
}
else {
ent = QOF_ENTITY(ref_param->param_getfcn(ent, ref_param));
ent = QOF_INSTANCE(ref_param->param_getfcn(ent, ref_param));
if(!ent) { return; }
if((0 == safe_strcmp(ref_param->param_type, QOF_TYPE_COLLECT)) ||
(0 == safe_strcmp(ref_param->param_type, QOF_TYPE_CHOICE)))
{ return; }
node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST QOF_TYPE_GUID));
guid = qof_entity_get_guid(ent);
guid = qof_instance_get_guid(ent);
guid_to_string_buff(guid, qsf_guid);
xmlNodeAddContent(node, BAD_CAST qsf_guid);
xmlNewProp(node, BAD_CAST QSF_OBJECT_TYPE, BAD_CAST ref_param->param_name);
@ -753,11 +753,11 @@ reference_list_lookup(gpointer data, gpointer user_data)
}
/*=====================================
Convert QofEntity to QSF XML node
Convert QofInstance to QSF XML node
qof_param holds the parameter sequence.
=======================================*/
static void
qsf_entity_foreach(QofEntity *ent, gpointer data)
qsf_entity_foreach(QofInstance *ent, gpointer data)
{
qsf_param *params;
GSList *param_list, *supported;
@ -766,7 +766,7 @@ qsf_entity_foreach(QofEntity *ent, gpointer data)
xmlNsPtr ns;
gchar *string_buffer;
QofParam *qof_param;
QofEntity *choice_ent;
QofInstance *choice_ent;
KvpFrame *qsf_kvp;
QofCollection *qsf_coll;
gint param_count;
@ -795,7 +795,7 @@ qsf_entity_foreach(QofEntity *ent, gpointer data)
{
if(!own_guid)
{
cm_guid = qof_entity_get_guid(ent);
cm_guid = qof_instance_get_guid(ent);
node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST QOF_TYPE_GUID));
guid_to_string_buff(cm_guid, cm_sa);
string_buffer = g_strdup(cm_sa);
@ -827,13 +827,13 @@ qsf_entity_foreach(QofEntity *ent, gpointer data)
if(0 == safe_strcmp(qof_param->param_type, QOF_TYPE_CHOICE))
{
/** \todo use the reference list here. */
choice_ent = QOF_ENTITY(qof_param->param_getfcn(ent, qof_param));
choice_ent = QOF_INSTANCE(qof_param->param_getfcn(ent, qof_param));
if(!choice_ent) {
param_list = g_slist_next(param_list);
continue;
}
node = xmlAddChild(object_node, xmlNewNode(ns, BAD_CAST qof_param->param_type));
cm_guid = qof_entity_get_guid(choice_ent);
cm_guid = qof_instance_get_guid(choice_ent);
guid_to_string_buff(cm_guid, cm_sa);
string_buffer = g_strdup(cm_sa);
xmlNodeAddContent(node, BAD_CAST string_buffer);
@ -1047,7 +1047,7 @@ string_to_kvp_value(const gchar *content, KvpValueType type)
}
/* ======================================================
Commit XML data from file to QofEntity in a QofBook
Commit XML data from file to QofInstance in a QofBook
========================================================= */
void
qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
@ -1055,8 +1055,8 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
qsf_param *params;
qsf_objects *object_set;
xmlNodePtr node;
QofEntityReference *reference;
QofEntity *qsf_ent;
QofInstanceReference *reference;
QofInstance *qsf_ent;
QofBook *targetBook;
const char *qof_type, *parameter_name, *timechk;
QofIdType obj_type, reference_type;
@ -1077,14 +1077,14 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
KvpValueType cm_type;
QofSetterFunc cm_setter;
const QofParam *cm_param;
void (*string_setter) (QofEntity*, const gchar*);
void (*date_setter) (QofEntity*, Timespec);
void (*numeric_setter) (QofEntity*, gnc_numeric);
void (*double_setter) (QofEntity*, double);
void (*boolean_setter) (QofEntity*, gboolean);
void (*i32_setter) (QofEntity*, gint32);
void (*i64_setter) (QofEntity*, gint64);
void (*char_setter) (QofEntity*, gchar);
void (*string_setter) (QofInstance*, const gchar*);
void (*date_setter) (QofInstance*, Timespec);
void (*numeric_setter) (QofInstance*, gnc_numeric);
void (*double_setter) (QofInstance*, double);
void (*boolean_setter) (QofInstance*, gboolean);
void (*i32_setter) (QofInstance*, gint32);
void (*i64_setter) (QofInstance*, gint64);
void (*char_setter) (QofInstance*, gchar);
g_return_if_fail(data && value && key);
params = (qsf_param*)data;
@ -1102,11 +1102,11 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
cm_param = qof_class_get_parameter(obj_type, parameter_name);
object_set = params->object_set;
if(safe_strcmp(qof_type, QOF_TYPE_STRING) == 0) {
string_setter = (void(*)(QofEntity*, const gchar*))cm_setter;
string_setter = (void(*)(QofInstance*, const gchar*))cm_setter;
if(string_setter != NULL) { string_setter(qsf_ent, (gchar*)xmlNodeGetContent(node)); }
}
if(safe_strcmp(qof_type, QOF_TYPE_DATE) == 0) {
date_setter = (void(*)(QofEntity*, Timespec))cm_setter;
date_setter = (void(*)(QofInstance*, Timespec))cm_setter;
timechk = NULL;
timechk = strptime((char*)xmlNodeGetContent(node), QSF_XSD_TIME, &qsf_time);
g_return_if_fail(timechk != NULL);
@ -1119,7 +1119,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
}
if((safe_strcmp(qof_type, QOF_TYPE_NUMERIC) == 0) ||
(safe_strcmp(qof_type, QOF_TYPE_DEBCRED) == 0)) {
numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_setter;
numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_setter;
string_to_gnc_numeric((char*)xmlNodeGetContent(node), &cm_numeric);
if(numeric_setter != NULL) { numeric_setter(qsf_ent, cm_numeric); }
}
@ -1135,10 +1135,10 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
reference_type = (char*)xmlGetProp(node, BAD_CAST QSF_OBJECT_TYPE);
if(0 == safe_strcmp(QOF_PARAM_GUID, reference_type))
{
qof_entity_set_guid(qsf_ent, cm_guid);
qof_instance_set_guid(qsf_ent, cm_guid);
}
else {
reference = qof_entity_get_reference_from(qsf_ent, cm_param);
reference = qof_instance_get_reference_from(qsf_ent, cm_param);
if(reference) {
params->referenceList = g_list_append(params->referenceList, reference);
}
@ -1148,7 +1148,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
errno = 0;
cm_i32 = (gint32)strtol ((char*)xmlNodeGetContent(node), &tail, 0);
if(errno == 0) {
i32_setter = (void(*)(QofEntity*, gint32))cm_setter;
i32_setter = (void(*)(QofInstance*, gint32))cm_setter;
if(i32_setter != NULL) { i32_setter(qsf_ent, cm_i32); }
}
else { qof_backend_set_error(params->be, ERR_QSF_OVERFLOW); }
@ -1157,7 +1157,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
errno = 0;
cm_i64 = strtoll((gchar*)xmlNodeGetContent(node), &tail, 0);
if(errno == 0) {
i64_setter = (void(*)(QofEntity*, gint64))cm_setter;
i64_setter = (void(*)(QofInstance*, gint64))cm_setter;
if(i64_setter != NULL) { i64_setter(qsf_ent, cm_i64); }
}
else { qof_backend_set_error(params->be, ERR_QSF_OVERFLOW); }
@ -1166,7 +1166,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
errno = 0;
cm_double = strtod((gchar*)xmlNodeGetContent(node), &tail);
if(errno == 0) {
double_setter = (void(*)(QofEntity*, double))cm_setter;
double_setter = (void(*)(QofInstance*, double))cm_setter;
if(double_setter != NULL) { double_setter(qsf_ent, cm_double); }
}
}
@ -1176,7 +1176,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
cm_boolean = TRUE;
}
else { cm_boolean = FALSE; }
boolean_setter = (void(*)(QofEntity*, gboolean))cm_setter;
boolean_setter = (void(*)(QofInstance*, gboolean))cm_setter;
if(boolean_setter != NULL) { boolean_setter(qsf_ent, cm_boolean); }
}
if(safe_strcmp(qof_type, QOF_TYPE_KVP) == 0) {
@ -1190,7 +1190,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
if(safe_strcmp(qof_type, QOF_TYPE_COLLECT) == 0) {
QofCollection *qsf_coll;
QofIdType type;
QofEntityReference *reference;
QofInstanceReference *reference;
QofParam *copy_param;
/* retrieve the *type* of the collection, ignore any contents. */
qsf_coll = cm_param->param_getfcn(qsf_ent, cm_param);
@ -1202,11 +1202,11 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
PINFO (" string to guid collect failed for %s", xmlNodeGetContent(node));
return;
}
/* create a QofEntityReference with this type and GUID.
/* create a QofInstanceReference with this type and GUID.
there is only one entity each time.
cm_guid contains the GUID of the reference.
type is the type of the reference. */
reference = g_new0(QofEntityReference, 1);
reference = g_new0(QofInstanceReference, 1);
reference->type = g_strdup(qsf_ent->e_type);
reference->ref_guid = cm_guid;
reference->ent_guid = &qsf_ent->guid;
@ -1219,7 +1219,7 @@ qsf_object_commitCB(gpointer key, gpointer value, gpointer data)
if(safe_strcmp(qof_type, QOF_TYPE_CHAR) == 0) {
char_getter = (gchar (*)(xmlNodePtr))xmlNodeGetContent;
cm_char = char_getter(node);
char_setter = (void(*)(QofEntity*, gchar))cm_setter;
char_setter = (void(*)(QofInstance*, gchar))cm_setter;
if(char_setter != NULL) { char_setter(qsf_ent, cm_char); }
}
}

View File

@ -355,7 +355,7 @@ qsf_book_node_handler(xmlNodePtr child, xmlNsPtr ns, qsf_param *params)
DEBUG (" trying to set book GUID");
buffer = g_strdup((gchar*)xmlNodeGetContent(child_node));
g_return_if_fail(TRUE == string_to_guid(buffer, &book_guid));
qof_entity_set_guid(QOF_ENTITY(params->book), &book_guid);
qof_instance_set_guid(QOF_INSTANCE(params->book), &book_guid);
xmlNewChild(params->output_node, params->qsf_ns,
BAD_CAST QSF_BOOK_GUID, BAD_CAST buffer);
g_free(buffer);

View File

@ -344,7 +344,7 @@ typedef struct qsf_metadata
gint count; /**< sequential counter for each object in the book */
GList *qsf_object_list; /**< list of qsf_objects */
GSList *qsf_sequence; /**< Parameter list sorted into QSF order */
GList *referenceList; /**< Table of references, ::QofEntityReference. */
GList *referenceList; /**< Table of references, ::QofInstanceReference. */
GHashTable *qsf_parameter_hash; /**< Hashtable of parameters for each object */
GHashTable *qsf_calculate_hash, *qsf_default_hash, *qsf_define_hash;
GSList *supported_types; /**< The list of QOF types currently supported, in QSF order. */
@ -362,7 +362,7 @@ typedef struct qsf_metadata
QofIdType qof_obj_type; /**< current QofObject type (e_type) for the parameters. */
QofIdType qof_foreach; /**< How to iterate over hierarchical entities. */
gint foreach_limit; /**< How many iterations are found in the QSF */
QofEntity *qsf_ent; /**< Current entity in the book. */
QofInstance *qsf_ent; /**< Current entity in the book. */
QofBackend *be; /**< the current QofBackend for this operation. */
gboolean knowntype; /**< detect references by comparing with known QOF types. */
QofParam *qof_param; /**< used by kvp to handle the frame hash table */

View File

@ -57,7 +57,7 @@ void gnc_engine_resume_events (void)
{
qof_event_resume();
}
void gnc_engine_gen_event (QofEntity *entity, GNCEngineEventType event_type)
void gnc_engine_gen_event (QofInstance *entity, GNCEngineEventType event_type)
{
qof_event_gen(entity, event_type, NULL);
}

View File

@ -104,7 +104,7 @@ gint gnc_engine_register_event_handler (GNCEngineEventHandler handler,
/** \deprecated use qof_event_unregister_handler instead. */
void gnc_engine_unregister_event_handler (gint handler_id);
/** \deprecated use qof_event_gen instead. */
void gnc_engine_gen_event (QofEntity *entity, GNCEngineEventType event_type);
void gnc_engine_gen_event (QofInstance *entity, GNCEngineEventType event_type);
/** \deprecated use qof_event_suspend instead. */
void gnc_engine_suspend_events (void);
/** \deprecated use qof_event_resume instead. */

View File

@ -115,10 +115,10 @@ void qof_book_set_backend (QofBook *book, QofBackend *be);
/* Register books with the engine */
gboolean qof_book_register (void);
/** @deprecated use qof_entity_set_guid instead but only in
/** @deprecated use qof_instance_set_guid instead but only in
backends (when reading the GUID from the data source). */
#define qof_book_set_guid(book,guid) \
qof_entity_set_guid(QOF_ENTITY(book), guid)
qof_instance_set_guid(QOF_INSTANCE(book), guid)
/* @} */
/* @} */

View File

@ -86,7 +86,7 @@ qof_book_new (void)
qof_book_init(book);
qof_object_book_begin (book);
qof_event_gen (&book->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&book->inst, QOF_EVENT_CREATE, NULL);
LEAVE ("book=%p", book);
return book;
}
@ -108,7 +108,7 @@ qof_book_destroy (QofBook *book)
ENTER ("book=%p", book);
book->shutting_down = TRUE;
qof_event_force (&book->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_force (&book->inst, QOF_EVENT_DESTROY, NULL);
/* Call the list of finalizers, let them do their thing.
* Do this before tearing into the rest of the book.
@ -411,7 +411,7 @@ qof_book_get_counter (QofBook *book, const char *counter_name)
gboolean qof_book_register (void)
{
static QofParam params[] = {
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, NULL },
{ NULL },
};

View File

@ -50,7 +50,7 @@
/** Lookup an entity by guid, returning pointer to the entity */
#define QOF_BOOK_LOOKUP_ENTITY(book,guid,e_type,c_type) ({ \
QofEntity *val = NULL; \
QofInstance *val = NULL; \
if (guid && book) { \
QofCollection *col; \
col = qof_book_get_collection (book, e_type); \
@ -191,7 +191,7 @@ gboolean qof_book_equal (const QofBook *book_1, const QofBook *book_2);
gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
/** deprecated */
#define qof_book_get_guid(X) qof_entity_get_guid (QOF_ENTITY(X))
#define qof_book_get_guid(X) qof_instance_get_guid (QOF_INSTANCE(X))
#endif /* QOF_BOOK_H */
/** @} */

View File

@ -74,7 +74,7 @@ struct collect_list_s
};
static void
collect_reference_cb (QofEntity *ent, gpointer user_data)
collect_reference_cb (QofInstance *ent, gpointer user_data)
{
struct collect_list_s *s;
@ -89,7 +89,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
QofBookMergeRule *currentRule;
QofCollection *mergeColl, *targetColl;
gchar *stringImport, *stringTarget;
QofEntity *mergeEnt, *targetEnt, *referenceEnt;
QofInstance *mergeEnt, *targetEnt, *referenceEnt;
const GUID *guidImport, *guidTarget;
QofParam *qtparam;
KvpFrame *kvpImport, *kvpTarget;
@ -97,13 +97,13 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
QofType mergeType;
GSList *paramList;
gboolean absolute, mergeError, knowntype, mergeMatch, booleanImport, booleanTarget,
(*boolean_getter) (QofEntity*, QofParam*);
Timespec tsImport, tsTarget, (*date_getter) (QofEntity*, QofParam*);
gnc_numeric numericImport, numericTarget, (*numeric_getter) (QofEntity*, QofParam*);
double doubleImport, doubleTarget, (*double_getter) (QofEntity*, QofParam*);
gint32 i32Import, i32Target, (*int32_getter) (QofEntity*, QofParam*);
gint64 i64Import, i64Target, (*int64_getter) (QofEntity*, QofParam*);
gchar charImport, charTarget, (*char_getter) (QofEntity*, QofParam*);
(*boolean_getter) (QofInstance*, QofParam*);
Timespec tsImport, tsTarget, (*date_getter) (QofInstance*, QofParam*);
gnc_numeric numericImport, numericTarget, (*numeric_getter) (QofInstance*, QofParam*);
double doubleImport, doubleTarget, (*double_getter) (QofInstance*, QofParam*);
gint32 i32Import, i32Target, (*int32_getter) (QofInstance*, QofParam*);
gint64 i64Import, i64Target, (*int64_getter) (QofInstance*, QofParam*);
gchar charImport, charTarget, (*char_getter) (QofInstance*, QofParam*);
g_return_val_if_fail((mergeData != NULL), -1);
currentRule = mergeData->currentRule;
@ -140,7 +140,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
knowntype= TRUE;
}
if(safe_strcmp(mergeType, QOF_TYPE_DATE) == 0) {
date_getter = (Timespec (*)(QofEntity*, QofParam*))qtparam->param_getfcn;
date_getter = (Timespec (*)(QofInstance*, QofParam*))qtparam->param_getfcn;
tsImport = date_getter(mergeEnt, qtparam);
tsTarget = date_getter(targetEnt, qtparam);
if(timespec_cmp(&tsImport, &tsTarget) == 0) { mergeMatch = TRUE; }
@ -150,7 +150,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
}
if((safe_strcmp(mergeType, QOF_TYPE_NUMERIC) == 0) ||
(safe_strcmp(mergeType, QOF_TYPE_DEBCRED) == 0)) {
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
numericImport = numeric_getter(mergeEnt,qtparam);
numericTarget = numeric_getter(targetEnt,qtparam);
if(gnc_numeric_compare (numericImport, numericTarget) == 0) { mergeMatch = TRUE; }
@ -167,7 +167,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
knowntype= TRUE;
}
if(safe_strcmp(mergeType, QOF_TYPE_INT32) == 0) {
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
i32Import = int32_getter(mergeEnt, qtparam);
i32Target = int32_getter(targetEnt, qtparam);
if(i32Target == i32Import) { mergeMatch = TRUE; }
@ -176,7 +176,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
knowntype= TRUE;
}
if(safe_strcmp(mergeType, QOF_TYPE_INT64) == 0) {
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
i64Import = int64_getter(mergeEnt, qtparam);
i64Target = int64_getter(targetEnt, qtparam);
if(i64Target == i64Import) { mergeMatch = TRUE; }
@ -185,7 +185,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
knowntype= TRUE;
}
if(safe_strcmp(mergeType, QOF_TYPE_DOUBLE) == 0) {
double_getter = (double (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
double_getter = (double (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
doubleImport = double_getter(mergeEnt, qtparam);
doubleTarget = double_getter(mergeEnt, qtparam);
if(doubleImport == doubleTarget) { mergeMatch = TRUE; }
@ -194,7 +194,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
knowntype= TRUE;
}
if(safe_strcmp(mergeType, QOF_TYPE_BOOLEAN) == 0){
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
booleanImport = boolean_getter(mergeEnt, qtparam);
booleanTarget = boolean_getter(targetEnt, qtparam);
if(booleanImport != FALSE && booleanImport != TRUE) { booleanImport = FALSE; }
@ -213,7 +213,7 @@ qof_book_merge_compare(QofBookMergeData *mergeData )
knowntype= TRUE;
}
if(safe_strcmp(mergeType, QOF_TYPE_CHAR) == 0) {
char_getter = (gchar (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
char_getter = (gchar (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
charImport = char_getter(mergeEnt, qtparam);
charTarget = char_getter(targetEnt, qtparam);
if(charImport == charTarget) { mergeMatch = TRUE; }
@ -325,7 +325,7 @@ The next mergeEnt may be a much better match for that targetEnt and the target_t
is designed to solve the issues that result from this conflict. The previous match
must be re-assigned because if two mergeEnt's are matched with only one targetEnt,
data loss \b WILL follow. Equally, the current mergeEnt must replace the previous
one as it is a better match. qof_entity_rating holds the details required to identify
one as it is a better match. qof_instance_rating holds the details required to identify
the correct mergeEnt to be re-assigned and these mergeEnt entities are therefore
orphaned - to be re-matched later.
@ -372,7 +372,7 @@ qof_book_merge_match_orphans(QofBookMergeData *mergeData)
{
GSList *orphans, *targets;
QofBookMergeRule *rule, *currentRule;
QofEntity *best_matchEnt;
QofInstance *best_matchEnt;
double difference;
g_return_if_fail(mergeData != NULL);
@ -409,7 +409,7 @@ qof_book_merge_match_orphans(QofBookMergeData *mergeData)
}
static void
qof_book_merge_foreach_target (QofEntity* targetEnt, gpointer user_data)
qof_book_merge_foreach_target (QofInstance* targetEnt, gpointer user_data)
{
QofBookMergeData *mergeData;
@ -437,11 +437,11 @@ qof_book_merge_foreach_type_target ( QofObject* merge_obj, gpointer user_data)
}
static void
qof_book_merge_foreach ( QofEntity* mergeEnt, gpointer user_data)
qof_book_merge_foreach ( QofInstance* mergeEnt, gpointer user_data)
{
QofBookMergeRule *mergeRule, *currentRule;
QofBookMergeData *mergeData;
QofEntity *targetEnt, *best_matchEnt;
QofInstance *targetEnt, *best_matchEnt;
GUID *g;
double difference;
GSList *c;
@ -592,7 +592,7 @@ qof_book_merge_commit_rule_loop(
{
QofInstance *inst;
gboolean registered_type;
QofEntity *referenceEnt;
QofInstance *referenceEnt;
/* cm_ prefix used for variables that hold the data to commit */
QofCollection *cm_coll;
QofParam *cm_param;
@ -600,26 +600,26 @@ qof_book_merge_commit_rule_loop(
const GUID *cm_guid;
KvpFrame *cm_kvp;
/* function pointers and variables for parameter getters that don't use pointers normally */
gnc_numeric cm_numeric, (*numeric_getter) (QofEntity*, QofParam*);
double cm_double, (*double_getter) (QofEntity*, QofParam*);
gboolean cm_boolean, (*boolean_getter) (QofEntity*, QofParam*);
gint32 cm_i32, (*int32_getter) (QofEntity*, QofParam*);
gint64 cm_i64, (*int64_getter) (QofEntity*, QofParam*);
Timespec cm_date, (*date_getter) (QofEntity*, QofParam*);
gchar cm_char, (*char_getter) (QofEntity*, QofParam*);
gnc_numeric cm_numeric, (*numeric_getter) (QofInstance*, QofParam*);
double cm_double, (*double_getter) (QofInstance*, QofParam*);
gboolean cm_boolean, (*boolean_getter) (QofInstance*, QofParam*);
gint32 cm_i32, (*int32_getter) (QofInstance*, QofParam*);
gint64 cm_i64, (*int64_getter) (QofInstance*, QofParam*);
Timespec cm_date, (*date_getter) (QofInstance*, QofParam*);
gchar cm_char, (*char_getter) (QofInstance*, QofParam*);
/* function pointers to the parameter setters */
void (*string_setter) (QofEntity*, const gchar*);
void (*date_setter) (QofEntity*, Timespec);
void (*numeric_setter) (QofEntity*, gnc_numeric);
void (*guid_setter) (QofEntity*, const GUID*);
void (*double_setter) (QofEntity*, double);
void (*boolean_setter) (QofEntity*, gboolean);
void (*i32_setter) (QofEntity*, gint32);
void (*i64_setter) (QofEntity*, gint64);
void (*char_setter) (QofEntity*, gchar);
void (*kvp_frame_setter) (QofEntity*, KvpFrame*);
void (*reference_setter) (QofEntity*, QofEntity*);
void (*collection_setter)(QofEntity*, QofCollection*);
void (*string_setter) (QofInstance*, const gchar*);
void (*date_setter) (QofInstance*, Timespec);
void (*numeric_setter) (QofInstance*, gnc_numeric);
void (*guid_setter) (QofInstance*, const GUID*);
void (*double_setter) (QofInstance*, double);
void (*boolean_setter) (QofInstance*, gboolean);
void (*i32_setter) (QofInstance*, gint32);
void (*i64_setter) (QofInstance*, gint64);
void (*char_setter) (QofInstance*, gchar);
void (*kvp_frame_setter) (QofInstance*, KvpFrame*);
void (*reference_setter) (QofInstance*, QofInstance*);
void (*collection_setter)(QofInstance*, QofCollection*);
g_return_if_fail(rule != NULL);
g_return_if_fail(mergeData != NULL);
@ -630,8 +630,8 @@ qof_book_merge_commit_rule_loop(
if(rule->mergeResult == MERGE_NEW) {
inst = (QofInstance*)qof_object_new_instance(rule->importEnt->e_type, mergeData->targetBook);
g_return_if_fail(inst != NULL);
rule->targetEnt = &inst->entity;
qof_entity_set_guid(rule->targetEnt, qof_entity_get_guid(rule->importEnt));
rule->targetEnt = inst;
qof_instance_set_guid(rule->targetEnt, qof_instance_get_guid(rule->importEnt));
}
/* currentRule->targetEnt is now set,
1. by an absolute GUID match or
@ -645,81 +645,81 @@ qof_book_merge_commit_rule_loop(
rule->mergeType = cm_param->param_type;
if(safe_strcmp(rule->mergeType, QOF_TYPE_STRING) == 0) {
cm_string = cm_param->param_getfcn(rule->importEnt, cm_param);
string_setter = (void(*)(QofEntity*, const gchar*))cm_param->param_setfcn;
string_setter = (void(*)(QofInstance*, const gchar*))cm_param->param_setfcn;
if(string_setter != NULL) { string_setter(rule->targetEnt, cm_string); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_DATE) == 0) {
date_getter = (Timespec (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
date_getter = (Timespec (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
cm_date = date_getter(rule->importEnt, cm_param);
date_setter = (void(*)(QofEntity*, Timespec))cm_param->param_setfcn;
date_setter = (void(*)(QofInstance*, Timespec))cm_param->param_setfcn;
if(date_setter != NULL) { date_setter(rule->targetEnt, cm_date); }
registered_type = TRUE;
}
if((safe_strcmp(rule->mergeType, QOF_TYPE_NUMERIC) == 0) ||
(safe_strcmp(rule->mergeType, QOF_TYPE_DEBCRED) == 0)) {
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
cm_numeric = numeric_getter(rule->importEnt, cm_param);
numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_param->param_setfcn;
numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_param->param_setfcn;
if(numeric_setter != NULL) { numeric_setter(rule->targetEnt, cm_numeric); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_GUID) == 0) {
cm_guid = cm_param->param_getfcn(rule->importEnt, cm_param);
guid_setter = (void(*)(QofEntity*, const GUID*))cm_param->param_setfcn;
guid_setter = (void(*)(QofInstance*, const GUID*))cm_param->param_setfcn;
if(guid_setter != NULL) { guid_setter(rule->targetEnt, cm_guid); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_INT32) == 0) {
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_i32 = int32_getter(rule->importEnt, cm_param);
i32_setter = (void(*)(QofEntity*, gint32))cm_param->param_setfcn;
i32_setter = (void(*)(QofInstance*, gint32))cm_param->param_setfcn;
if(i32_setter != NULL) { i32_setter(rule->targetEnt, cm_i32); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_INT64) == 0) {
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_i64 = int64_getter(rule->importEnt, cm_param);
i64_setter = (void(*)(QofEntity*, gint64))cm_param->param_setfcn;
i64_setter = (void(*)(QofInstance*, gint64))cm_param->param_setfcn;
if(i64_setter != NULL) { i64_setter(rule->targetEnt, cm_i64); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_DOUBLE) == 0) {
double_getter = (double (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
double_getter = (double (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_double = double_getter(rule->importEnt, cm_param);
double_setter = (void(*)(QofEntity*, double))cm_param->param_setfcn;
double_setter = (void(*)(QofInstance*, double))cm_param->param_setfcn;
if(double_setter != NULL) { double_setter(rule->targetEnt, cm_double); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_BOOLEAN) == 0){
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_boolean = boolean_getter(rule->importEnt, cm_param);
boolean_setter = (void(*)(QofEntity*, gboolean))cm_param->param_setfcn;
boolean_setter = (void(*)(QofInstance*, gboolean))cm_param->param_setfcn;
if(boolean_setter != NULL) { boolean_setter(rule->targetEnt, cm_boolean); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_KVP) == 0) {
cm_kvp = kvp_frame_copy(cm_param->param_getfcn(rule->importEnt,cm_param));
kvp_frame_setter = (void(*)(QofEntity*, KvpFrame*))cm_param->param_setfcn;
kvp_frame_setter = (void(*)(QofInstance*, KvpFrame*))cm_param->param_setfcn;
if(kvp_frame_setter != NULL) { kvp_frame_setter(rule->targetEnt, cm_kvp); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_CHAR) == 0) {
char_getter = (gchar (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
char_getter = (gchar (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_char = char_getter(rule->importEnt,cm_param);
char_setter = (void(*)(QofEntity*, gchar))cm_param->param_setfcn;
char_setter = (void(*)(QofInstance*, gchar))cm_param->param_setfcn;
if(char_setter != NULL) { char_setter(rule->targetEnt, cm_char); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_COLLECT) == 0) {
cm_coll = cm_param->param_getfcn(rule->importEnt, cm_param);
collection_setter = (void(*)(QofEntity*, QofCollection*))cm_param->param_setfcn;
collection_setter = (void(*)(QofInstance*, QofCollection*))cm_param->param_setfcn;
if(collection_setter != NULL) { collection_setter(rule->targetEnt, cm_coll); }
registered_type = TRUE;
}
if(safe_strcmp(rule->mergeType, QOF_TYPE_CHOICE) == 0) {
referenceEnt = cm_param->param_getfcn(rule->importEnt, cm_param);
reference_setter = (void(*)(QofEntity*, QofEntity*))cm_param->param_setfcn;
reference_setter = (void(*)(QofInstance*, QofInstance*))cm_param->param_setfcn;
if(reference_setter != NULL)
{
reference_setter(rule->targetEnt, referenceEnt);
@ -729,7 +729,7 @@ qof_book_merge_commit_rule_loop(
if(registered_type == FALSE) {
referenceEnt = cm_param->param_getfcn(rule->importEnt, cm_param);
if(referenceEnt) {
reference_setter = (void(*)(QofEntity*, QofEntity*))cm_param->param_setfcn;
reference_setter = (void(*)(QofInstance*, QofInstance*))cm_param->param_setfcn;
if(reference_setter != NULL)
{
reference_setter(rule->targetEnt, referenceEnt);
@ -819,20 +819,20 @@ and then add
gchar* qof_class_get_param_as_string(QofIdTypeConst, QofInstance*); ?
*/
gchar*
qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
qof_book_merge_param_as_string(QofParam *qtparam, QofInstance *qtEnt)
{
gchar *param_string, param_date[QOF_DATE_STRING_LENGTH];
gchar param_sa[GUID_ENCODING_LENGTH + 1];
QofType paramType;
const GUID *param_guid;
time_t param_t;
gnc_numeric param_numeric, (*numeric_getter) (QofEntity*, QofParam*);
Timespec param_ts, (*date_getter) (QofEntity*, QofParam*);
double param_double, (*double_getter) (QofEntity*, QofParam*);
gboolean param_boolean, (*boolean_getter) (QofEntity*, QofParam*);
gint32 param_i32, (*int32_getter) (QofEntity*, QofParam*);
gint64 param_i64, (*int64_getter) (QofEntity*, QofParam*);
gchar param_char, (*char_getter) (QofEntity*, QofParam*);
gnc_numeric param_numeric, (*numeric_getter) (QofInstance*, QofParam*);
Timespec param_ts, (*date_getter) (QofInstance*, QofParam*);
double param_double, (*double_getter) (QofInstance*, QofParam*);
gboolean param_boolean, (*boolean_getter) (QofInstance*, QofParam*);
gint32 param_i32, (*int32_getter) (QofInstance*, QofParam*);
gint64 param_i64, (*int64_getter) (QofInstance*, QofParam*);
gchar param_char, (*char_getter) (QofInstance*, QofParam*);
param_string = NULL;
paramType = qtparam->param_type;
@ -842,7 +842,7 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_DATE) == 0) {
date_getter = (Timespec (*)(QofEntity*, QofParam*))qtparam->param_getfcn;
date_getter = (Timespec (*)(QofInstance*, QofParam*))qtparam->param_getfcn;
param_ts = date_getter(qtEnt, qtparam);
param_t = timespecToTime_t(param_ts);
strftime(param_date, QOF_DATE_STRING_LENGTH, QOF_UTC_DATE_FORMAT, gmtime(&param_t));
@ -851,7 +851,7 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
}
if((safe_strcmp(paramType, QOF_TYPE_NUMERIC) == 0) ||
(safe_strcmp(paramType, QOF_TYPE_DEBCRED) == 0)) {
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
param_numeric = numeric_getter(qtEnt,qtparam);
param_string = g_strdup(gnc_numeric_to_string(param_numeric));
return param_string;
@ -863,25 +863,25 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_INT32) == 0) {
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
param_i32 = int32_getter(qtEnt, qtparam);
param_string = g_strdup_printf("%d", param_i32);
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_INT64) == 0) {
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
param_i64 = int64_getter(qtEnt, qtparam);
param_string = g_strdup_printf("%" G_GINT64_FORMAT, param_i64);
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_DOUBLE) == 0) {
double_getter = (double (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
double_getter = (double (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
param_double = double_getter(qtEnt, qtparam);
param_string = g_strdup_printf("%f", param_double);
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_BOOLEAN) == 0){
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
param_boolean = boolean_getter(qtEnt, qtparam);
/* Boolean values need to be lowercase for QSF validation. */
if(param_boolean == TRUE) { param_string = g_strdup("true"); }
@ -891,7 +891,7 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
/* "kvp" contains repeating values, cannot be a single string for the frame. */
if(safe_strcmp(paramType, QOF_TYPE_KVP) == 0) { return param_string; }
if(safe_strcmp(paramType, QOF_TYPE_CHAR) == 0) {
char_getter = (gchar (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
char_getter = (gchar (*)(QofInstance*, QofParam*)) qtparam->param_getfcn;
param_char = char_getter(qtEnt, qtparam);
param_string = g_strdup_printf("%c", param_char);
return param_string;

View File

@ -175,7 +175,7 @@ typedef struct
GSList *mergeParam; /**< list of usable parameters for the object type */
GSList *linkedEntList; /**< list of complex data types included in this object.
linkedEntList contains an ::QofEntity reference to any parameter that is not
linkedEntList contains an ::QofInstance reference to any parameter that is not
one of the core QOF_TYPE data types. This entity must be already
registered with QOF and the results of the comparison for the linked entity
will modulate the mergeResult of this object. e.g. if an invoice is the
@ -183,8 +183,8 @@ typedef struct
MERGE_REPORT and the customer as MERGE_NEW.
*/
QofBookMergeResult mergeResult; /**< result of comparison with main ::QofBook */
QofEntity *importEnt; /**< pointer to the current entity in the import book. */
QofEntity *targetEnt; /**< pointer to the corresponding entity in the
QofInstance *importEnt; /**< pointer to the current entity in the import book. */
QofInstance *targetEnt; /**< pointer to the corresponding entity in the
target book, if any. */
}QofBookMergeRule;
@ -194,7 +194,7 @@ typedef struct
Used to dictate what to merge, how to merge it, where to get the new data and
where to put the amended data.
Combines lists of \a ::QofParam, \a ::QofEntity and \a ::QofBookMergeRule
Combines lists of \a ::QofParam, \a ::QofInstance and \a ::QofBookMergeRule
into one struct that can be easily passed between callbacks. Also holds the
pointers to the import and target ::QofBook structures.
@ -209,7 +209,7 @@ typedef struct
parameter in the current object. */
GList *mergeList; /**< GList of all ::qof_book_mergeRule rules
for the merge operation. */
GSList *targetList; /**< GSList of ::QofEntity * for each object
GSList *targetList; /**< GSList of ::QofInstance * for each object
of this type in the target book */
QofBook *mergeBook; /**< pointer to the import book for this
merge operation. */
@ -218,16 +218,16 @@ typedef struct
gboolean abort; /**< set to TRUE if MERGE_INVALID is set. */
QofBookMergeRule *currentRule; /**< placeholder for the rule currently
being tested or applied. */
GSList *orphan_list; /**< List of QofEntity's that need to be rematched.
GSList *orphan_list; /**< List of QofInstance's that need to be rematched.
When one QofEntity has a lower difference to the targetEnt than the
When one QofInstance has a lower difference to the targetEnt than the
previous best_match, the new match takes precedence. This list holds those
orphaned entities that are not a good enough match so that these can be
rematched later. The ranking is handled using the private QofEntityRating
rematched later. The ranking is handled using the private QofInstanceRating
struct and the GHashTable ::QofBookMergeData::target_table.
*/
GHashTable *target_table; /**< The GHashTable to hold the
QofEntityRating values. */
QofInstanceRating values. */
}QofBookMergeData;
@ -335,7 +335,7 @@ process must handle the NULL targetEnt and NOT call any param_getfcn
routines for the target entity. The import entity is available for display.
Uses ::qof_book_get_collection with the QofBookMergeRule::mergeType object
type to return a collection of ::QofEntity entities from either the
type to return a collection of ::QofInstance entities from either the
QofBookMergeData::mergeBook or QofBookMergeData::targetBook. Then
uses ::qof_collection_lookup_entity to lookup the QofBookMergeRule::importEnt
and again the qof_book_mergeRule::targetEnt to return the two specific entities.
@ -359,7 +359,7 @@ This allows the dialog to display the description of the object and all
parameter data.
*/
gchar* qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt);
gchar* qof_book_merge_param_as_string(QofParam *qtparam, QofInstance *qtEnt);
/** \brief called by dialogue callback to set the result of user intervention

View File

@ -267,7 +267,7 @@ void qof_class_param_foreach (QofIdTypeConst obj_name,
Simple check to return a GList of all parameters
of this object type that are not known QOF data types.
Used for partial QofBook support, see ::QofEntityReference
Used for partial QofBook support, see ::QofInstanceReference
*/
GList* qof_class_get_referenceList(QofIdTypeConst type);

View File

@ -48,6 +48,6 @@ qof_event_generate (const GUID *guid, QofIdType e_type,
QofEventId event_id);
/* generates an event even when events are suspended! */
void qof_event_force (QofEntity *entity, QofEventId event_id, gpointer event_data);
void qof_event_force (QofInstance *entity, QofEventId event_id, gpointer event_data);
#endif

View File

@ -203,7 +203,7 @@ qof_event_resume (void)
}
static void
qof_event_generate_internal (QofEntity *entity, QofEventId event_id,
qof_event_generate_internal (QofInstance *entity, QofEventId event_id,
gpointer event_data)
{
GList *node;
@ -275,7 +275,7 @@ qof_event_generate_internal (QofEntity *entity, QofEventId event_id,
}
void
qof_event_force (QofEntity *entity, QofEventId event_id, gpointer event_data)
qof_event_force (QofInstance *entity, QofEventId event_id, gpointer event_data)
{
if (!entity)
return;
@ -284,7 +284,7 @@ qof_event_force (QofEntity *entity, QofEventId event_id, gpointer event_data)
}
void
qof_event_gen (QofEntity *entity, QofEventId event_id, gpointer event_data)
qof_event_gen (QofInstance *entity, QofEventId event_id, gpointer event_data)
{
if (!entity)
return;
@ -300,7 +300,7 @@ void
qof_event_generate (const GUID *guid, QofIdType e_type,
QofEventId event_id)
{
QofEntity ent;
QofInstance ent;
ent.guid = *guid;
ent.e_type = e_type;
if (suspend_counter) return;

View File

@ -81,7 +81,7 @@ for future libqof1 or libqof2 usage.
* @param handler_data: data supplied when handler was registered.
* @param event_data: data to be supplied when handler is invoked.
*/
typedef void (*QofEventHandler) (QofEntity *ent, QofEventId event_type,
typedef void (*QofEventHandler) (QofInstance *ent, QofEventId event_type,
gpointer handler_data, gpointer event_data);
/** \brief Register a handler for events.
@ -113,14 +113,14 @@ void qof_event_unregister_handler (gint handler_id);
Any other events are entirely the concern of the application.
\note QofEventHandler routines do \b NOT support generating
events from a GUID and QofIdType - you must specify a genuine QofEntity.
events from a GUID and QofIdType - you must specify a genuine QofInstance.
@param entity: the entity generating the event
@param event_type: the name of the event.
@param event_data: Data to be passed to the event handler just for
this one event. Can be NULL.
*/
void qof_event_gen (QofEntity *entity, QofEventId event_type,
void qof_event_gen (QofInstance *entity, QofEventId event_type,
gpointer event_data);
/** \brief Suspend all engine events.

View File

@ -202,7 +202,7 @@ qof_gobject_double_getter (gpointer data, QofParam *getter)
* of instances that we have on hand.
*/
static void
qof_gobject_foreach (QofCollection *coll, QofEntityForeachCB cb, gpointer ud)
qof_gobject_foreach (QofCollection *coll, QofInstanceForeachCB cb, gpointer ud)
{
GSList *n;
n = qof_collection_get_data (coll);

View File

@ -38,13 +38,13 @@
/** Set the ID of the entity, over-riding the previous ID.
* Very dangerous, use only for file i/o work.
*/
void qof_entity_set_guid (QofEntity *ent, const GUID *guid);
void qof_instance_set_guid (QofInstance *ent, const GUID *guid);
/** Take entity, remove it from whatever collection its currently
* in, and place it in a new collection. To be used only for
* moving entity from one book to another.
*/
void qof_collection_insert_entity (QofCollection *, QofEntity *);
void qof_collection_insert_entity (QofCollection *, QofInstance *);
/** reset value of dirty flag */
void qof_collection_mark_clean (QofCollection *);

View File

@ -58,6 +58,58 @@ qof_set_alt_dirty_mode (gboolean enabled)
/* =============================================================== */
void
qof_entity_init (QofInstance *ent, QofIdType type, QofCollection * tab)
{
g_return_if_fail (NULL != tab);
/* XXX We passed redundant info to this routine ... but I think that's
* OK, it might eliminate programming errors. */
if (safe_strcmp(tab->e_type, type))
{
PERR ("attempt to insert \"%s\" into \"%s\"", type, tab->e_type);
return;
}
ent->e_type = CACHE_INSERT (type);
do
{
guid_new(&ent->guid);
if (NULL == qof_collection_lookup_entity (tab, &ent->guid)) break;
PWARN("duplicate id created, trying again");
} while(1);
ent->collection = tab;
qof_collection_insert_entity (tab, ent);
}
void
qof_entity_release (QofInstance *ent)
{
if (!ent->collection) return;
qof_collection_remove_entity (ent);
CACHE_REMOVE (ent->e_type);
ent->e_type = NULL;
}
/* This is a restricted function, should be used only during
* read from file */
void
qof_instance_set_guid (QofInstance *ent, const GUID *guid)
{
QofCollection *col;
if (guid_equal (guid, &ent->guid)) return;
col = ent->collection;
qof_collection_remove_entity (ent);
ent->guid = *guid;
qof_collection_insert_entity (col, ent);
}
/* =============================================================== */
static guint
@ -129,7 +181,7 @@ qof_collection_get_type (const QofCollection *col)
/* =============================================================== */
void
qof_collection_remove_entity (QofEntity *ent)
qof_collection_remove_entity (QofInstance *ent)
{
QofCollection *col;
if (!ent) return;
@ -142,7 +194,7 @@ qof_collection_remove_entity (QofEntity *ent)
}
void
qof_collection_insert_entity (QofCollection *col, QofEntity *ent)
qof_collection_insert_entity (QofCollection *col, QofInstance *ent)
{
if (!col || !ent) return;
if (guid_equal(&ent->guid, guid_null())) return;
@ -155,9 +207,9 @@ qof_collection_insert_entity (QofCollection *col, QofEntity *ent)
}
gboolean
qof_collection_add_entity (QofCollection *coll, QofEntity *ent)
qof_collection_add_entity (QofCollection *coll, QofInstance *ent)
{
QofEntity *e;
QofInstance *e;
e = NULL;
if (!coll || !ent) { return FALSE; }
@ -172,7 +224,7 @@ qof_collection_add_entity (QofCollection *coll, QofEntity *ent)
}
static void
collection_merge_cb (QofEntity *ent, gpointer data)
collection_merge_cb (QofInstance *ent, gpointer data)
{
QofCollection *target;
@ -190,10 +242,10 @@ qof_collection_merge (QofCollection *target, QofCollection *merge)
}
static void
collection_compare_cb (QofEntity *ent, gpointer user_data)
collection_compare_cb (QofInstance *ent, gpointer user_data)
{
QofCollection *target;
QofEntity *e;
QofInstance *e;
gint value;
e = NULL;
@ -241,10 +293,10 @@ qof_collection_compare (QofCollection *target, QofCollection *merge)
return value;
}
QofEntity *
QofInstance *
qof_collection_lookup_entity (const QofCollection *col, const GUID * guid)
{
QofEntity *ent;
QofInstance *ent;
g_return_val_if_fail (col, NULL);
if (guid == NULL) return NULL;
ent = g_hash_table_lookup (col->hash_of_entities, guid);
@ -255,13 +307,13 @@ QofCollection *
qof_collection_from_glist (QofIdType type, GList *glist)
{
QofCollection *coll;
QofEntity *ent;
QofInstance *ent;
GList *list;
coll = qof_collection_new(type);
for(list = glist; list != NULL; list = list->next)
{
ent = QOF_ENTITY(list->data);
ent = QOF_INSTANCE(list->data);
if(FALSE == qof_collection_add_entity(coll, ent))
{
return NULL;
@ -304,7 +356,7 @@ qof_collection_print_dirty (const QofCollection *col, gpointer dummy)
{
if (col->is_dirty)
printf("%s collection is dirty.\n", col->e_type);
qof_collection_foreach(col, (QofEntityForeachCB)qof_instance_print_dirty, NULL);
qof_collection_foreach(col, (QofInstanceForeachCB)qof_instance_print_dirty, NULL);
}
/* =============================================================== */
@ -324,20 +376,20 @@ qof_collection_set_data (QofCollection *col, gpointer user_data)
/* =============================================================== */
struct _iterate {
QofEntityForeachCB fcn;
QofInstanceForeachCB fcn;
gpointer data;
};
static void foreach_cb (gpointer key, gpointer item, gpointer arg)
{
struct _iterate *iter = arg;
QofEntity *ent = item;
QofInstance *ent = item;
iter->fcn (ent, iter->data);
}
void
qof_collection_foreach (const QofCollection *col, QofEntityForeachCB cb_func,
qof_collection_foreach (const QofCollection *col, QofInstanceForeachCB cb_func,
gpointer user_data)
{
struct _iterate iter;

View File

@ -111,7 +111,7 @@ typedef struct QofInstance_s QofInstance;
/** return TRUE if object is of the given type */
#define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
(0 == QSTRCMP((type),(((QofEntity *)(obj))->e_type))))
(0 == QSTRCMP((type),(((QofInstance *)(obj))->e_type))))
/** cast object to the indicated type,
print error message if its bad */
@ -120,10 +120,11 @@ print error message if its bad */
(c_type *) (obj) : \
(c_type *) ({ \
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
"Error: Bad QofEntity at %s:%d", __FILE__, __LINE__); \
"Error: Bad QofInstance at %s:%d", __FILE__, __LINE__); \
(obj); \
}))
/** QofCollection declaration
@param e_type QofIdType
@ -134,15 +135,9 @@ print error message if its bad */
*/
typedef struct QofCollection_s QofCollection;
/** @name QOF Entity Initialization & Shutdown
@{ */
/** Initialise the memory associated with an entity */
void qof_entity_init (QofEntity *, QofIdType, QofCollection *);
/** Release the data associated with this entity. Dont actually free
* the memory associated with the instance. */
void qof_entity_release (QofEntity *);
/** @} */
void qof_entity_init (QofInstance *ent, QofIdType type, QofCollection * tab);
void qof_entity_release (QofInstance *ent);
void qof_instance_set_guid (QofInstance *ent, const GUID *guid);
/** Is QOF operating in "alternate" dirty mode. In normal mode,
* whenever an instance is dirtied, the collection (and therefore the
@ -162,7 +157,7 @@ gboolean qof_get_alt_dirty_mode (void);
void qof_set_alt_dirty_mode (gboolean enabled);
/** Return the GUID of this entity */
const GUID * qof_entity_get_guid (const QofEntity *);
const GUID * qof_instance_get_guid (const QofInstance *);
/** @name Collections of Entities
@{ */
@ -180,13 +175,13 @@ void qof_collection_destroy (QofCollection *col);
QofIdType qof_collection_get_type (const QofCollection *);
/** Find the entity going only from its guid */
QofEntity * qof_collection_lookup_entity (const QofCollection *, const GUID *);
QofInstance * qof_collection_lookup_entity (const QofCollection *, const GUID *);
/** Callback type for qof_collection_foreach */
typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
/** Call the callback for each entity in the collection. */
void qof_collection_foreach (const QofCollection *, QofEntityForeachCB,
void qof_collection_foreach (const QofCollection *, QofInstanceForeachCB,
gpointer user_data);
/** Store and retreive arbitrary object-defined data
@ -218,13 +213,13 @@ of one object type as references of another entity.
Entities can be
freely added and merged across these secondary collections, they
will not be removed from the original collection as they would
by using ::qof_entity_insert_entity or ::qof_entity_remove_entity.
by using ::qof_instance_insert_entity or ::qof_instance_remove_entity.
*/
gboolean
qof_collection_add_entity (QofCollection *coll, QofEntity *ent);
qof_collection_add_entity (QofCollection *coll, QofInstance *ent);
void qof_collection_remove_entity (QofEntity *ent);
void qof_collection_remove_entity (QofInstance *ent);
/** \brief Merge two QOF_TYPE_COLLECT of the same type.
@ -232,8 +227,8 @@ void qof_collection_remove_entity (QofEntity *ent);
QOF_TYPE_COLLECT uses a secondary collection, independent of
those in the book. Entities will not be removed from the
original collection as when using ::qof_entity_insert_entity
or ::qof_entity_remove_entity.
original collection as when using ::qof_instance_insert_entity
or ::qof_instance_remove_entity.
*/
gboolean
@ -241,7 +236,7 @@ qof_collection_merge (QofCollection *target, QofCollection *merge);
/** \brief Compare two secondary collections.
Performs a deep comparision of the collections. Each QofEntity in
Performs a deep comparision of the collections. Each QofInstance in
each collection is looked up in the other collection, via the GUID.
\return 0 if the collections are identical or both are NULL

View File

@ -39,67 +39,6 @@ static QofLogModule log_module = QOF_MOD_ENGINE;
/* ========================================================== */
static void
qof_int_entity_init (QofEntity *ent, QofIdType type, QofCollection * tab)
{
g_return_if_fail (NULL != tab);
/* XXX We passed redundant info to this routine ... but I think that's
* OK, it might eliminate programming errors. */
if (safe_strcmp(tab->e_type, type))
{
PERR ("attempt to insert \"%s\" into \"%s\"", type, tab->e_type);
return;
}
ent->e_type = CACHE_INSERT (type);
do
{
guid_new(&ent->guid);
if (NULL == qof_collection_lookup_entity (tab, &ent->guid)) break;
PWARN("duplicate id created, trying again");
} while(1);
ent->collection = tab;
qof_collection_insert_entity (tab, ent);
}
void
qof_int_entity_release (QofEntity *ent)
{
if (!ent->collection) return;
qof_collection_remove_entity (ent);
CACHE_REMOVE (ent->e_type);
ent->e_type = NULL;
}
/* This is a restricted function, should be used only during
* read from file */
void
qof_entity_set_guid (QofEntity *ent, const GUID *guid)
{
QofCollection *col;
if (guid_equal (guid, &ent->guid)) return;
col = ent->collection;
qof_collection_remove_entity (ent);
ent->guid = *guid;
qof_collection_insert_entity (col, ent);
}
const GUID *
qof_entity_get_guid (const QofEntity *ent)
{
if (!ent) return guid_null();
return &ent->guid;
}
/* ========================================================== */
QofInstance*
qof_instance_create (QofIdType type, QofBook *book)
{
@ -127,7 +66,7 @@ qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
inst->infant = TRUE;
col = qof_book_get_collection (book, type);
qof_int_entity_init (&inst->entity, type, col);
qof_entity_init (inst, type, col);
}
void
@ -138,14 +77,14 @@ qof_instance_release (QofInstance *inst)
inst->editlevel = 0;
inst->do_free = FALSE;
inst->dirty = FALSE;
qof_int_entity_release (&inst->entity);
qof_entity_release (inst);
}
const GUID *
qof_instance_get_guid (const QofInstance *inst)
{
if (!inst) return NULL;
return &inst->entity.guid;
if (!inst) return guid_null();
return &(inst->guid);
}
QofBook *
@ -187,13 +126,13 @@ qof_instance_version_cmp (const QofInstance *left, const QofInstance *right)
}
void
qof_instance_print_dirty (const QofEntity *entity, gpointer dummy)
qof_instance_print_dirty (const QofInstance *entity, gpointer dummy)
{
QofInstance *inst = QOF_INSTANCE(entity);
if (inst->dirty)
printf("%s instance %s is dirty.\n", inst->entity.e_type,
guid_to_string(&inst->entity.guid));
printf("%s instance %s is dirty.\n", inst->e_type,
guid_to_string(&inst->guid));
}
gboolean
@ -204,7 +143,7 @@ qof_instance_is_dirty (QofInstance *inst)
if (!inst) { return FALSE; }
if (qof_get_alt_dirty_mode())
return inst->dirty;
coll = inst->entity.collection;
coll = inst->collection;
if(qof_collection_is_dirty(coll)) { return inst->dirty; }
inst->dirty = FALSE;
return FALSE;
@ -217,7 +156,7 @@ qof_instance_set_dirty(QofInstance* inst)
inst->dirty = TRUE;
if (!qof_get_alt_dirty_mode()) {
coll = inst->entity.collection;
coll = inst->collection;
qof_collection_mark_dirty(coll);
}
}
@ -285,12 +224,12 @@ qof_instance_gemini (QofInstance *to, const QofInstance *from)
/* Make a note of where the copy came from */
gnc_kvp_bag_add (to->kvp_data, "gemini", now,
"inst_guid", &from->entity.guid,
"book_guid", &from->book->inst.entity.guid,
"inst_guid", &from->guid,
"book_guid", &from->book->inst.guid,
NULL);
gnc_kvp_bag_add (from->kvp_data, "gemini", now,
"inst_guid", &to->entity.guid,
"book_guid", &to->book->inst.entity.guid,
"inst_guid", &to->guid,
"book_guid", &to->book->inst.guid,
NULL);
to->dirty = TRUE;
@ -308,11 +247,11 @@ qof_instance_lookup_twin (const QofInstance *src, QofBook *target_book)
ENTER (" ");
fr = gnc_kvp_bag_find_by_guid (src->kvp_data, "gemini",
"book_guid", &target_book->inst.entity.guid);
"book_guid", &target_book->inst.guid);
twin_guid = kvp_frame_get_guid (fr, "inst_guid");
col = qof_book_get_collection (target_book, src->entity.e_type);
col = qof_book_get_collection (target_book, src->e_type);
twin = (QofInstance *) qof_collection_lookup_entity (col, twin_guid);
LEAVE (" found twin=%p", twin);

View File

@ -22,7 +22,7 @@
/** @addtogroup Entity
@{ */
/** @addtogroup Instance
Qof Instances are a derived type of QofEntity. The Instance
Qof Instances are a derived type of QofInstance. The Instance
adds some common features and functions that most objects
will want to use.
@ -47,7 +47,7 @@
* thunks, etc. */
#define QOF_INSTANCE(object) ((QofInstance *)(object))
typedef struct QofInstance_s QofInstance;
/*typedef struct QofInstance_s QofInstance;*/
/** Initialise the memory associated with an instance */
void qof_instance_init (QofInstance *, QofIdType, QofBook *);
@ -81,7 +81,7 @@ Timespec qof_instance_get_last_update (const QofInstance *inst);
*/
int qof_instance_version_cmp (const QofInstance *left, const QofInstance *right);
void qof_instance_print_dirty (const QofEntity *entity, gpointer dummy);
void qof_instance_print_dirty (const QofInstance *entity, gpointer dummy);
/** Return value of is_dirty flag */
gboolean qof_instance_is_dirty (QofInstance *);

View File

@ -156,7 +156,7 @@ qof_object_compliance (QofIdTypeConst type_name, gboolean warn)
void
qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
QofEntityForeachCB cb, gpointer user_data)
QofInstanceForeachCB cb, gpointer user_data)
{
QofCollection *col;
const QofObject *obj;

View File

@ -104,7 +104,7 @@ struct _QofObject
* provide this routine, as without it, little of interest can
* be done.
*/
void (*foreach)(const QofCollection *, QofEntityForeachCB, gpointer);
void (*foreach)(const QofCollection *, QofInstanceForeachCB, gpointer);
/** Given a particular item of this type, return a printable string.
*/
@ -160,7 +160,7 @@ void qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data);
* be invoked only for those instances stored in the book.
*/
void qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
QofEntityForeachCB cb, gpointer user_data);
QofInstanceForeachCB cb, gpointer user_data);
/** Register and lookup backend-specific data for this particular object */
gboolean qof_object_register_backend (QofIdTypeConst type_name,

View File

@ -809,7 +809,7 @@ static void qof_query_run_cb(QofQueryCB* qcb, gpointer cb_arg)
/* And then iterate over all the objects */
qof_object_foreach (qcb->query->search_for, book,
(QofEntityForeachCB) check_item_cb, qcb);
(QofInstanceForeachCB) check_item_cb, qcb);
}
}

View File

@ -1450,13 +1450,13 @@ collect_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2)
}
static void
query_collect_cb(QofEntity* ent, gpointer user_data)
query_collect_cb(QofInstance* ent, gpointer user_data)
{
query_coll_t pdata;
GUID *guid;
guid = guid_malloc();
guid = (GUID*)qof_entity_get_guid(ent);
guid = (GUID*)qof_instance_get_guid(ent);
pdata = (query_coll_t)user_data;
pdata->guids = g_list_append(pdata->guids, guid);
}

View File

@ -26,16 +26,16 @@
#include "qofreference.h"
static void
entity_set_reference_cb(QofEntity *ent, gpointer user_data)
entity_set_reference_cb(QofInstance *ent, gpointer user_data)
{
void (*reference_setter) (QofEntity*, QofEntity*);
void (*choice_setter) (QofEntity*, QofEntity*);
void (*collect_setter)(QofEntity*, QofCollection*);
QofEntityReference *ref;
void (*reference_setter) (QofInstance*, QofInstance*);
void (*choice_setter) (QofInstance*, QofInstance*);
void (*collect_setter)(QofInstance*, QofCollection*);
QofInstanceReference *ref;
GList *book_ref_list;
QofCollection *coll;
QofIdType type;
QofEntity *reference;
QofInstance *reference;
QofBook *partial_book;
partial_book = (QofBook*)user_data;
@ -45,8 +45,8 @@ entity_set_reference_cb(QofEntity *ent, gpointer user_data)
book_ref_list = qof_book_get_data(partial_book, ENTITYREFERENCE);
while(book_ref_list)
{
ref = (QofEntityReference*)book_ref_list->data;
if(0 == guid_compare(ref->ref_guid, qof_entity_get_guid(ent)))
ref = (QofInstanceReference*)book_ref_list->data;
if(0 == guid_compare(ref->ref_guid, qof_instance_get_guid(ent)))
{
/* avoid setting the entity's own guid as a reference. */
book_ref_list = g_list_next(book_ref_list);
@ -56,7 +56,7 @@ entity_set_reference_cb(QofEntity *ent, gpointer user_data)
type = ref->param->param_type;
coll = qof_book_get_collection(partial_book, type);
reference = qof_collection_lookup_entity(coll, ref->ref_guid);
reference_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
reference_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
if((reference) && (reference_setter))
{
qof_begin_edit((QofInstance*)ent);
@ -66,10 +66,10 @@ entity_set_reference_cb(QofEntity *ent, gpointer user_data)
qof_commit_edit((QofInstance*)reference);
}
/* collect and choice handling */
collect_setter = (void(*)(QofEntity*, QofCollection*))ref->param->param_setfcn;
choice_setter = (void(*)(QofEntity*, QofEntity*))ref->param->param_setfcn;
collect_setter = (void(*)(QofInstance*, QofCollection*))ref->param->param_setfcn;
choice_setter = (void(*)(QofInstance*, QofInstance*))ref->param->param_setfcn;
if ((0 == safe_strcmp(ref->param->param_type, QOF_TYPE_COLLECT)) &&
(0 == guid_compare(qof_entity_get_guid(ent), ref->ent_guid)) &&
(0 == guid_compare(qof_instance_get_guid(ent), ref->ent_guid)) &&
(0 == safe_strcmp(ref->type, ent->e_type)))
{
QofCollection *temp_col;
@ -113,18 +113,18 @@ set_each_type(QofObject *obj, gpointer user_data)
qof_object_foreach(obj->e_type, book, entity_set_reference_cb, book);
}
static QofEntityReference*
create_reference(QofEntity *ent, const QofParam *param)
static QofInstanceReference*
create_reference(QofInstance *ent, const QofParam *param)
{
QofEntityReference *reference;
QofEntity *ref_ent;
QofInstanceReference *reference;
QofInstance *ref_ent;
const GUID *cm_guid;
char cm_sa[GUID_ENCODING_LENGTH + 1];
gchar *cm_string;
ref_ent = QOF_ENTITY(param->param_getfcn(ent, param));
ref_ent = QOF_INSTANCE(param->param_getfcn(ent, param));
if(!ref_ent) { return NULL; }
reference = g_new0(QofEntityReference, 1);
reference = g_new0(QofInstanceReference, 1);
reference->type = ent->e_type;
reference->ref_guid = g_new(GUID, 1);
reference->ent_guid = &ent->guid;
@ -133,7 +133,7 @@ create_reference(QofEntity *ent, const QofParam *param)
reference->choice_type = ref_ent->e_type;
}
reference->param = param;
cm_guid = qof_entity_get_guid(ref_ent);
cm_guid = qof_instance_get_guid(ref_ent);
guid_to_string_buff(cm_guid, cm_sa);
cm_string = g_strdup(cm_sa);
if(TRUE == string_to_guid(cm_string, reference->ref_guid)) {
@ -144,8 +144,8 @@ create_reference(QofEntity *ent, const QofParam *param)
return NULL;
}
QofEntityReference*
qof_entity_get_reference_from(QofEntity *ent, const QofParam *param)
QofInstanceReference*
qof_instance_get_reference_from(QofInstance *ent, const QofParam *param)
{
g_return_val_if_fail(param, NULL);
param = qof_class_get_parameter(ent->e_type, param->param_name);

View File

@ -39,15 +39,15 @@ a partial book and then convert the same book to a standard book.
Different backends have different requirements for a complete book - some
(like gnucash) are highly customised to that application - however all complete
QofBooks must be self-contained, only a partial book uses QofEntityReference.
QofBooks must be self-contained, only a partial book uses QofInstanceReference.
To retain the relationships between entities, including between a partial and
a complete book, QofEntityReference data is stored in the QofBook. This data
a complete book, QofInstanceReference data is stored in the QofBook. This data
should be read by backends that support partial books so that the exported
data contains the GUID and QofIdType of the referenced entity. Even if that
entity does not then exist within the partial book, it can be located when
the partial book is merged back into the original, complete, book. (Remember
that given the GUID and QofIdType of any QofEntity it is possible to uniquely
that given the GUID and QofIdType of any QofInstance it is possible to uniquely
identify that entity in another book.)
Entities in partial books may need to refer to the entities that remain within
@ -81,7 +81,7 @@ When the file is imported back in, the list needs to be rebuilt.
The QSF backend rebuilds the references by linking to real entities.
Other backends can process the list in similar ways.
The list stores the QofEntityReference to the referenced entity -
The list stores the QofInstanceReference to the referenced entity -
a struct that contains the GUID and the QofIdType of the referenced
entity as well as the parameter used to obtain the reference.
@ -102,7 +102,7 @@ It is used by the entity copy functions and by the QSF backend.
Creates a GList stored in the Book hashtable to contain
repeated references for a single entity.
*/
typedef struct qof_entity_reference {
typedef struct qof_instance_reference {
QofIdType choice_type;/**< Used when the reference is a QOF_TYPE_CHOICE type
- stores the actual type of the reference from the list of available choices. */
QofIdType type; /**< The type of the original entity -
@ -112,7 +112,7 @@ typedef struct qof_entity_reference {
const QofParam *param; /**< The parameter of the original entity to use
to get or set the reference. */
const GUID *ent_guid; /**< The GUID of the original entity. */
}QofEntityReference;
}QofInstanceReference;
/** \brief Adds a new reference to the partial book data hash.
@ -122,17 +122,17 @@ If the book is not already marked as partial, it will be marked as
partial.
*/
void
qof_session_update_reference_list(QofSession *session, QofEntityReference *reference);
qof_session_update_reference_list(QofSession *session, QofInstanceReference *reference);
/** Used as the key value for the QofBook data hash.
*
* Retrieved later by QSF (or any other suitable backend) to
* rebuild the references from the QofEntityReference struct
* rebuild the references from the QofInstanceReference struct
* that contains the QofIdType and GUID of the referenced entity
* of the original QofBook as well as the parameter data and the
* GUID of the original entity.
* */
#define ENTITYREFERENCE "QofEntityReference"
#define ENTITYREFERENCE "QofInstanceReference"
/** \brief Flag indicating a partial QofBook.
@ -143,11 +143,11 @@ books can be used to save this session.
#define PARTIAL_QOFBOOK "PartialQofBook"
/** \brief Read QofEntityReference data for this book and set values.
/** \brief Read QofInstanceReference data for this book and set values.
@param book The partial book containing the referenceList
The referenceList is a GList of QofEntityReference structures that contain
The referenceList is a GList of QofInstanceReference structures that contain
the GUID of each end of a reference. e.g. where one entity refers to another.
The referenceList is used in partial books to store relationships between
@ -173,14 +173,14 @@ void qof_book_set_references(QofBook *book);
been checked \b NOT to be QOF_TYPE_COLLECT or other known QOF types
because this function expects to return a single reference and
a collect parameter would need to return a list of references, other
parameters would not return a viable QofEntity. (A string cannot be
parameters would not return a viable QofInstance. (A string cannot be
cast to an entity.)
Used in the preparation of a partial QofBook when the known entity
(the one currently being copied into the partial book) refers to
any other entity, usually as a parent or child.
The routine calls the param_getfcn of the supplied parameter,
which must return an object (QofEntity*), not a known QOF data type, to
which must return an object (QofInstance*), not a known QOF data type, to
retrieve the referenced entity and therefore the GUID. The GUID of
both entities are stored in the reference which then needs to be added
to the reference list which is added to the partial book data hash.
@ -199,10 +199,10 @@ the integrity of the partial book during sequential copy operations.
@param ent The known entity.
@param param The parameter to use to get the referenced entity.
@return FALSE on error, otherwise a pointer to the QofEntityReference.
@return FALSE on error, otherwise a pointer to the QofInstanceReference.
*/
QofEntityReference*
qof_entity_get_reference_from(QofEntity *ent, const QofParam *param);
QofInstanceReference*
qof_instance_get_reference_from(QofInstance *ent, const QofParam *param);
/** @} */
/** @} */

View File

@ -38,7 +38,7 @@ struct _QofSession
* an Entity. NOTE: THIS IS NOT AN ENTITY! THE ONLY PART OF ENTITY
* THAT IS VALID IS E_TYPE!
*/
QofEntity entity;
QofInstance entity;
/* A book holds pointers to the various types of datasets.
* A session may have multiple books. */

View File

@ -305,15 +305,15 @@ qof_session_get_url (QofSession *session)
/* =============================================================== */
typedef struct qof_entity_copy_data {
QofEntity *from;
QofEntity *to;
typedef struct qof_instance_copy_data {
QofInstance *from;
QofInstance *to;
QofParam *param;
GList *referenceList;
GSList *param_list;
QofSession *new_session;
gboolean error;
}QofEntityCopyData;
}QofInstanceCopyData;
static void
qof_book_set_partial(QofBook *book)
@ -328,7 +328,7 @@ qof_book_set_partial(QofBook *book)
}
void
qof_session_update_reference_list(QofSession *session, QofEntityReference *reference)
qof_session_update_reference_list(QofSession *session, QofInstanceReference *reference)
{
QofBook *book;
GList *book_ref_list;
@ -341,12 +341,12 @@ qof_session_update_reference_list(QofSession *session, QofEntityReference *refer
}
static void
qof_entity_param_cb(QofParam *param, gpointer data)
qof_instance_param_cb(QofParam *param, gpointer data)
{
QofEntityCopyData *qecd;
QofInstanceCopyData *qecd;
g_return_if_fail(data != NULL);
qecd = (QofEntityCopyData*)data;
qecd = (QofInstanceCopyData*)data;
g_return_if_fail(param != NULL);
/* KVP doesn't need a set routine to be copied. */
if(0 == safe_strcmp(param->param_type, QOF_TYPE_KVP)) {
@ -359,24 +359,24 @@ qof_entity_param_cb(QofParam *param, gpointer data)
}
static void
col_ref_cb (QofEntity* ref_ent, gpointer user_data)
col_ref_cb (QofInstance* ref_ent, gpointer user_data)
{
QofEntityReference *ref;
QofEntityCopyData *qecd;
QofEntity *ent;
QofInstanceReference *ref;
QofInstanceCopyData *qecd;
QofInstance *ent;
const GUID *cm_guid;
char cm_sa[GUID_ENCODING_LENGTH + 1];
gchar *cm_string;
qecd = (QofEntityCopyData*)user_data;
qecd = (QofInstanceCopyData*)user_data;
ent = qecd->from;
ref = g_new0(QofEntityReference, 1);
ref = g_new0(QofInstanceReference, 1);
ref->type = ent->e_type;
ref->ref_guid = g_new(GUID, 1);
ref->ent_guid = &ent->guid;
ref->param = qof_class_get_parameter(ent->e_type,
qecd->param->param_name);
cm_guid = qof_entity_get_guid(ref_ent);
cm_guid = qof_instance_get_guid(ref_ent);
guid_to_string_buff(cm_guid, cm_sa);
cm_string = g_strdup(cm_sa);
if(TRUE == string_to_guid(cm_string, ref->ref_guid)) {
@ -386,11 +386,11 @@ col_ref_cb (QofEntity* ref_ent, gpointer user_data)
}
static void
qof_entity_foreach_copy(gpointer data, gpointer user_data)
qof_instance_foreach_copy(gpointer data, gpointer user_data)
{
QofEntity *importEnt, *targetEnt/*, *referenceEnt*/;
QofEntityCopyData *context;
QofEntityReference *reference;
QofInstance *importEnt, *targetEnt/*, *referenceEnt*/;
QofInstanceCopyData *context;
QofInstanceReference *reference;
gboolean registered_type;
/* cm_ prefix used for variables that hold the data to commit */
QofParam *cm_param;
@ -399,26 +399,26 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
KvpFrame *cm_kvp;
QofCollection *cm_col;
/* function pointers and variables for parameter getters that don't use pointers normally */
gnc_numeric cm_numeric, (*numeric_getter) (QofEntity*, QofParam*);
double cm_double, (*double_getter) (QofEntity*, QofParam*);
gboolean cm_boolean, (*boolean_getter) (QofEntity*, QofParam*);
gint32 cm_i32, (*int32_getter) (QofEntity*, QofParam*);
gint64 cm_i64, (*int64_getter) (QofEntity*, QofParam*);
Timespec cm_date, (*date_getter) (QofEntity*, QofParam*);
gnc_numeric cm_numeric, (*numeric_getter) (QofInstance*, QofParam*);
double cm_double, (*double_getter) (QofInstance*, QofParam*);
gboolean cm_boolean, (*boolean_getter) (QofInstance*, QofParam*);
gint32 cm_i32, (*int32_getter) (QofInstance*, QofParam*);
gint64 cm_i64, (*int64_getter) (QofInstance*, QofParam*);
Timespec cm_date, (*date_getter) (QofInstance*, QofParam*);
/* function pointers to the parameter setters */
void (*string_setter) (QofEntity*, const char*);
void (*date_setter) (QofEntity*, Timespec);
void (*numeric_setter) (QofEntity*, gnc_numeric);
void (*guid_setter) (QofEntity*, const GUID*);
void (*double_setter) (QofEntity*, double);
void (*boolean_setter) (QofEntity*, gboolean);
void (*i32_setter) (QofEntity*, gint32);
void (*i64_setter) (QofEntity*, gint64);
void (*char_setter) (QofEntity*, char*);
void (*kvp_frame_setter) (QofEntity*, KvpFrame*);
void (*string_setter) (QofInstance*, const char*);
void (*date_setter) (QofInstance*, Timespec);
void (*numeric_setter) (QofInstance*, gnc_numeric);
void (*guid_setter) (QofInstance*, const GUID*);
void (*double_setter) (QofInstance*, double);
void (*boolean_setter) (QofInstance*, gboolean);
void (*i32_setter) (QofInstance*, gint32);
void (*i64_setter) (QofInstance*, gint64);
void (*char_setter) (QofInstance*, char*);
void (*kvp_frame_setter) (QofInstance*, KvpFrame*);
g_return_if_fail(user_data != NULL);
context = (QofEntityCopyData*) user_data;
context = (QofInstanceCopyData*) user_data;
cm_date.tv_nsec = 0;
cm_date.tv_sec = 0;
importEnt = context->from;
@ -430,63 +430,63 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
if(safe_strcmp(cm_param->param_type, QOF_TYPE_STRING) == 0) {
cm_string = (gchar*)cm_param->param_getfcn(importEnt, cm_param);
if(cm_string) {
string_setter = (void(*)(QofEntity*, const char*))cm_param->param_setfcn;
string_setter = (void(*)(QofInstance*, const char*))cm_param->param_setfcn;
if(string_setter != NULL) { string_setter(targetEnt, cm_string); }
}
registered_type = TRUE;
}
if(safe_strcmp(cm_param->param_type, QOF_TYPE_DATE) == 0) {
date_getter = (Timespec (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
date_getter = (Timespec (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
cm_date = date_getter(importEnt, cm_param);
date_setter = (void(*)(QofEntity*, Timespec))cm_param->param_setfcn;
date_setter = (void(*)(QofInstance*, Timespec))cm_param->param_setfcn;
if(date_setter != NULL) { date_setter(targetEnt, cm_date); }
registered_type = TRUE;
}
if((safe_strcmp(cm_param->param_type, QOF_TYPE_NUMERIC) == 0) ||
(safe_strcmp(cm_param->param_type, QOF_TYPE_DEBCRED) == 0)) {
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*))cm_param->param_getfcn;
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*))cm_param->param_getfcn;
cm_numeric = numeric_getter(importEnt, cm_param);
numeric_setter = (void(*)(QofEntity*, gnc_numeric))cm_param->param_setfcn;
numeric_setter = (void(*)(QofInstance*, gnc_numeric))cm_param->param_setfcn;
if(numeric_setter != NULL) { numeric_setter(targetEnt, cm_numeric); }
registered_type = TRUE;
}
if(safe_strcmp(cm_param->param_type, QOF_TYPE_GUID) == 0) {
cm_guid = (const GUID*)cm_param->param_getfcn(importEnt, cm_param);
guid_setter = (void(*)(QofEntity*, const GUID*))cm_param->param_setfcn;
guid_setter = (void(*)(QofInstance*, const GUID*))cm_param->param_setfcn;
if(guid_setter != NULL) { guid_setter(targetEnt, cm_guid); }
registered_type = TRUE;
}
if(safe_strcmp(cm_param->param_type, QOF_TYPE_INT32) == 0) {
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_i32 = int32_getter(importEnt, cm_param);
i32_setter = (void(*)(QofEntity*, gint32))cm_param->param_setfcn;
i32_setter = (void(*)(QofInstance*, gint32))cm_param->param_setfcn;
if(i32_setter != NULL) { i32_setter(targetEnt, cm_i32); }
registered_type = TRUE;
}
if(safe_strcmp(cm_param->param_type, QOF_TYPE_INT64) == 0) {
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_i64 = int64_getter(importEnt, cm_param);
i64_setter = (void(*)(QofEntity*, gint64))cm_param->param_setfcn;
i64_setter = (void(*)(QofInstance*, gint64))cm_param->param_setfcn;
if(i64_setter != NULL) { i64_setter(targetEnt, cm_i64); }
registered_type = TRUE;
}
if(safe_strcmp(cm_param->param_type, QOF_TYPE_DOUBLE) == 0) {
double_getter = (double (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
double_getter = (double (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_double = double_getter(importEnt, cm_param);
double_setter = (void(*)(QofEntity*, double))cm_param->param_setfcn;
double_setter = (void(*)(QofInstance*, double))cm_param->param_setfcn;
if(double_setter != NULL) { double_setter(targetEnt, cm_double); }
registered_type = TRUE;
}
if(safe_strcmp(cm_param->param_type, QOF_TYPE_BOOLEAN) == 0){
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) cm_param->param_getfcn;
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) cm_param->param_getfcn;
cm_boolean = boolean_getter(importEnt, cm_param);
boolean_setter = (void(*)(QofEntity*, gboolean))cm_param->param_setfcn;
boolean_setter = (void(*)(QofInstance*, gboolean))cm_param->param_setfcn;
if(boolean_setter != NULL) { boolean_setter(targetEnt, cm_boolean); }
registered_type = TRUE;
}
if(safe_strcmp(cm_param->param_type, QOF_TYPE_KVP) == 0) {
cm_kvp = (KvpFrame*)cm_param->param_getfcn(importEnt,cm_param);
kvp_frame_setter = (void(*)(QofEntity*, KvpFrame*))cm_param->param_setfcn;
kvp_frame_setter = (void(*)(QofInstance*, KvpFrame*))cm_param->param_setfcn;
if(kvp_frame_setter != NULL) { kvp_frame_setter(targetEnt, cm_kvp); }
else
{
@ -500,7 +500,7 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
}
if(safe_strcmp(cm_param->param_type, QOF_TYPE_CHAR) == 0) {
cm_char = (gchar*)cm_param->param_getfcn(importEnt,cm_param);
char_setter = (void(*)(QofEntity*, char*))cm_param->param_setfcn;
char_setter = (void(*)(QofInstance*, char*))cm_param->param_setfcn;
if(char_setter != NULL) { char_setter(targetEnt, cm_char); }
registered_type = TRUE;
}
@ -514,10 +514,10 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
registered_type = TRUE;
}
if(registered_type == FALSE) {
/* referenceEnt = QOF_ENTITY(cm_param->param_getfcn(importEnt, cm_param));
/* referenceEnt = QOF_INSTANCE(cm_param->param_getfcn(importEnt, cm_param));
if(!referenceEnt) { return; }
if(!referenceEnt->e_type) { return; }*/
reference = qof_entity_get_reference_from(importEnt, cm_param);
reference = qof_instance_get_reference_from(importEnt, cm_param);
if(reference) {
qof_session_update_reference_list(context->new_session, reference);
}
@ -525,9 +525,9 @@ qof_entity_foreach_copy(gpointer data, gpointer user_data)
}
static gboolean
qof_entity_guid_match(QofSession *new_session, QofEntity *original)
qof_instance_guid_match(QofSession *new_session, QofInstance *original)
{
QofEntity *copy;
QofInstance *copy;
const GUID *g;
QofIdTypeConst type;
QofBook *targetBook;
@ -537,7 +537,7 @@ qof_entity_guid_match(QofSession *new_session, QofEntity *original)
g_return_val_if_fail(original != NULL, FALSE);
targetBook = qof_session_get_book(new_session);
g_return_val_if_fail(targetBook != NULL, FALSE);
g = qof_entity_get_guid(original);
g = qof_instance_get_guid(original);
type = g_strdup(original->e_type);
coll = qof_book_get_collection(targetBook, type);
copy = qof_collection_lookup_entity(coll, g);
@ -546,19 +546,19 @@ qof_entity_guid_match(QofSession *new_session, QofEntity *original)
}
static void
qof_entity_list_foreach(gpointer data, gpointer user_data)
qof_instance_list_foreach(gpointer data, gpointer user_data)
{
QofEntityCopyData *qecd;
QofEntity *original;
QofInstanceCopyData *qecd;
QofInstance *original;
QofInstance *inst;
QofBook *book;
const GUID *g;
g_return_if_fail(data != NULL);
original = QOF_ENTITY(data);
original = QOF_INSTANCE(data);
g_return_if_fail(user_data != NULL);
qecd = (QofEntityCopyData*)user_data;
if(qof_entity_guid_match(qecd->new_session, original)) { return; }
qecd = (QofInstanceCopyData*)user_data;
if(qof_instance_guid_match(qecd->new_session, original)) { return; }
qecd->from = original;
if(!qof_object_compliance(original->e_type, FALSE))
{
@ -573,69 +573,69 @@ qof_entity_list_foreach(gpointer data, gpointer user_data)
qecd->error = TRUE;
return;
}
qecd->to = &inst->entity;
g = qof_entity_get_guid(original);
qof_entity_set_guid(qecd->to, g);
qecd->to = inst;
g = qof_instance_get_guid(original);
qof_instance_set_guid(qecd->to, g);
if(qecd->param_list != NULL) {
g_slist_free(qecd->param_list);
qecd->param_list = NULL;
}
qof_class_param_foreach(original->e_type, qof_entity_param_cb, qecd);
qof_class_param_foreach(original->e_type, qof_instance_param_cb, qecd);
qof_begin_edit(inst);
g_slist_foreach(qecd->param_list, qof_entity_foreach_copy, qecd);
g_slist_foreach(qecd->param_list, qof_instance_foreach_copy, qecd);
qof_commit_edit(inst);
}
static void
qof_entity_coll_foreach(QofEntity *original, gpointer user_data)
qof_instance_coll_foreach(QofInstance *original, gpointer user_data)
{
QofEntityCopyData *qecd;
QofInstanceCopyData *qecd;
const GUID *g;
QofBook *targetBook;
QofCollection *coll;
QofEntity *copy;
QofInstance *copy;
g_return_if_fail(user_data != NULL);
copy = NULL;
qecd = (QofEntityCopyData*)user_data;
qecd = (QofInstanceCopyData*)user_data;
targetBook = qof_session_get_book(qecd->new_session);
g = qof_entity_get_guid(original);
g = qof_instance_get_guid(original);
coll = qof_book_get_collection(targetBook, original->e_type);
copy = qof_collection_lookup_entity(coll, g);
if(copy) { qecd->error = TRUE; }
}
static void
qof_entity_coll_copy(QofEntity *original, gpointer user_data)
qof_instance_coll_copy(QofInstance *original, gpointer user_data)
{
QofEntityCopyData *qecd;
QofInstanceCopyData *qecd;
QofBook *book;
QofInstance *inst;
const GUID *g;
g_return_if_fail(user_data != NULL);
qecd = (QofEntityCopyData*)user_data;
qecd = (QofInstanceCopyData*)user_data;
book = qof_session_get_book(qecd->new_session);
if(!qof_object_compliance(original->e_type, TRUE)) { return; }
inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
qecd->to = &inst->entity;
qecd->to = inst;
qecd->from = original;
g = qof_entity_get_guid(original);
qof_entity_set_guid(qecd->to, g);
g = qof_instance_get_guid(original);
qof_instance_set_guid(qecd->to, g);
qof_begin_edit(inst);
g_slist_foreach(qecd->param_list, qof_entity_foreach_copy, qecd);
g_slist_foreach(qecd->param_list, qof_instance_foreach_copy, qecd);
qof_commit_edit(inst);
}
gboolean
qof_entity_copy_to_session(QofSession* new_session, QofEntity* original)
qof_instance_copy_to_session(QofSession* new_session, QofInstance* original)
{
QofEntityCopyData qecd;
QofInstanceCopyData qecd;
QofInstance *inst;
QofBook *book;
if(!new_session || !original) { return FALSE; }
if(qof_entity_guid_match(new_session, original)) { return FALSE; }
if(qof_instance_guid_match(new_session, original)) { return FALSE; }
if(!qof_object_compliance(original->e_type, TRUE)) { return FALSE; }
qof_event_suspend();
qecd.param_list = NULL;
@ -643,31 +643,31 @@ qof_entity_copy_to_session(QofSession* new_session, QofEntity* original)
qecd.new_session = new_session;
qof_book_set_partial(book);
inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
qecd.to = &inst->entity;
qecd.to = inst;
qecd.from = original;
qof_entity_set_guid(qecd.to, qof_entity_get_guid(original));
qof_instance_set_guid(qecd.to, qof_instance_get_guid(original));
qof_begin_edit(inst);
qof_class_param_foreach(original->e_type, qof_entity_param_cb, &qecd);
qof_class_param_foreach(original->e_type, qof_instance_param_cb, &qecd);
qof_commit_edit(inst);
if(g_slist_length(qecd.param_list) == 0) { return FALSE; }
g_slist_foreach(qecd.param_list, qof_entity_foreach_copy, &qecd);
g_slist_foreach(qecd.param_list, qof_instance_foreach_copy, &qecd);
g_slist_free(qecd.param_list);
qof_event_resume();
return TRUE;
}
gboolean qof_entity_copy_list(QofSession *new_session, GList *entity_list)
gboolean qof_instance_copy_list(QofSession *new_session, GList *entity_list)
{
QofEntityCopyData *qecd;
QofInstanceCopyData *qecd;
if(!new_session || !entity_list) { return FALSE; }
ENTER (" list=%d", g_list_length(entity_list));
qecd = g_new0(QofEntityCopyData, 1);
qecd = g_new0(QofInstanceCopyData, 1);
qof_event_suspend();
qecd->param_list = NULL;
qecd->new_session = new_session;
qof_book_set_partial(qof_session_get_book(new_session));
g_list_foreach(entity_list, qof_entity_list_foreach, qecd);
g_list_foreach(entity_list, qof_instance_list_foreach, qecd);
qof_event_resume();
if(qecd->error)
{
@ -679,9 +679,9 @@ gboolean qof_entity_copy_list(QofSession *new_session, GList *entity_list)
}
gboolean
qof_entity_copy_coll(QofSession *new_session, QofCollection *entity_coll)
qof_instance_copy_coll(QofSession *new_session, QofCollection *entity_coll)
{
QofEntityCopyData qecd;
QofInstanceCopyData qecd;
g_return_val_if_fail(new_session, FALSE);
if(!entity_coll) { return FALSE; }
@ -689,10 +689,10 @@ qof_entity_copy_coll(QofSession *new_session, QofCollection *entity_coll)
qecd.param_list = NULL;
qecd.new_session = new_session;
qof_book_set_partial(qof_session_get_book(qecd.new_session));
qof_collection_foreach(entity_coll, qof_entity_coll_foreach, &qecd);
qof_collection_foreach(entity_coll, qof_instance_coll_foreach, &qecd);
qof_class_param_foreach(qof_collection_get_type(entity_coll),
qof_entity_param_cb, &qecd);
qof_collection_foreach(entity_coll, qof_entity_coll_copy, &qecd);
qof_instance_param_cb, &qecd);
qof_collection_foreach(entity_coll, qof_instance_coll_copy, &qecd);
if(qecd.param_list != NULL) { g_slist_free(qecd.param_list); }
qof_event_resume();
return TRUE;
@ -707,25 +707,25 @@ struct recurse_s
};
static void
recurse_collection_cb (QofEntity *ent, gpointer user_data)
recurse_collection_cb (QofInstance *ent, gpointer user_data)
{
struct recurse_s *store;
if(user_data == NULL) { return; }
store = (struct recurse_s*)user_data;
if(!ent || !store) { return; }
store->success = qof_entity_copy_to_session(store->session, ent);
store->success = qof_instance_copy_to_session(store->session, ent);
if(store->success) {
store->ent_list = g_list_append(store->ent_list, ent);
}
}
static void
recurse_ent_cb(QofEntity *ent, gpointer user_data)
recurse_ent_cb(QofInstance *ent, gpointer user_data)
{
GList *ref_list, *i, *j, *ent_list, *child_list;
QofParam *ref_param;
QofEntity *ref_ent, *child_ent;
QofInstance *ref_ent, *child_ent;
QofSession *session;
struct recurse_s *store;
gboolean success;
@ -756,17 +756,17 @@ recurse_ent_cb(QofEntity *ent, gpointer user_data)
}
continue;
}
ref_ent = QOF_ENTITY(ref_param->param_getfcn(ent, ref_param));
ref_ent = QOF_INSTANCE(ref_param->param_getfcn(ent, ref_param));
if((ref_ent)&&(ref_ent->e_type))
{
store->success = qof_entity_copy_to_session(session, ref_ent);
store->success = qof_instance_copy_to_session(session, ref_ent);
if(store->success) { ent_list = g_list_append(ent_list, ref_ent); }
}
}
for(i = ent_list; i != NULL; i = i->next)
{
if(i->data == NULL) { continue; }
child_ent = QOF_ENTITY(i->data);
child_ent = QOF_INSTANCE(i->data);
if(child_ent == NULL) { continue; }
ref_list = qof_class_get_referenceList(child_ent->e_type);
for(j = ref_list; j != NULL; j = j->next)
@ -776,7 +776,7 @@ recurse_ent_cb(QofEntity *ent, gpointer user_data)
ref_ent = ref_param->param_getfcn(child_ent, ref_param);
if(ref_ent != NULL)
{
success = qof_entity_copy_to_session(session, ref_ent);
success = qof_instance_copy_to_session(session, ref_ent);
if(success) { child_list = g_list_append(child_list, ref_ent); }
}
}
@ -784,7 +784,7 @@ recurse_ent_cb(QofEntity *ent, gpointer user_data)
for(i = child_list; i != NULL; i = i->next)
{
if(i->data == NULL) { continue; }
ref_ent = QOF_ENTITY(i->data);
ref_ent = QOF_INSTANCE(i->data);
if(ref_ent == NULL) { continue; }
ref_list = qof_class_get_referenceList(ref_ent->e_type);
for(j = ref_list; j != NULL; j = j->next)
@ -794,14 +794,14 @@ recurse_ent_cb(QofEntity *ent, gpointer user_data)
child_ent = ref_param->param_getfcn(ref_ent, ref_param);
if(child_ent != NULL)
{
qof_entity_copy_to_session(session, child_ent);
qof_instance_copy_to_session(session, child_ent);
}
}
}
}
gboolean
qof_entity_copy_coll_r(QofSession *new_session, QofCollection *coll)
qof_instance_copy_coll_r(QofSession *new_session, QofCollection *coll)
{
struct recurse_s store;
gboolean success;
@ -812,12 +812,12 @@ qof_entity_copy_coll_r(QofSession *new_session, QofCollection *coll)
store.success = success;
store.ent_list = NULL;
store.ref_list = qof_class_get_referenceList(qof_collection_get_type(coll));
success = qof_entity_copy_coll(new_session, coll);
success = qof_instance_copy_coll(new_session, coll);
if(success){ qof_collection_foreach(coll, recurse_ent_cb, &store); }
return success;
}
gboolean qof_entity_copy_one_r(QofSession *new_session, QofEntity *ent)
gboolean qof_instance_copy_one_r(QofSession *new_session, QofInstance *ent)
{
struct recurse_s store;
QofCollection *coll;
@ -828,7 +828,7 @@ gboolean qof_entity_copy_one_r(QofSession *new_session, QofEntity *ent)
success = TRUE;
store.success = success;
store.ref_list = qof_class_get_referenceList(ent->e_type);
success = qof_entity_copy_to_session(new_session, ent);
success = qof_instance_copy_to_session(new_session, ent);
if(success == TRUE) {
coll = qof_book_get_collection(qof_session_get_book(new_session), ent->e_type);
if(coll) { qof_collection_foreach(coll, recurse_ent_cb, &store); }

View File

@ -264,7 +264,7 @@ using the GnuCash XML v2 file backend will be switched to QSF.
Copied entities are identical to the source entity, all parameters
defined with ::QofAccessFunc and ::QofSetterFunc in QOF are copied
and the ::GUID of the original ::QofEntity is set in the new entity.
and the ::GUID of the original ::QofInstance is set in the new entity.
Sessions containing copied entities are intended for use
as mechanisms for data export.
@ -280,19 +280,19 @@ see \ref BookMerge
*/
/** \brief Copy a single QofEntity to another session
/** \brief Copy a single QofInstance to another session
Checks first that no entity in the session book contains
the GUID of the source entity.
@param new_session - the target session
@param original - the QofEntity* to copy
@param original - the QofInstance* to copy
@return FALSE without copying if the session contains an entity
with the same GUID already, otherwise TRUE.
*/
gboolean qof_entity_copy_to_session(QofSession* new_session, QofEntity* original);
gboolean qof_instance_copy_to_session(QofSession* new_session, QofInstance* original);
/** @brief Copy a GList of entities to another session
@ -301,18 +301,18 @@ with the same GUID as any of the source entities - there is
no support for handling collisions, instead use \ref BookMerge
Note that the GList (e.g. from ::qof_sql_query_run) can contain
QofEntity pointers of any ::QofIdType, in any sequence. As long
as all members of the list are ::QofEntity*, and all GUID's are
QofInstance pointers of any ::QofIdType, in any sequence. As long
as all members of the list are ::QofInstance*, and all GUID's are
unique, the list can be copied.
@param new_session - the target session
@param entity_list - a GList of QofEntity pointers of any type(s).
@param entity_list - a GList of QofInstance pointers of any type(s).
@return FALSE, without copying, if new_session contains any entities
with the same GUID. Otherwise TRUE.
*/
gboolean qof_entity_copy_list(QofSession *new_session, GList *entity_list);
gboolean qof_instance_copy_list(QofSession *new_session, GList *entity_list);
/** @brief Copy a QofCollection of entities.
@ -327,12 +327,12 @@ no support for handling collisions - instead, use \ref BookMerge
with the same GUID. Otherwise TRUE.
*/
gboolean qof_entity_copy_coll(QofSession *new_session, QofCollection *entity_coll);
gboolean qof_instance_copy_coll(QofSession *new_session, QofCollection *entity_coll);
/** \brief Recursively copy a collection of entities to a session.
\note This function creates a <b>partial QofBook</b>. See
::qof_entity_copy_to_session for more information.
::qof_instance_copy_to_session for more information.
The QofBook in the new_session must \b not contain any entities
with the same GUID as any entities to be copied - there is
@ -341,7 +341,7 @@ no support for handling collisions - instead, use \ref BookMerge
Objects can be defined solely in terms of QOF data types or
as a mix of data types and other objects, which may in turn
include other objects. These references can be copied recursively
down to the third level. See ::QofEntityReference.
down to the third level. See ::QofInstanceReference.
\note This is a deep recursive copy - every referenced entity is copied
to the new session, including all parameters. The starting point is all
@ -358,7 +358,7 @@ one of the references fails to copy.
*/
gboolean
qof_entity_copy_coll_r(QofSession *new_session, QofCollection *coll);
qof_instance_copy_coll_r(QofSession *new_session, QofCollection *coll);
/** \brief Recursively copy a single entity to a new session.
@ -369,7 +369,7 @@ copied.
This is a deep copy - all parameters of all referenced entities are copied. If
the top level entity has no references, this is identical to
::qof_entity_copy_to_session.
::qof_instance_copy_to_session.
@param ent A single entity that may or may not have references.
@ -380,7 +380,7 @@ the top level entity has no references, this is identical to
one of the references fails to copy.
*/
gboolean
qof_entity_copy_one_r(QofSession *new_session, QofEntity *ent);
qof_instance_copy_one_r(QofSession *new_session, QofInstance *ent);
/** @}
*/

View File

@ -52,7 +52,7 @@ struct _QofSqlQuery
char * single_global_tablename;
KvpFrame *kvp_join;
GList *param_list;
QofEntity *inserted_entity;
QofInstance *inserted_entity;
};
/* ========================================================== */
@ -573,7 +573,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
QofIdTypeConst type;
sql_insert_statement *sis;
gboolean registered_type;
QofEntity *ent;
QofInstance *ent;
struct tm query_time;
time_t query_time_t;
/* cm_ prefix used for variables that hold the data to commit */
@ -588,15 +588,15 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
/* KvpFrame *cm_kvp;
KvpValue *cm_value;
KvpValueType cm_type;*/
void (*string_setter) (QofEntity*, const char*);
void (*date_setter) (QofEntity*, Timespec);
void (*numeric_setter) (QofEntity*, gnc_numeric);
void (*double_setter) (QofEntity*, double);
void (*boolean_setter) (QofEntity*, gboolean);
void (*i32_setter) (QofEntity*, gint32);
void (*i64_setter) (QofEntity*, gint64);
void (*char_setter) (QofEntity*, char);
/* void (*kvp_frame_setter) (QofEntity*, KvpFrame*);*/
void (*string_setter) (QofInstance*, const char*);
void (*date_setter) (QofInstance*, Timespec);
void (*numeric_setter) (QofInstance*, gnc_numeric);
void (*double_setter) (QofInstance*, double);
void (*boolean_setter) (QofInstance*, gboolean);
void (*i32_setter) (QofInstance*, gint32);
void (*i64_setter) (QofInstance*, gint64);
void (*char_setter) (QofInstance*, char);
/* void (*kvp_frame_setter) (QofInstance*, KvpFrame*);*/
g_return_if_fail(param || insert_string || query);
ent = query->inserted_entity;
@ -606,12 +606,12 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
ENTER (" param=%s param_type=%s type=%s content=%s",
param->param_name, param->param_type, type, insert_string);
if(safe_strcmp(param->param_type, QOF_TYPE_STRING) == 0) {
string_setter = (void(*)(QofEntity*, const char*))param->param_setfcn;
string_setter = (void(*)(QofInstance*, const char*))param->param_setfcn;
if(string_setter != NULL) { string_setter(ent, insert_string); }
registered_type = TRUE;
}
if(safe_strcmp(param->param_type, QOF_TYPE_DATE) == 0) {
date_setter = (void(*)(QofEntity*, Timespec))param->param_setfcn;
date_setter = (void(*)(QofInstance*, Timespec))param->param_setfcn;
strptime(insert_string, QOF_UTC_DATE_FORMAT, &query_time);
query_time_t = mktime(&query_time);
timespecFromTime_t(&cm_date, query_time_t);
@ -619,7 +619,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
}
if((safe_strcmp(param->param_type, QOF_TYPE_NUMERIC) == 0) ||
(safe_strcmp(param->param_type, QOF_TYPE_DEBCRED) == 0)) {
numeric_setter = (void(*)(QofEntity*, gnc_numeric))param->param_setfcn;
numeric_setter = (void(*)(QofInstance*, gnc_numeric))param->param_setfcn;
string_to_gnc_numeric(insert_string, &cm_numeric);
if(numeric_setter != NULL) { numeric_setter(ent, cm_numeric); }
}
@ -633,10 +633,10 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
/* reference_type = xmlGetProp(node, QSF_OBJECT_TYPE);
if(0 == safe_strcmp(QOF_PARAM_GUID, reference_type))
{
qof_entity_set_guid(qsf_ent, cm_guid);
qof_instance_set_guid(qsf_ent, cm_guid);
}
else {
reference = qof_entity_get_reference_from(qsf_ent, cm_param);
reference = qof_instance_get_reference_from(qsf_ent, cm_param);
if(reference) {
params->referenceList = g_list_append(params->referenceList, reference);
}
@ -646,7 +646,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
errno = 0;
cm_i32 = (gint32)strtol (insert_string, &tail, 0);
if(errno == 0) {
i32_setter = (void(*)(QofEntity*, gint32))param->param_setfcn;
i32_setter = (void(*)(QofInstance*, gint32))param->param_setfcn;
if(i32_setter != NULL) { i32_setter(ent, cm_i32); }
}
else
@ -663,7 +663,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
errno = 0;
cm_i64 = strtoll(insert_string, &tail, 0);
if(errno == 0) {
i64_setter = (void(*)(QofEntity*, gint64))param->param_setfcn;
i64_setter = (void(*)(QofInstance*, gint64))param->param_setfcn;
if(i64_setter != NULL) { i64_setter(ent, cm_i64); }
}
else
@ -680,7 +680,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
errno = 0;
cm_double = strtod(insert_string, &tail);
if(errno == 0) {
double_setter = (void(*)(QofEntity*, double))param->param_setfcn;
double_setter = (void(*)(QofInstance*, double))param->param_setfcn;
if(double_setter != NULL) { double_setter(ent, cm_double); }
}
}
@ -691,7 +691,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
cm_boolean = TRUE;
}
else { cm_boolean = FALSE; }
boolean_setter = (void(*)(QofEntity*, gboolean))param->param_setfcn;
boolean_setter = (void(*)(QofInstance*, gboolean))param->param_setfcn;
if(boolean_setter != NULL) { boolean_setter(ent, cm_boolean); }
}
if(safe_strcmp(param->param_type, QOF_TYPE_KVP) == 0) {
@ -699,7 +699,7 @@ qof_sql_insertCB(const QofParam *param, const gchar *insert_string, QofSqlQuery
}
if(safe_strcmp(param->param_type, QOF_TYPE_CHAR) == 0) {
cm_char = *insert_string;
char_setter = (void(*)(QofEntity*, char))param->param_setfcn;
char_setter = (void(*)(QofInstance*, char))param->param_setfcn;
if(char_setter != NULL) { char_setter(ent, cm_char); }
}
LEAVE (" ");
@ -725,7 +725,7 @@ qof_query_set_insert_table(QofSqlQuery *query)
}
}
static QofEntity*
static QofInstance*
qof_query_insert(QofSqlQuery *query)
{
GList *field_list, *value_list, *cur;
@ -755,7 +755,7 @@ qof_query_insert(QofSqlQuery *query)
LEAVE (" unable to create instance of type %s", type);
return NULL;
}
query->inserted_entity = &inst->entity;
query->inserted_entity = inst;
value_list = sis->values;
for (field_list = sis->fields; field_list != NULL; field_list = field_list->next)
{

View File

@ -62,7 +62,7 @@ search loop, aka a 'join', which is not currently supported in the
underlying QofQuery code.
However, by repeating queries and adding the entities to a new session using
::qof_entity_copy_list, a series of queries can be added to a single
::qof_instance_copy_list, a series of queries can be added to a single
book. e.g. You can insert multiple entities and save out as a QSF XML
file or use multiple SELECT queries to build a precise list - this
can be used to replicate most of the functionality of a SQL join.
@ -77,7 +77,7 @@ When combined with a foreach callback on the value of param_id for each
entity in the QofBook, you can produce the effect of a join from running
the two SELECT queries for each value of param_id held in 'value'.
See ::QofEntityForeachCB and ::qof_object_foreach.
See ::QofInstanceForeachCB and ::qof_object_foreach.
Date queries handle full date and time strings, using the format
exported by the QSF backend. To query dates and times, convert

View File

@ -306,7 +306,7 @@ qof_commit_edit_part2(QofInstance *inst,
}
if (dirty && qof_get_alt_dirty_mode() &&
!(inst->infant && inst->do_free)) {
qof_collection_mark_dirty(inst->entity.collection);
qof_collection_mark_dirty(inst->collection);
qof_book_mark_dirty(inst->book);
}
inst->infant = FALSE;
@ -397,7 +397,7 @@ qof_util_string_cache_insert(gconstpointer key)
}
gchar*
qof_util_param_as_string(QofEntity *ent, QofParam *param)
qof_util_param_as_string(QofInstance *ent, QofParam *param)
{
gchar *param_string, param_date[MAX_DATE_LENGTH];
gchar param_sa[GUID_ENCODING_LENGTH + 1];
@ -405,13 +405,13 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
QofType paramType;
const GUID *param_guid;
time_t param_t;
gnc_numeric param_numeric, (*numeric_getter) (QofEntity*, QofParam*);
Timespec param_ts, (*date_getter) (QofEntity*, QofParam*);
double param_double, (*double_getter) (QofEntity*, QofParam*);
gboolean param_boolean, (*boolean_getter) (QofEntity*, QofParam*);
gint32 param_i32, (*int32_getter) (QofEntity*, QofParam*);
gint64 param_i64, (*int64_getter) (QofEntity*, QofParam*);
gchar param_char, (*char_getter) (QofEntity*, QofParam*);
gnc_numeric param_numeric, (*numeric_getter) (QofInstance*, QofParam*);
Timespec param_ts, (*date_getter) (QofInstance*, QofParam*);
double param_double, (*double_getter) (QofInstance*, QofParam*);
gboolean param_boolean, (*boolean_getter) (QofInstance*, QofParam*);
gint32 param_i32, (*int32_getter) (QofInstance*, QofParam*);
gint64 param_i64, (*int64_getter) (QofInstance*, QofParam*);
gchar param_char, (*char_getter) (QofInstance*, QofParam*);
param_string = NULL;
known_type = FALSE;
@ -423,7 +423,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_DATE) == 0) {
date_getter = (Timespec (*)(QofEntity*, QofParam*))param->param_getfcn;
date_getter = (Timespec (*)(QofInstance*, QofParam*))param->param_getfcn;
param_ts = date_getter(ent, param);
param_t = timespecToTime_t(param_ts);
strftime(param_date, MAX_DATE_LENGTH,
@ -434,7 +434,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
}
if((safe_strcmp(paramType, QOF_TYPE_NUMERIC) == 0) ||
(safe_strcmp(paramType, QOF_TYPE_DEBCRED) == 0)) {
numeric_getter = (gnc_numeric (*)(QofEntity*, QofParam*)) param->param_getfcn;
numeric_getter = (gnc_numeric (*)(QofInstance*, QofParam*)) param->param_getfcn;
param_numeric = numeric_getter(ent, param);
param_string = g_strdup(gnc_numeric_to_string(param_numeric));
known_type = TRUE;
@ -448,28 +448,28 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_INT32) == 0) {
int32_getter = (gint32 (*)(QofEntity*, QofParam*)) param->param_getfcn;
int32_getter = (gint32 (*)(QofInstance*, QofParam*)) param->param_getfcn;
param_i32 = int32_getter(ent, param);
param_string = g_strdup_printf("%d", param_i32);
known_type = TRUE;
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_INT64) == 0) {
int64_getter = (gint64 (*)(QofEntity*, QofParam*)) param->param_getfcn;
int64_getter = (gint64 (*)(QofInstance*, QofParam*)) param->param_getfcn;
param_i64 = int64_getter(ent, param);
param_string = g_strdup_printf("%"G_GINT64_FORMAT, param_i64);
known_type = TRUE;
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_DOUBLE) == 0) {
double_getter = (double (*)(QofEntity*, QofParam*)) param->param_getfcn;
double_getter = (double (*)(QofInstance*, QofParam*)) param->param_getfcn;
param_double = double_getter(ent, param);
param_string = g_strdup_printf("%f", param_double);
known_type = TRUE;
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_BOOLEAN) == 0){
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) param->param_getfcn;
boolean_getter = (gboolean (*)(QofInstance*, QofParam*)) param->param_getfcn;
param_boolean = boolean_getter(ent, param);
/* Boolean values need to be lowercase for QSF validation. */
if(param_boolean == TRUE) { param_string = g_strdup("true"); }
@ -491,7 +491,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
return param_string;
}
if(safe_strcmp(paramType, QOF_TYPE_CHAR) == 0) {
char_getter = (gchar (*)(QofEntity*, QofParam*)) param->param_getfcn;
char_getter = (gchar (*)(QofInstance*, QofParam*)) param->param_getfcn;
param_char = char_getter(ent, param);
known_type = TRUE;
return g_strdup_printf("%c", param_char);
@ -507,7 +507,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
}
if(safe_strcmp(paramType, QOF_TYPE_CHOICE) == 0)
{
QofEntity *child = NULL;
QofInstance *child = NULL;
child = param->param_getfcn(ent, param);
if(!child) { return param_string; }
known_type = TRUE;
@ -534,7 +534,7 @@ qof_util_param_as_string(QofEntity *ent, QofParam *param)
}
if(!known_type)
{
QofEntity *child = NULL;
QofInstance *child = NULL;
child = param->param_getfcn(ent, param);
if(!child) { return param_string; }
return g_strdup(qof_object_printable(child->e_type, child));

View File

@ -235,7 +235,7 @@ gint qof_util_bool_to_int (const gchar * val);
The returned string must be freed by the caller.
*/
gchar* qof_util_param_as_string(QofEntity *ent, QofParam *param);
gchar* qof_util_param_as_string(QofInstance *ent, QofParam *param);
/** The QOF String Cache:
*

View File

@ -253,12 +253,12 @@ add_event_type (ComponentEventInfo *cei, GNCIdTypeConst entity_type,
}
static void
gnc_cm_event_handler (QofEntity *entity,
gnc_cm_event_handler (QofInstance *entity,
QofEventId event_type,
gpointer user_data,
gpointer event_data)
{
const GUID *guid = qof_entity_get_guid(entity);
const GUID *guid = qof_instance_get_guid(entity);
#if CM_DEBUG
fprintf (stderr, "event_handler: event %d, entity %p, guid %s\n", event_type,
entity, guid);

View File

@ -56,7 +56,7 @@ static gint _get_vars_helper(Transaction *txn, void *var_hash_data);
static GncSxVariable* gnc_sx_variable_new(gchar *name);
static void _gnc_sx_instance_event_handler(QofEntity *ent, QofEventId event_type, gpointer user_data, gpointer evt_data);
static void _gnc_sx_instance_event_handler(QofInstance *ent, QofEventId event_type, gpointer user_data, gpointer evt_data);
/* ------------------------------------------------------------ */
@ -605,7 +605,7 @@ _gnc_sx_instance_find_by_sx(GncSxInstances *in_list_instances, SchedXaction *sx_
}
static void
_gnc_sx_instance_event_handler(QofEntity *ent, QofEventId event_type, gpointer user_data, gpointer evt_data)
_gnc_sx_instance_event_handler(QofInstance *ent, QofEventId event_type, gpointer user_data, gpointer evt_data)
{
GncSxInstanceModel *instances = GNC_SX_INSTANCE_MODEL(user_data);

View File

@ -364,7 +364,7 @@ write_out (QofMap *qm, QofInstance *inst)
{
if (!inst) return;
GUID *guid = &QOF_ENTITY(inst)->guid;
GUID *guid = &QOF_INSTANCE(inst)->guid;
dui_connection_lock(qm->db_conn, qm->table_name);
/* Use a temp book when loading from the database */
@ -376,8 +376,8 @@ write_out (QofMap *qm, QofInstance *inst)
/* See if we got something back from the DB */
QofCollection *col;
col = qof_book_get_collection (qm->tmp_book, QOF_ENTITY(inst)->e_type);
QofEntity * db_ent = qof_collection_lookup_entity (col, guid);
col = qof_book_get_collection (qm->tmp_book, QOF_INSTANCE(inst)->e_type);
QofInstance * db_ent = qof_collection_lookup_entity (col, guid);
QofInstance *db_inst = QOF_INSTANCE(db_ent);
/* If its not already in the database, then insert it in */

View File

@ -821,7 +821,7 @@ file_begin_edit (QofBackend *be, QofInstance *inst)
QofBook *book = gp;
const char * filepath;
QofIdTypeConst typ = QOF_ENTITY(inst)->e_type;
QofIdTypeConst typ = QOF_INSTANCE(inst)->e_type;
if (strcmp (GNC_ID_PERIOD, typ)) return;
filepath = build_period_filepath(fbe, book);
PINFO (" ====================== book=%p filepath=%s\n", book, filepath);

View File

@ -196,7 +196,7 @@ book_id_handler(xmlNodePtr node, gpointer book_pdata)
GUID *guid;
guid = dom_tree_to_guid(node);
qof_entity_set_guid(QOF_ENTITY(book), guid);
qof_instance_set_guid(QOF_INSTANCE(book), guid);
g_free(guid);
return TRUE;

View File

@ -111,7 +111,7 @@ budget_id_handler (xmlNodePtr node, gpointer bgt)
guid = dom_tree_to_guid(node);
g_return_val_if_fail(guid, FALSE);
qof_entity_set_guid(QOF_ENTITY(bgt), guid);
qof_instance_set_guid(QOF_INSTANCE(bgt), guid);
g_free(guid);
return TRUE;
}

View File

@ -865,7 +865,7 @@ static void write_pricedb (FILE *out, QofBook *book, sixtp_gdv2 *gd);
static void write_transactions (FILE *out, QofBook *book, sixtp_gdv2 *gd);
static void write_template_transaction_data (FILE *out, QofBook *book, sixtp_gdv2 *gd);
static void write_schedXactions(FILE *out, QofBook *book, sixtp_gdv2 *gd);
static void write_budget (QofEntity *ent, gpointer data);
static void write_budget (QofInstance *ent, gpointer data);
static void
write_counts_cb (const char *type, gpointer data_p, gpointer be_data_p)
@ -1103,7 +1103,7 @@ write_schedXactions( FILE *out, QofBook *book, sixtp_gdv2 *gd)
}
static void
write_budget (QofEntity *ent, gpointer data)
write_budget (QofInstance *ent, gpointer data)
{
xmlNodePtr node;
struct file_backend* be = data;

View File

@ -184,7 +184,7 @@ pgendSplitLookup (PGBackend *be, const GUID *split_guid)
struct _iter {
const GUID *guid;
QofEntity *ent;
QofInstance *ent;
};
static void
@ -1627,7 +1627,7 @@ static void
pgend_do_begin (QofBackend *bend, QofInstance *inst)
{
PGBackend *be = (PGBackend*)bend;
QofIdTypeConst type = inst->entity.e_type;
QofIdTypeConst type = inst->e_type;
ENTER ("be=%p, type=%s", bend, type);
// if (!safe_strcmp (type, GNC_ID_PERIOD))
@ -1653,7 +1653,7 @@ static void
pgend_do_commit (QofBackend *bend, QofInstance *inst)
{
PGBackend *be = (PGBackend*)bend;
QofIdTypeConst type = inst->entity.e_type;
QofIdTypeConst type = inst->e_type;
ENTER ("be=%p, type=%s", bend, type);
// if (!safe_strcmp (type, GNC_ID_PERIOD))
@ -1689,7 +1689,7 @@ static void
pgend_do_rollback (QofBackend *bend, QofInstance *inst)
{
PGBackend *be = (PGBackend*)bend;
QofIdTypeConst type = inst->entity.e_type;
QofIdTypeConst type = inst->e_type;
ENTER ("be=%p, type=%s", bend, type);
switch (be->session_mode) {

View File

@ -139,7 +139,7 @@ get_one_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("bookGuid",j), &guid);
qof_entity_set_guid (QOF_ENTITY(book), &guid);
qof_instance_set_guid (QOF_INSTANCE(book), &guid);
if((DB_GET_VAL("book_open",j))[0] == 'n')
{
@ -208,14 +208,14 @@ get_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
for (node=blist; node; node=node->next)
{
book = node->data;
if (guid_equal (qof_entity_get_guid(QOF_ENTITY(book)), &guid)) break;
if (guid_equal (qof_instance_get_guid(QOF_INSTANCE(book)), &guid)) break;
book = NULL;
}
if (!book)
{
book = qof_book_new();
qof_entity_set_guid (QOF_ENTITY(book), &guid);
qof_instance_set_guid (QOF_INSTANCE(book), &guid);
}
if((DB_GET_VAL("book_open",j))[0] == 'n')

View File

@ -259,7 +259,7 @@ pgendProcessEvents (QofBackend *bend)
{
Event *ev = (Event *) node->data;
QofIdType local_obj_type;
QofEntity *ent;
QofInstance *ent;
ent = NULL;
/* lets see if the local cache has this item in it */
@ -290,14 +290,14 @@ pgendProcessEvents (QofBackend *bend)
/* if the remote user created an account, mirror it here */
acc = pgendCopyAccountToEngine (be, &(ev->guid));
ent = QOF_ENTITY(acc);
ent = QOF_INSTANCE(acc);
break;
}
case QOF_EVENT_DESTROY: {
Account * acc = pgendAccountLookup (be, &(ev->guid));
xaccAccountBeginEdit (acc);
xaccAccountDestroy (acc);
ent = QOF_ENTITY(acc);
ent = QOF_INSTANCE(acc);
break;
}
}
@ -319,7 +319,7 @@ pgendProcessEvents (QofBackend *bend)
/* don't mirror transaction creations. If a register needs
* it, it will do a query. */
trans = pgendTransLookup (be, &(ev->guid));
ent = QOF_ENTITY(trans);
ent = QOF_INSTANCE(trans);
PINFO ("create transaction");
break;
}
@ -327,7 +327,7 @@ pgendProcessEvents (QofBackend *bend)
Transaction *trans;
trans = pgendTransLookup (be, &(ev->guid));
pgendCopyTransactionToEngine (be, &(ev->guid));
ent = QOF_ENTITY(trans);
ent = QOF_INSTANCE(trans);
break;
}
case QOF_EVENT_DESTROY: {
@ -336,7 +336,7 @@ pgendProcessEvents (QofBackend *bend)
/* mark trans for freeing */
xaccTransDestroy (trans);
xaccTransCommitEdit (trans);
ent = QOF_ENTITY(trans);
ent = QOF_INSTANCE(trans);
break;
}
}

View File

@ -358,7 +358,7 @@ int finishQuery(PGBackend *be);
for (node=be->blist; node; node=node->next) \
{ \
book = node->data; \
if (guid_equal (qof_entity_get_guid((QofEntity*)book), &book_guid)) break; \
if (guid_equal (qof_instance_get_guid((QofInstance*)book), &book_guid)) break; \
book = NULL; \
} \
if (!book) return data; \

View File

@ -13,7 +13,7 @@ define(`account', `gncAccount, Account, Account, a,
commodity, , char *, gnc_commodity_get_unique_name(xaccAccountGetCommodity(ptr)),
version, , int32, xaccAccountGetVersion(ptr),
iguid, , int32, ptr->idata,
bookGUID, , GUID *, qof_entity_get_guid((QofEntity*)gnc_account_get_book(ptr)),
bookGUID, , GUID *, qof_instance_get_guid((QofInstance*)gnc_account_get_book(ptr)),
parentGUID, , GUID *, xaccAccountGetGUID(gnc_account_get_parent(ptr)),
accountGUID, KEY, GUID *, xaccAccountGetGUID(ptr),
')
@ -362,7 +362,7 @@ define(`compare_version',
p = be->buff; *p = 0;
p = stpcpy (p, "SELECT version FROM tablename($@) WHERE key_fieldname($@) = ''`");
p = guid_to_string_buff (qof_entity_get_guid(QOF_ENTITY(ptr)), p);
p = guid_to_string_buff (qof_instance_get_guid(QOF_INSTANCE(ptr)), p);
p = stpcpy (p, "''`;");
SEND_QUERY (be,be->buff, -1);
sql_version = GPOINTER_TO_INT(pgendGetResults (be, get_version_cb, (gpointer) -1));
@ -392,7 +392,7 @@ define(`is_deleted',
p = be->buff; *p = 0;
p = stpcpy (p, "SELECT version FROM tablename($@)" "Trail WHERE key_fieldname($@) = ''`");
p = guid_to_string_buff (qof_entity_get_guid(QOF_ENTITY(ptr)), p);
p = guid_to_string_buff (qof_instance_get_guid(QOF_INSTANCE(ptr)), p);
p = stpcpy (p, "''` AND change = ''`d''`;");
SEND_QUERY (be,be->buff, -1);
sql_version = GPOINTER_TO_INT(pgendGetResults (be, get_version_cb, (gpointer) -1));

View File

@ -171,7 +171,7 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
{
Split *s = split_node->data;
if (s && guid_equal (&s->inst.entity.guid, &dti->guid))
if (s && guid_equal (&s->inst.guid, &dti->guid))
{
pgendStoreAuditSplit (be, s, SQL_DELETE);
break;

View File

@ -482,7 +482,7 @@ billterm_sixtp_parser_create(void)
}
static void
do_count (QofEntity *term_p, gpointer count_p)
do_count (QofInstance *term_p, gpointer count_p)
{
int *count = count_p;
(*count)++;
@ -497,7 +497,7 @@ billterm_get_count (QofBook *book)
}
static void
xml_add_billterm (QofEntity *term_p, gpointer out_p)
xml_add_billterm (QofInstance *term_p, gpointer out_p)
{
xmlNodePtr node;
GncBillTerm *term = (GncBillTerm *) term_p;
@ -556,7 +556,7 @@ billterm_find_senior (GncBillTerm *term)
/* build a list of bill terms that are grandchildren or bogus (empty entry list). */
static void
billterm_scrub_cb (QofEntity *term_p, gpointer list_p)
billterm_scrub_cb (QofInstance *term_p, gpointer list_p)
{
GncBillTerm *term = GNC_BILLTERM(term_p);
GList **list = list_p;
@ -590,7 +590,7 @@ billterm_scrub_cb (QofEntity *term_p, gpointer list_p)
* grandchildren, then fix them to point to the most senior child
*/
static void
billterm_scrub_invoices (QofEntity * invoice_p, gpointer ht_p)
billterm_scrub_invoices (QofInstance * invoice_p, gpointer ht_p)
{
GHashTable *ht = ht_p;
GncInvoice *invoice = GNC_INVOICE(invoice_p);
@ -617,7 +617,7 @@ billterm_scrub_invoices (QofEntity * invoice_p, gpointer ht_p)
}
static void
billterm_scrub_cust (QofEntity * cust_p, gpointer ht_p)
billterm_scrub_cust (QofInstance * cust_p, gpointer ht_p)
{
GHashTable *ht = ht_p;
GncCustomer *cust = GNC_CUSTOMER(cust_p);
@ -637,7 +637,7 @@ billterm_scrub_cust (QofEntity * cust_p, gpointer ht_p)
}
static void
billterm_scrub_vendor (QofEntity * vendor_p, gpointer ht_p)
billterm_scrub_vendor (QofInstance * vendor_p, gpointer ht_p)
{
GHashTable *ht = ht_p;
GncVendor *vendor = GNC_VENDOR(vendor_p);

View File

@ -470,7 +470,7 @@ customer_should_be_saved (GncCustomer *customer)
}
static void
do_count (QofEntity * cust_p, gpointer count_p)
do_count (QofInstance * cust_p, gpointer count_p)
{
int *count = count_p;
if (customer_should_be_saved ((GncCustomer *)cust_p))
@ -486,7 +486,7 @@ customer_get_count (QofBook *book)
}
static void
xml_add_customer (QofEntity * cust_p, gpointer out_p)
xml_add_customer (QofInstance * cust_p, gpointer out_p)
{
xmlNodePtr node;
GncCustomer *cust = (GncCustomer *) cust_p;

View File

@ -389,7 +389,7 @@ employee_should_be_saved (GncEmployee *employee)
}
static void
do_count (QofEntity * employee_p, gpointer count_p)
do_count (QofInstance * employee_p, gpointer count_p)
{
int *count = count_p;
if (employee_should_be_saved ((GncEmployee *) employee_p))
@ -405,7 +405,7 @@ employee_get_count (QofBook *book)
}
static void
xml_add_employee (QofEntity * employee_p, gpointer out_p)
xml_add_employee (QofInstance * employee_p, gpointer out_p)
{
xmlNodePtr node;
GncEmployee *employee = (GncEmployee *) employee_p;

View File

@ -781,7 +781,7 @@ entry_sixtp_parser_create(void)
}
static void
do_count (QofEntity * entry_p, gpointer count_p)
do_count (QofInstance * entry_p, gpointer count_p)
{
int *count = count_p;
(*count)++;
@ -796,7 +796,7 @@ entry_get_count (QofBook *book)
}
static void
xml_add_entry (QofEntity * entry_p, gpointer out_p)
xml_add_entry (QofInstance * entry_p, gpointer out_p)
{
xmlNodePtr node;
GncEntry *entry = (GncEntry *) entry_p;

View File

@ -501,7 +501,7 @@ invoice_should_be_saved (GncInvoice *invoice)
}
static void
do_count (QofEntity * invoice_p, gpointer count_p)
do_count (QofInstance * invoice_p, gpointer count_p)
{
int *count = count_p;
if (invoice_should_be_saved ((GncInvoice *)invoice_p))
@ -517,7 +517,7 @@ invoice_get_count (QofBook *book)
}
static void
xml_add_invoice (QofEntity * invoice_p, gpointer out_p)
xml_add_invoice (QofInstance * invoice_p, gpointer out_p)
{
xmlNodePtr node;
GncInvoice *invoice = (GncInvoice *) invoice_p;

View File

@ -288,7 +288,7 @@ job_should_be_saved (GncJob *job)
}
static void
do_count (QofEntity * job_p, gpointer count_p)
do_count (QofInstance * job_p, gpointer count_p)
{
int *count = count_p;
if (job_should_be_saved ((GncJob *)job_p))
@ -304,7 +304,7 @@ job_get_count (QofBook *book)
}
static void
xml_add_job (QofEntity * job_p, gpointer out_p)
xml_add_job (QofInstance * job_p, gpointer out_p)
{
xmlNodePtr node;
GncJob *job = (GncJob *) job_p;

View File

@ -331,7 +331,7 @@ order_should_be_saved (GncOrder *order)
}
static void
do_count (QofEntity * order_p, gpointer count_p)
do_count (QofInstance * order_p, gpointer count_p)
{
int *count = count_p;
if (order_should_be_saved ((GncOrder *) order_p))
@ -347,7 +347,7 @@ order_get_count (QofBook *book)
}
static void
xml_add_order (QofEntity * order_p, gpointer out_p)
xml_add_order (QofInstance * order_p, gpointer out_p)
{
xmlNodePtr node;
GncOrder *order = (GncOrder *) order_p;

View File

@ -445,7 +445,7 @@ taxtable_sixtp_parser_create(void)
}
static void
do_count (QofEntity * table_p, gpointer count_p)
do_count (QofInstance * table_p, gpointer count_p)
{
int *count = count_p;
(*count)++;
@ -460,7 +460,7 @@ taxtable_get_count (QofBook *book)
}
static void
xml_add_taxtable (QofEntity * table_p, gpointer out_p)
xml_add_taxtable (QofInstance * table_p, gpointer out_p)
{
xmlNodePtr node;
GncTaxTable *table = (GncTaxTable *) table_p;
@ -520,7 +520,7 @@ taxtable_find_senior (GncTaxTable *table)
/* build a list of tax tables that are grandchildren or bogus (empty entry list). */
static void
taxtable_scrub_cb (QofEntity * table_p, gpointer list_p)
taxtable_scrub_cb (QofInstance * table_p, gpointer list_p)
{
GncTaxTable *table = GNC_TAXTABLE(table_p);
GList **list = list_p;
@ -533,7 +533,7 @@ taxtable_scrub_cb (QofEntity * table_p, gpointer list_p)
* grandchildren, then fix them to point to the most senior child
*/
static void
taxtable_scrub_entries (QofEntity * entry_p, gpointer ht_p)
taxtable_scrub_entries (QofInstance * entry_p, gpointer ht_p)
{
GHashTable *ht = ht_p;
GncEntry *entry = GNC_ENTRY(entry_p);
@ -578,7 +578,7 @@ taxtable_scrub_entries (QofEntity * entry_p, gpointer ht_p)
}
static void
taxtable_scrub_cust (QofEntity * cust_p, gpointer ht_p)
taxtable_scrub_cust (QofInstance * cust_p, gpointer ht_p)
{
GHashTable *ht = ht_p;
GncCustomer *cust = GNC_CUSTOMER(cust_p);
@ -594,7 +594,7 @@ taxtable_scrub_cust (QofEntity * cust_p, gpointer ht_p)
}
static void
taxtable_scrub_vendor (QofEntity * vendor_p, gpointer ht_p)
taxtable_scrub_vendor (QofInstance * vendor_p, gpointer ht_p)
{
GHashTable *ht = ht_p;
GncVendor *vendor = GNC_VENDOR(vendor_p);

View File

@ -407,7 +407,7 @@ vendor_should_be_saved (GncVendor *vendor)
}
static void
do_count (QofEntity * vendor_p, gpointer count_p)
do_count (QofInstance * vendor_p, gpointer count_p)
{
int *count = count_p;
if (vendor_should_be_saved ((GncVendor *)vendor_p))
@ -423,7 +423,7 @@ vendor_get_count (QofBook *book)
}
static void
xml_add_vendor (QofEntity * vendor_p, gpointer out_p)
xml_add_vendor (QofInstance * vendor_p, gpointer out_p)
{
xmlNodePtr node;
GncVendor *vendor = (GncVendor *) vendor_p;

View File

@ -38,7 +38,7 @@ struct _gncAddress
QofInstance inst;
QofBook * book;
QofEntity * parent;
QofInstance * parent;
gboolean dirty;
char * name;
char * addr1;
@ -65,7 +65,7 @@ void mark_address (GncAddress *address)
/* Create/Destroy functions */
GncAddress *
gncAddressCreate (QofBook *book, QofEntity *prnt)
gncAddressCreate (QofBook *book, QofInstance *prnt)
{
GncAddress *addr;
@ -97,13 +97,13 @@ qofAddressCreate (QofBook *book)
}
static void
qofAddressSetOwner(GncAddress *addr, QofEntity *ent)
qofAddressSetOwner(GncAddress *addr, QofInstance *ent)
{
if(!addr || !ent) { return; }
if(addr->parent == NULL) { addr->parent = ent; }
}
static QofEntity*
static QofInstance*
qofAddressGetOwner(GncAddress *addr)
{
@ -112,7 +112,7 @@ qofAddressGetOwner(GncAddress *addr)
}
GncAddress *
gncCloneAddress (GncAddress *from, QofEntity *new_parent, QofBook *book)
gncCloneAddress (GncAddress *from, QofInstance *new_parent, QofBook *book)
{
GncAddress *addr;
@ -148,7 +148,7 @@ gncAddressFree (GncAddress *addr)
{
if (!addr) return;
qof_event_gen (&addr->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&addr->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (addr->name);
CACHE_REMOVE (addr->addr1);

View File

@ -65,7 +65,7 @@ up to you to pass a suitable entity.
@param QofInstance The address instance.
@param QofBook* Copy of the book pointer.
@param QofEntity* parent entity.
@param QofInstance* parent entity.
@param gboolean dirty flag
@param char* name of addressee
@param char* first line of address
@ -80,7 +80,7 @@ typedef struct _gncAddress GncAddress;
/** @name Create/Destroy functions
@{ */
GncAddress *gncAddressCreate (QofBook *book, QofEntity *parent);
GncAddress *gncAddressCreate (QofBook *book, QofInstance *parent);
void gncAddressDestroy (GncAddress *addr);
void gncAddressBeginEdit (GncAddress *addr);
void gncAddressCommitEdit (GncAddress *addr);

View File

@ -33,7 +33,7 @@
gboolean gncAddressRegister (void);
/** Make a copy of the address, setting the parent to 'new_parent' */
GncAddress * gncCloneAddress (GncAddress *from, QofEntity *new_parent, QofBook *book);
GncAddress * gncCloneAddress (GncAddress *from, QofInstance *new_parent, QofBook *book);
#endif /* GNC_ADDRESSP_H_ */

View File

@ -85,7 +85,7 @@ static inline void
mark_term (GncBillTerm *term)
{
qof_instance_set_dirty(&term->inst);
qof_event_gen (&term->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&term->inst, QOF_EVENT_MODIFY, NULL);
}
static inline void maybe_resort_list (GncBillTerm *term)
@ -140,7 +140,7 @@ GncBillTerm * gncBillTermCreate (QofBook *book)
term->desc = CACHE_INSERT ("");
term->discount = gnc_numeric_zero ();
addObj (term);
qof_event_gen (&term->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&term->inst, QOF_EVENT_CREATE, NULL);
return term;
}
@ -161,7 +161,7 @@ static void gncBillTermFree (GncBillTerm *term)
if (!term) return;
qof_event_gen (&term->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&term->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (term->name);
CACHE_REMOVE (term->desc);
remObj (term);
@ -228,7 +228,7 @@ gncCloneBillTerm (GncBillTerm *from, QofBook *book)
}
addObj (term);
qof_event_gen (&term->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&term->inst, QOF_EVENT_CREATE, NULL);
return term;
}

View File

@ -64,7 +64,7 @@ GncBillTerm * gncCloneBillTerm (GncBillTerm *from, QofBook *);
*/
GncBillTerm * gncBillTermObtainTwin (GncBillTerm *from, QofBook *book);
#define gncBillTermSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
#define gncBillTermSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
#endif /* GNC_BILLTERMP_H_ */

View File

@ -79,7 +79,7 @@ G_INLINE_FUNC void mark_customer (GncCustomer *customer);
void mark_customer (GncCustomer *customer)
{
qof_instance_set_dirty(&customer->inst);
qof_event_gen (&customer->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&customer->inst, QOF_EVENT_MODIFY, NULL);
}
/* ============================================================== */
@ -97,16 +97,16 @@ GncCustomer *gncCustomerCreate (QofBook *book)
cust->id = CACHE_INSERT ("");
cust->name = CACHE_INSERT ("");
cust->notes = CACHE_INSERT ("");
cust->addr = gncAddressCreate (book, &cust->inst.entity);
cust->addr = gncAddressCreate (book, &cust->inst);
cust->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
cust->active = TRUE;
cust->jobs = NULL;
cust->discount = gnc_numeric_zero();
cust->credit = gnc_numeric_zero();
cust->shipaddr = gncAddressCreate (book, &cust->inst.entity);
cust->shipaddr = gncAddressCreate (book, &cust->inst);
qof_event_gen (&cust->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&cust->inst, QOF_EVENT_CREATE, NULL);
return cust;
}
@ -132,8 +132,8 @@ gncCloneCustomer (GncCustomer *from, QofBook *book)
cust->active = from->active;
cust->taxtable_override = from->taxtable_override;
cust->addr = gncCloneAddress (from->addr, &cust->inst.entity, book);
cust->shipaddr = gncCloneAddress (from->shipaddr, &cust->inst.entity, book);
cust->addr = gncCloneAddress (from->addr, &cust->inst, book);
cust->shipaddr = gncCloneAddress (from->shipaddr, &cust->inst, book);
/* Find the matching currency in the new book, assumes
* currency has already been copied into new book. */
@ -150,7 +150,7 @@ gncCloneCustomer (GncCustomer *from, QofBook *book)
cust->jobs = g_list_prepend(cust->jobs, job);
}
qof_event_gen (&cust->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&cust->inst, QOF_EVENT_CREATE, NULL);
return cust;
}
@ -167,7 +167,7 @@ static void gncCustomerFree (GncCustomer *cust)
{
if (!cust) return;
qof_event_gen (&cust->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&cust->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (cust->id);
CACHE_REMOVE (cust->name);
@ -340,7 +340,7 @@ void gncCustomerAddJob (GncCustomer *cust, GncJob *job)
cust->jobs = g_list_insert_sorted (cust->jobs, job,
(GCompareFunc)gncJobCompare);
qof_event_gen (&cust->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&cust->inst, QOF_EVENT_MODIFY, NULL);
}
void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
@ -357,7 +357,7 @@ void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
cust->jobs = g_list_remove_link (cust->jobs, node);
g_list_free_1 (node);
}
qof_event_gen (&cust->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&cust->inst, QOF_EVENT_MODIFY, NULL);
}
void gncCustomerBeginEdit (GncCustomer *cust)
@ -412,7 +412,7 @@ GncAddress * gncCustomerGetAddr (GncCustomer *cust)
}
static void
qofCustomerSetAddr (GncCustomer *cust, QofEntity *addr_ent)
qofCustomerSetAddr (GncCustomer *cust, QofInstance *addr_ent)
{
GncAddress *addr;
@ -426,7 +426,7 @@ qofCustomerSetAddr (GncCustomer *cust, QofEntity *addr_ent)
}
static void
qofCustomerSetShipAddr (GncCustomer *cust, QofEntity *ship_addr_ent)
qofCustomerSetShipAddr (GncCustomer *cust, QofInstance *ship_addr_ent)
{
GncAddress *ship_addr;

View File

@ -53,6 +53,6 @@ GncCustomer * gncCloneCustomer (GncCustomer *from, QofBook *book);
*/
GncCustomer * gncCustomerObtainTwin (GncCustomer *from, QofBook *book);
#define gncCustomerSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
#define gncCustomerSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
#endif /* GNC_CUSTOMERP_H_ */

View File

@ -62,7 +62,7 @@ G_INLINE_FUNC void mark_employee (GncEmployee *employee);
void mark_employee (GncEmployee *employee)
{
qof_instance_set_dirty(&employee->inst);
qof_event_gen (&employee->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&employee->inst, QOF_EVENT_MODIFY, NULL);
}
/* ============================================================== */
@ -81,12 +81,12 @@ GncEmployee *gncEmployeeCreate (QofBook *book)
employee->username = CACHE_INSERT ("");
employee->language = CACHE_INSERT ("");
employee->acl = CACHE_INSERT ("");
employee->addr = gncAddressCreate (book, &employee->inst.entity);
employee->addr = gncAddressCreate (book, &employee->inst);
employee->workday = gnc_numeric_zero();
employee->rate = gnc_numeric_zero();
employee->active = TRUE;
qof_event_gen (&employee->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&employee->inst, QOF_EVENT_CREATE, NULL);
return employee;
}
@ -102,7 +102,7 @@ static void gncEmployeeFree (GncEmployee *employee)
{
if (!employee) return;
qof_event_gen (&employee->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&employee->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (employee->id);
CACHE_REMOVE (employee->username);
@ -128,7 +128,7 @@ gncCloneEmployee (GncEmployee *from, QofBook *book)
employee->username = CACHE_INSERT (from->username);
employee->language = CACHE_INSERT (from->language);
employee->acl = CACHE_INSERT (from->acl);
employee->addr = gncCloneAddress (from->addr, &employee->inst.entity, book);
employee->addr = gncCloneAddress (from->addr, &employee->inst, book);
employee->workday = from->workday;
employee->rate = from->rate;
employee->active = from->active;
@ -136,7 +136,7 @@ gncCloneEmployee (GncEmployee *from, QofBook *book)
employee->ccard_acc =
GNC_ACCOUNT(qof_instance_lookup_twin(QOF_INSTANCE(from->ccard_acc), book));
qof_event_gen (&employee->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&employee->inst, QOF_EVENT_CREATE, NULL);
return employee;
}
@ -258,7 +258,7 @@ void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc)
}
void
qofEmployeeSetAddr (GncEmployee *employee, QofEntity *addr_ent)
qofEmployeeSetAddr (GncEmployee *employee, QofInstance *addr_ent)
{
GncAddress *addr;

View File

@ -60,7 +60,7 @@ void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate);
void gncEmployeeSetCurrency (GncEmployee *employee, gnc_commodity * currency);
void gncEmployeeSetActive (GncEmployee *employee, gboolean active);
void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc);
void qofEmployeeSetAddr (GncEmployee *employee, QofEntity *addr_ent);
void qofEmployeeSetAddr (GncEmployee *employee, QofInstance *addr_ent);
/** @} */
@ -101,9 +101,9 @@ gboolean gncEmployeeIsDirty (GncEmployee *employee);
#define EMPLOYEE_CC "credit_card_account"
/** deprecated routines */
#define gncEmployeeGetGUID(E) qof_entity_get_guid(QOF_ENTITY(E))
#define gncEmployeeGetGUID(E) qof_instance_get_guid(QOF_INSTANCE(E))
#define gncEmployeeGetBook(E) qof_instance_get_book(QOF_INSTANCE(E))
#define gncEmployeeRetGUID(E) (E ? *(qof_entity_get_guid(QOF_ENTITY(E))) : *(guid_null()))
#define gncEmployeeRetGUID(E) (E ? *(qof_instance_get_guid(QOF_INSTANCE(E))) : *(guid_null()))
#define gncEmployeeLookupDirect(G,B) gncEmployeeLookup((B),&(G))
#endif /* GNC_EMPLOYEE_H_ */

View File

@ -57,6 +57,6 @@ GncEmployee * gncCloneEmployee (GncEmployee *from, QofBook *);
*/
GncEmployee * gncEmployeeObtainTwin (GncEmployee *from, QofBook *book);
#define gncEmployeeSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
#define gncEmployeeSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
#endif /* GNC_EMPLOYEEP_H_ */

View File

@ -169,7 +169,7 @@ G_INLINE_FUNC void mark_entry (GncEntry *entry);
void mark_entry (GncEntry *entry)
{
qof_instance_set_dirty(&entry->inst);
qof_event_gen (&entry->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&entry->inst, QOF_EVENT_MODIFY, NULL);
}
/* ================================================================ */
@ -203,7 +203,7 @@ GncEntry *gncEntryCreate (QofBook *book)
entry->values_dirty = TRUE;
qof_event_gen (&entry->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&entry->inst, QOF_EVENT_CREATE, NULL);
return entry;
}
@ -219,7 +219,7 @@ static void gncEntryFree (GncEntry *entry)
{
if (!entry) return;
qof_event_gen (&entry->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&entry->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (entry->desc);
CACHE_REMOVE (entry->action);
@ -1209,7 +1209,7 @@ int gncEntryCompare (GncEntry *a, GncEntry *b)
compare = safe_strcmp (a->action, b->action);
if (compare) return compare;
return guid_compare (&(a->inst.entity.guid), &(b->inst.entity.guid));
return guid_compare (&(a->inst.guid), &(b->inst.guid));
}
/* ============================================================= */

View File

@ -59,6 +59,6 @@ GncEntry * gncCloneEntry (GncEntry *from, QofBook *);
*/
GncEntry * gncEntryObtainTwin (GncEntry *from, QofBook *book);
#define gncEntrySetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
#define gncEntrySetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
#endif /* GNC_ENTRYP_H_ */

View File

@ -91,7 +91,7 @@ static void
mark_invoice (GncInvoice *invoice)
{
qof_instance_set_dirty(&invoice->inst);
qof_event_gen (&invoice->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&invoice->inst, QOF_EVENT_MODIFY, NULL);
}
QofBook * gncInvoiceGetBook(GncInvoice *x)
@ -120,7 +120,7 @@ GncInvoice *gncInvoiceCreate (QofBook *book)
invoice->to_charge_amount = gnc_numeric_zero();
qof_event_gen (&invoice->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&invoice->inst, QOF_EVENT_CREATE, NULL);
return invoice;
}
@ -136,7 +136,7 @@ static void gncInvoiceFree (GncInvoice *invoice)
{
if (!invoice) return;
qof_event_gen (&invoice->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&invoice->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (invoice->id);
CACHE_REMOVE (invoice->notes);
@ -199,7 +199,7 @@ XXX not done */
GNCLot * posted_lot;
#endif
qof_event_gen (&invoice->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&invoice->inst, QOF_EVENT_CREATE, NULL);
return invoice;
}
@ -241,7 +241,7 @@ void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner)
}
static void
qofInvoiceSetOwner (GncInvoice *invoice, QofEntity *ent)
qofInvoiceSetOwner (GncInvoice *invoice, QofInstance *ent)
{
if(!invoice || !ent) { return; }
gncInvoiceBeginEdit (invoice);
@ -251,7 +251,7 @@ qofInvoiceSetOwner (GncInvoice *invoice, QofEntity *ent)
}
static void
qofInvoiceSetBillTo (GncInvoice *invoice, QofEntity *ent)
qofInvoiceSetBillTo (GncInvoice *invoice, QofInstance *ent)
{
if(!invoice || !ent) { return; }
gncInvoiceBeginEdit (invoice);
@ -459,18 +459,18 @@ GncOwner * gncInvoiceGetOwner (GncInvoice *invoice)
return &invoice->owner;
}
static QofEntity*
static QofInstance*
qofInvoiceGetOwner (GncInvoice *invoice)
{
if(!invoice) { return NULL; }
return QOF_ENTITY(&invoice->owner);
return QOF_INSTANCE(&invoice->owner);
}
static QofEntity*
static QofInstance*
qofInvoiceGetBillTo (GncInvoice *invoice)
{
if(!invoice) { return NULL; }
return QOF_ENTITY(&invoice->billto);
return QOF_INSTANCE(&invoice->billto);
}
Timespec gncInvoiceGetDateOpened (GncInvoice *invoice)
@ -655,19 +655,19 @@ qofInvoiceGetEntries (GncInvoice *invoice)
{
QofCollection *entry_coll;
GList *list;
QofEntity *entry;
QofInstance *entry;
entry_coll = qof_collection_new(GNC_ID_ENTRY);
for(list = gncInvoiceGetEntries(invoice); list != NULL; list = list->next)
{
entry = QOF_ENTITY(list->data);
entry = QOF_INSTANCE(list->data);
qof_collection_add_entity(entry_coll, entry);
}
return entry_coll;
}
static void
qofInvoiceEntryCB (QofEntity *ent, gpointer user_data)
qofInvoiceEntryCB (QofInstance *ent, gpointer user_data)
{
GncInvoice *invoice;
@ -1385,7 +1385,7 @@ gncOwnerApplyPayment (GncOwner *owner, GncInvoice* invoice,
/* Now send an event for the invoice so it gets updated as paid */
this_invoice = gncInvoiceGetInvoiceFromLot(lot);
if (this_invoice)
qof_event_gen (&this_invoice->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&this_invoice->inst, QOF_EVENT_MODIFY, NULL);
if (gnc_numeric_zero_p (amount))
break;
@ -1482,7 +1482,7 @@ int gncInvoiceCompare (GncInvoice *a, GncInvoice *b)
compare = timespec_cmp (&(a->date_posted), &(b->date_posted));
if (compare) return compare;
return guid_compare (&(a->inst.entity.guid), &(b->inst.entity.guid));
return guid_compare (&(a->inst.guid), &(b->inst.guid));
}
/* ============================================================= */

View File

@ -63,5 +63,5 @@ GncInvoice * gncCloneInvoice (GncInvoice *from, QofBook *);
* different ways.
*/
GncInvoice * gncInvoiceObtainTwin (GncInvoice *from, QofBook *book);
#define gncInvoiceSetGUID(I,G) qof_entity_set_guid(QOF_ENTITY(I),(G))
#define gncInvoiceSetGUID(I,G) qof_instance_set_guid(QOF_INSTANCE(I),(G))
#endif /* GNC_INVOICEP_H_ */

View File

@ -57,7 +57,7 @@ G_INLINE_FUNC void mark_job (GncJob *job);
void mark_job (GncJob *job)
{
qof_instance_set_dirty(&job->inst);
qof_event_gen (&job->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&job->inst, QOF_EVENT_MODIFY, NULL);
}
/* ================================================================== */
@ -78,7 +78,7 @@ GncJob *gncJobCreate (QofBook *book)
job->active = TRUE;
/* GncOwner not initialized */
qof_event_gen (&job->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&job->inst, QOF_EVENT_CREATE, NULL);
return job;
}
@ -101,7 +101,7 @@ gncCloneJob (GncJob *from, QofBook *book)
job->owner = gncCloneOwner(&from->owner, book);
qof_event_gen (&job->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&job->inst, QOF_EVENT_CREATE, NULL);
return job;
}
@ -117,7 +117,7 @@ static void gncJobFree (GncJob *job)
{
if (!job) return;
qof_event_gen (&job->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&job->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (job->id);
CACHE_REMOVE (job->name);
@ -248,7 +248,7 @@ void gncJobSetActive (GncJob *job, gboolean active)
}
static void
qofJobSetOwner (GncJob *job, QofEntity *ent)
qofJobSetOwner (GncJob *job, QofInstance *ent)
{
if(!job || !ent) { return; }
qof_begin_edit(&job->inst);
@ -315,11 +315,11 @@ gboolean gncJobGetActive (GncJob *job)
return job->active;
}
static QofEntity*
static QofInstance*
qofJobGetOwner (GncJob *job)
{
if(!job) { return NULL; }
return QOF_ENTITY(qofOwnerGetOwner(&job->owner));
return QOF_INSTANCE(qofOwnerGetOwner(&job->owner));
}
/* Other functions */

View File

@ -53,6 +53,6 @@ GncJob * gncCloneJob (GncJob *from, QofBook *book);
*/
GncJob * gncJobObtainTwin (GncJob *from, QofBook *book);
#define gncJobSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
#define gncJobSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
#endif /* GNC_JOBP_H_ */

View File

@ -71,7 +71,7 @@ G_INLINE_FUNC void mark_order (GncOrder *order);
void mark_order (GncOrder *order)
{
qof_instance_set_dirty(&order->inst);
qof_event_gen (&order->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&order->inst, QOF_EVENT_MODIFY, NULL);
}
/* =============================================================== */
@ -92,7 +92,7 @@ GncOrder *gncOrderCreate (QofBook *book)
order->active = TRUE;
qof_event_gen (&order->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&order->inst, QOF_EVENT_CREATE, NULL);
return order;
}
@ -108,7 +108,7 @@ static void gncOrderFree (GncOrder *order)
{
if (!order) return;
qof_event_gen (&order->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&order->inst, QOF_EVENT_DESTROY, NULL);
g_list_free (order->entries);
CACHE_REMOVE (order->id);
@ -152,7 +152,7 @@ gncCloneOrder (GncOrder *from, QofBook *book)
order->entries = g_list_prepend (order->entries, entry);
}
qof_event_gen (&order->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&order->inst, QOF_EVENT_CREATE, NULL);
return order;
}
@ -373,7 +373,7 @@ int gncOrderCompare (GncOrder *a, GncOrder *b)
compare = timespec_cmp (&(a->closed), &(b->closed));
if (compare) return compare;
return guid_compare (&(a->inst.entity.guid), &(b->inst.entity.guid));
return guid_compare (&(a->inst.guid), &(b->inst.guid));
}
/* =========================================================== */

View File

@ -54,6 +54,6 @@ GncOrder * gncCloneOrder (GncOrder *from, QofBook *);
*/
GncOrder * gncOrderObtainTwin (GncOrder *from, QofBook *book);
#define gncOrderSetGUID(O,G) qof_entity_set_guid(QOF_ENTITY(O),(G))
#define gncOrderSetGUID(O,G) qof_instance_set_guid(QOF_INSTANCE(O),(G))
#endif /* GNC_ORDERP_H_ */

View File

@ -138,10 +138,10 @@ qofOwnerGetType(GncOwner *owner)
return type;
}
QofEntity*
QofInstance*
qofOwnerGetOwner (GncOwner *owner)
{
QofEntity *ent;
QofInstance *ent;
if(!owner) { return NULL; }
ent = NULL;
@ -154,19 +154,19 @@ qofOwnerGetOwner (GncOwner *owner)
break;
}
case GNC_OWNER_CUSTOMER : {
ent = QOF_ENTITY(owner->owner.customer);
ent = QOF_INSTANCE(owner->owner.customer);
break;
}
case GNC_OWNER_JOB : {
ent = QOF_ENTITY(owner->owner.job);
ent = QOF_INSTANCE(owner->owner.job);
break;
}
case GNC_OWNER_VENDOR : {
ent = QOF_ENTITY(owner->owner.vendor);
ent = QOF_INSTANCE(owner->owner.vendor);
break;
}
case GNC_OWNER_EMPLOYEE : {
ent = QOF_ENTITY(owner->owner.employee);
ent = QOF_INSTANCE(owner->owner.employee);
break;
}
}
@ -174,7 +174,7 @@ qofOwnerGetOwner (GncOwner *owner)
}
void
qofOwnerSetEntity (GncOwner *owner, QofEntity *ent)
qofOwnerSetEntity (GncOwner *owner, QofInstance *ent)
{
if(!owner || !ent) { return; }
if(0 == safe_strcmp(ent->e_type, GNC_ID_CUSTOMER))

View File

@ -63,9 +63,9 @@ to QOF as they can be used by objects like GncInvoice.
/** return the type for the collection. */
QofIdType qofOwnerGetType(GncOwner *owner);
/** return the owner itself as an entity. */
QofEntity* qofOwnerGetOwner (GncOwner *owner);
QofInstance* qofOwnerGetOwner (GncOwner *owner);
/** set the owner from the entity. */
void qofOwnerSetEntity (GncOwner *owner, QofEntity *ent);
void qofOwnerSetEntity (GncOwner *owner, QofInstance *ent);
gboolean
gncOwnerRegister(void);

View File

@ -144,7 +144,7 @@ static inline void
mark_table (GncTaxTable *table)
{
qof_instance_set_dirty(&table->inst);
qof_event_gen (&table->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&table->inst, QOF_EVENT_MODIFY, NULL);
}
static inline void
@ -212,7 +212,7 @@ gncTaxTableCreate (QofBook *book)
qof_instance_init (&table->inst, _GNC_MOD_NAME, book);
table->name = CACHE_INSERT ("");
addObj (table);
qof_event_gen (&table->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&table->inst, QOF_EVENT_CREATE, NULL);
return table;
}
@ -264,7 +264,7 @@ gncCloneTaxTable (GncTaxTable *from, QofBook *book)
}
addObj (table);
qof_event_gen (&table->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&table->inst, QOF_EVENT_CREATE, NULL);
return table;
}
@ -300,7 +300,7 @@ gncTaxTableFree (GncTaxTable *table)
if (!table) return;
qof_event_gen (&table->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&table->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (table->name);
remObj (table);

View File

@ -63,6 +63,6 @@ GncTaxTable * gncCloneTaxTable (GncTaxTable *from, QofBook *book);
*/
GncTaxTable * gncTaxTableObtainTwin (GncTaxTable *from, QofBook *book);
#define gncTaxTableSetGUID(E,G) qof_entity_set_guid(QOF_ENTITY(E),(G))
#define gncTaxTableSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
#endif /* GNC_TAXTABLEP_H_ */

View File

@ -68,7 +68,7 @@ G_INLINE_FUNC void mark_vendor (GncVendor *vendor);
void mark_vendor (GncVendor *vendor)
{
qof_instance_set_dirty(&vendor->inst);
qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&vendor->inst, QOF_EVENT_MODIFY, NULL);
}
/* ============================================================== */
@ -86,12 +86,12 @@ GncVendor *gncVendorCreate (QofBook *book)
vendor->id = CACHE_INSERT ("");
vendor->name = CACHE_INSERT ("");
vendor->notes = CACHE_INSERT ("");
vendor->addr = gncAddressCreate (book, &vendor->inst.entity);
vendor->addr = gncAddressCreate (book, &vendor->inst);
vendor->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
vendor->active = TRUE;
vendor->jobs = NULL;
qof_event_gen (&vendor->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&vendor->inst, QOF_EVENT_CREATE, NULL);
return vendor;
}
@ -107,7 +107,7 @@ static void gncVendorFree (GncVendor *vendor)
{
if (!vendor) return;
qof_event_gen (&vendor->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&vendor->inst, QOF_EVENT_DESTROY, NULL);
CACHE_REMOVE (vendor->id);
CACHE_REMOVE (vendor->name);
@ -140,7 +140,7 @@ gncCloneVendor (GncVendor *from, QofBook *book)
vendor->id = CACHE_INSERT (from->id);
vendor->name = CACHE_INSERT (from->name);
vendor->notes = CACHE_INSERT (from->notes);
vendor->addr = gncCloneAddress (from->addr, &vendor->inst.entity, book);
vendor->addr = gncCloneAddress (from->addr, &vendor->inst, book);
vendor->taxincluded = from->taxincluded;
vendor->taxtable_override = from->taxtable_override;
vendor->active = from->active;
@ -161,7 +161,7 @@ gncCloneVendor (GncVendor *from, QofBook *book)
vendor->jobs = g_list_prepend(vendor->jobs, job);
}
qof_event_gen (&vendor->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&vendor->inst, QOF_EVENT_CREATE, NULL);
return vendor;
}
@ -293,7 +293,7 @@ void gncVendorSetTaxTable (GncVendor *vendor, GncTaxTable *table)
}
static void
qofVendorSetAddr (GncVendor *vendor, QofEntity *addr_ent)
qofVendorSetAddr (GncVendor *vendor, QofInstance *addr_ent)
{
GncAddress *addr;
@ -396,7 +396,7 @@ void gncVendorAddJob (GncVendor *vendor, GncJob *job)
vendor->jobs = g_list_insert_sorted (vendor->jobs, job,
(GCompareFunc)gncJobCompare);
qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&vendor->inst, QOF_EVENT_MODIFY, NULL);
}
void gncVendorRemoveJob (GncVendor *vendor, GncJob *job)
@ -414,7 +414,7 @@ void gncVendorRemoveJob (GncVendor *vendor, GncJob *job)
g_list_free_1 (node);
}
qof_event_gen (&vendor->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&vendor->inst, QOF_EVENT_MODIFY, NULL);
}
void gncVendorBeginEdit (GncVendor *vendor)

View File

@ -52,7 +52,7 @@ GncVendor * gncCloneVendor (GncVendor *from, QofBook *);
* different ways.
*/
GncVendor * gncVendorObtainTwin (GncVendor *from, QofBook *book);
#define gncVendorSetGUID(V,G) qof_entity_set_guid(QOF_ENTITY(V),(G))
#define gncVendorSetGUID(V,G) qof_instance_set_guid(QOF_INSTANCE(V),(G))
#endif /* GNC_VENDORP_H_ */

View File

@ -38,7 +38,7 @@ test_string_fcn (GncAddress *address, const char *message,
static void
test_address (void)
{
QofEntity ent;
QofInstance ent;
GncAddress *address;
QofBook *book = qof_book_new ();

View File

@ -79,7 +79,7 @@ static gboolean
customerCB (const char *location, const char *label,
gboolean new_window, GNCURLResult * result)
{
QofEntity *entity;
QofInstance *entity;
GncCustomer *customer;
/* href="...:customer=<guid>" */
@ -94,7 +94,7 @@ static gboolean
vendorCB (const char *location, const char *label,
gboolean new_window, GNCURLResult * result)
{
QofEntity *entity;
QofInstance *entity;
GncVendor *vendor;
/* href="...:vendor=<guid>" */
@ -109,7 +109,7 @@ static gboolean
employeeCB (const char *location, const char *label,
gboolean new_window, GNCURLResult * result)
{
QofEntity *entity;
QofInstance *entity;
GncEmployee *employee;
/* href="...:employee=<guid>" */
@ -125,7 +125,7 @@ static gboolean
invoiceCB (const char *location, const char *label,
gboolean new_window, GNCURLResult * result)
{
QofEntity *entity;
QofInstance *entity;
GncInvoice *invoice;
/* href="...:invoice=<guid>" */
@ -141,7 +141,7 @@ static gboolean
jobCB (const char *location, const char *label,
gboolean new_window, GNCURLResult * result)
{
QofEntity *entity;
QofInstance *entity;
GncJob *job;
/* href="...:job=<guid>" */

View File

@ -727,10 +727,10 @@ gnc_plugin_business_cmd_export_invoice (GtkAction *action, GncMainWindowActionDa
{
qof_session_begin(chart_session, filename, TRUE, TRUE);
coll = qof_book_get_collection(book, GNC_ID_INVOICE);
success = qof_entity_copy_coll_r(chart_session, coll);
success = qof_instance_copy_coll_r(chart_session, coll);
/* Need to get the GList of GncEntry's - KVP */
coll = qof_book_get_collection(book, GNC_ID_CUSTOMER);
success = qof_entity_copy_coll_r(chart_session, coll);
success = qof_instance_copy_coll_r(chart_session, coll);
if(success)
{
qof_session_save(chart_session, NULL);
@ -762,7 +762,7 @@ gnc_plugin_business_cmd_export_customer (GtkAction *action, GncMainWindowActionD
{
qof_session_begin(chart_session, filename, TRUE, TRUE);
coll = qof_book_get_collection(book, GNC_ID_CUSTOMER);
success = qof_entity_copy_coll_r(chart_session, coll);
success = qof_instance_copy_coll_r(chart_session, coll);
if(success)
{
qof_session_save(chart_session, NULL);
@ -794,7 +794,7 @@ gnc_plugin_business_cmd_export_vendor (GtkAction *action, GncMainWindowActionDat
{
qof_session_begin(chart_session, filename, TRUE, TRUE);
coll = qof_book_get_collection(book, GNC_ID_VENDOR);
success = qof_entity_copy_coll_r(chart_session, coll);
success = qof_instance_copy_coll_r(chart_session, coll);
if(success)
{
qof_session_save(chart_session, NULL);
@ -826,7 +826,7 @@ gnc_plugin_business_cmd_export_employee (GtkAction *action, GncMainWindowActionD
{
qof_session_begin(chart_session, filename, TRUE, TRUE);
coll = qof_book_get_collection(book, GNC_ID_EMPLOYEE);
success = qof_entity_copy_coll_r(chart_session, coll);
success = qof_instance_copy_coll_r(chart_session, coll);
if(success)
{
qof_session_save(chart_session, NULL);

View File

@ -29,7 +29,7 @@ base QOF type and references to other objects - usually by storing
the type of the referenced object and the GUID of the referenced object
as the value and the GUID of the original object as the key in a
GHashTable or other lookup mechanism within the backend. See
::QofEntityReference.
::QofInstanceReference.
\section backendqueries Handling Queries:

View File

@ -233,7 +233,7 @@ xaccMallocAccount (QofBook *book)
acc = g_new (Account, 1);
xaccInitAccount (acc, book);
qof_event_gen (&acc->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&acc->inst, QOF_EVENT_CREATE, NULL);
return acc;
}
@ -342,7 +342,7 @@ xaccFreeAccount (Account *acc)
if (!acc) return;
qof_event_gen (&acc->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&acc->inst, QOF_EVENT_DESTROY, NULL);
if (acc->children)
{
@ -430,7 +430,7 @@ xaccAccountBeginEdit (Account *acc)
static void on_done(QofInstance *inst)
{
/* old event style */
qof_event_gen (&inst->entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (inst, QOF_EVENT_MODIFY, NULL);
}
static void on_err (QofInstance *inst, QofBackendError errcode)
@ -448,7 +448,7 @@ static void acc_free (QofInstance *inst)
}
static void
destroy_pending_splits_for_account(QofEntity *ent, gpointer acc)
destroy_pending_splits_for_account(QofInstance *ent, gpointer acc)
{
Transaction *trans = (Transaction *) ent;
Split *split;
@ -629,7 +629,7 @@ xaccAccountEqual(const Account *aa, const Account *ab, gboolean check_guids)
}
if(check_guids) {
if(!guid_equal(&aa->inst.entity.guid, &ab->inst.entity.guid))
if(!guid_equal(&aa->inst.guid, &ab->inst.guid))
{
PWARN ("GUIDs differ");
return FALSE;
@ -831,7 +831,7 @@ xaccAccountSetGUID (Account *acc, const GUID *guid)
/* XXX this looks fishy and weird to me ... */
PINFO("acct=%p", acc);
xaccAccountBeginEdit (acc);
qof_entity_set_guid (&acc->inst.entity, guid);
qof_instance_set_guid (&acc->inst, guid);
qof_instance_set_dirty(&acc->inst);
xaccAccountCommitEdit (acc);
}
@ -1160,7 +1160,7 @@ xaccAccountOrder (const Account *aa, const Account *ab)
return result;
/* guarantee a stable sort */
return guid_compare (&(aa->inst.entity.guid), &(ab->inst.entity.guid));
return guid_compare (&(aa->inst.guid), &(ab->inst.guid));
}
static int
@ -1222,7 +1222,7 @@ xaccAccountSetDescription (Account *acc, const char *str)
}
static void
qofAccountSetParent (Account *acc, QofEntity *parent)
qofAccountSetParent (Account *acc, QofInstance *parent)
{
Account *parent_acc;
@ -1405,10 +1405,10 @@ gnc_account_append_child (Account *new_parent, Account *child)
*/
PWARN ("reparenting accounts across books is not correctly supported\n");
qof_event_gen (&child->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&child->inst, QOF_EVENT_DESTROY, NULL);
col = qof_book_get_collection (new_parent->inst.book, GNC_ID_ACCOUNT);
qof_collection_insert_entity (col, &child->inst.entity);
qof_event_gen (&child->inst.entity, QOF_EVENT_CREATE, NULL);
qof_collection_insert_entity (col, &child->inst);
qof_event_gen (&child->inst, QOF_EVENT_CREATE, NULL);
}
}
child->parent = new_parent;
@ -1420,8 +1420,8 @@ gnc_account_append_child (Account *new_parent, Account *child)
* to send a MODIFY event. If the gtktreemodelfilter code gets the
* MODIFY before it gets the ADD, it gets very confused and thinks
* that two nodes have been added. */
qof_event_gen (&child->inst.entity, QOF_EVENT_ADD, NULL);
// qof_event_gen (&new_parent->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&child->inst, QOF_EVENT_ADD, NULL);
// qof_event_gen (&new_parent->inst, QOF_EVENT_MODIFY, NULL);
xaccAccountCommitEdit (child);
// xaccAccountCommitEdit(new_parent);
@ -1451,12 +1451,12 @@ gnc_account_remove_child (Account *parent, Account *child)
parent->children = g_list_remove (parent->children, child);
/* Now send the event. */
qof_event_gen(&child->inst.entity, QOF_EVENT_REMOVE, &ed);
qof_event_gen(&child->inst, QOF_EVENT_REMOVE, &ed);
/* clear the account's parent pointer after REMOVE event generation. */
child->parent = NULL;
qof_event_gen (&parent->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&parent->inst, QOF_EVENT_MODIFY, NULL);
}
Account *
@ -3178,7 +3178,7 @@ gnc_account_copy_children (Account *to, Account *from)
gnc_account_copy_children(to_acc, from_acc);
}
xaccAccountCommitEdit (to_acc);
qof_event_gen (&to_acc->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&to_acc->inst, QOF_EVENT_CREATE, NULL);
/* DRH - Should this send ADD/REMOVE events */
}
xaccAccountCommitEdit(from);
@ -3225,8 +3225,8 @@ gnc_account_merge_children (Account *parent)
gnc_account_append_child (acc_a, (Account *)worker->data);
g_list_free(work);
qof_event_gen (&acc_a->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&acc_b->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&acc_a->inst, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&acc_b->inst, QOF_EVENT_MODIFY, NULL);
}
/* recurse to do the children's children */

View File

@ -216,8 +216,8 @@ Account *gnc_book_get_root_account(QofBook *book);
void gnc_book_set_root_account(QofBook *book, Account *root);
/** @deprecated */
#define xaccAccountGetGUID(X) qof_entity_get_guid(QOF_ENTITY(X))
#define xaccAccountReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_ENTITY(X))) : *(guid_null()))
#define xaccAccountGetGUID(X) qof_instance_get_guid(QOF_INSTANCE(X))
#define xaccAccountReturnGUID(X) (X ? *(qof_instance_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
/** The xaccAccountLookup() subroutine will return the
* account associated with the given id, or NULL

View File

@ -168,12 +168,10 @@ get_abbrev_month_name(guint month)
static void
xaccFreqSpecInit( FreqSpec *fs, QofBook *book )
{
QofCollection *col;
g_return_if_fail( fs );
g_return_if_fail (book);
col = qof_book_get_collection (book, QOF_ID_FREQSPEC);
qof_entity_init (&fs->entity, QOF_ID_FREQSPEC, col);
qof_instance_init (&fs->entity, QOF_ID_FREQSPEC, book);
fs->type = INVALID;
fs->uift = UIFREQ_ONCE;
@ -224,7 +222,7 @@ xaccFreqSpecFree( FreqSpec *fs )
qof_event_gen( &fs->entity, QOF_EVENT_DESTROY , NULL);
xaccFreqSpecCleanUp( fs );
qof_entity_release (&fs->entity);
qof_instance_release (&fs->entity);
g_free( fs );
}

View File

@ -37,7 +37,7 @@ Currently the only files which include this file are:
struct gncp_freq_spec
{
QofEntity entity;
QofInstance entity;
FreqType type;
UIFreqType uift;
union u {

View File

@ -5,7 +5,7 @@
* void xaccGUIDNew (GUID *guid, QofBook *book)
*/
#define xaccGUIDNew(guid,book) \
qof_entity_guid_new (qof_book_get_entity_table (book), (guid))
qof_instance_guid_new (qof_book_get_entity_table (book), (guid))
#define xaccGUIDNULL guid_null
@ -14,16 +14,16 @@
#define GNCIdTypeConst QofIdTypeConst
#define GNCIdType QofIdType
#define GNCEntityTable QofEntityTable
#define GNCEntityTable QofInstanceTable
#define xaccGUIDTypeEntityTable qof_guid_type
#define xaccEntityTableNew qof_entity_new
#define xaccEntityTableDestroy qof_entity_destroy
#define xaccGUIDNewEntityTable qof_entity_guid_new
#define xaccLookupEntity qof_entity_lookup
#define xaccStoreEntity qof_entity_store
#define xaccRemoveEntity qof_entity_remove
#define xaccForeachEntity qof_entity_foreach
#define xaccEntityTableNew qof_instance_new
#define xaccEntityTableDestroy qof_instance_destroy
#define xaccGUIDNewEntityTable qof_instance_guid_new
#define xaccLookupEntity qof_instance_lookup
#define xaccStoreEntity qof_instance_store
#define xaccRemoveEntity qof_instance_remove
#define xaccForeachEntity qof_instance_foreach
#define foreachObjectCB QofEntityForeachCB
#define foreachObjectCB QofInstanceForeachCB

View File

@ -89,7 +89,7 @@ gnc_book_insert_trans_clobber (QofBook *book, Transaction *trans)
/* Fiddle the transaction into place in the new book */
col = qof_book_get_collection (book, GNC_ID_TRANS);
qof_collection_insert_entity (col, &newtrans->inst.entity);
qof_collection_insert_entity (col, &newtrans->inst);
newtrans->inst.book = book;
col = qof_book_get_collection (book, GNC_ID_SPLIT);
@ -101,7 +101,7 @@ gnc_book_insert_trans_clobber (QofBook *book, Transaction *trans)
/* move the split into the new book ... */
s->inst.book = book;
qof_collection_insert_entity(col, &s->inst.entity);
qof_collection_insert_entity(col, &s->inst);
/* find the twin account, and re-parent to that. */
twin = xaccAccountLookupTwin (s->acc, book);
@ -118,7 +118,7 @@ gnc_book_insert_trans_clobber (QofBook *book, Transaction *trans)
}
xaccTransCommitEdit (newtrans);
qof_event_gen (&newtrans->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&newtrans->inst, QOF_EVENT_CREATE, NULL);
LEAVE ("trans=%p %s", trans, trans->description);
}
@ -152,7 +152,7 @@ gnc_book_insert_trans (QofBook *book, Transaction *trans)
col = qof_book_get_collection (book, GNC_ID_TRANS);
trans->inst.book = book;
qof_collection_insert_entity (col, &trans->inst.entity);
qof_collection_insert_entity (col, &trans->inst);
col = qof_book_get_collection (book, GNC_ID_SPLIT);
for (node = trans->splits; node; node = node->next)
@ -164,7 +164,7 @@ gnc_book_insert_trans (QofBook *book, Transaction *trans)
if (s->inst.book != book)
{
s->inst.book = book;
qof_collection_insert_entity (col, &s->inst.entity);
qof_collection_insert_entity (col, &s->inst);
}
/* Find the twin account, and re-parent to that. */
@ -186,7 +186,7 @@ gnc_book_insert_trans (QofBook *book, Transaction *trans)
}
xaccTransCommitEdit (trans);
qof_event_gen (&trans->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&trans->inst, QOF_EVENT_MODIFY, NULL);
LEAVE ("trans=%p %s", trans, trans->description);
}
@ -228,7 +228,7 @@ gnc_book_insert_lot (QofBook *book, GNCLot *lot)
col = qof_book_get_collection (book, GNC_ID_LOT);
lot->inst.book = book;
qof_collection_insert_entity (col, &lot->inst.entity);
qof_collection_insert_entity (col, &lot->inst);
/* Move the splits over (only if they haven't already been moved). */
col = qof_book_get_collection (book, GNC_ID_SPLIT);
@ -238,7 +238,7 @@ gnc_book_insert_lot (QofBook *book, GNCLot *lot)
if (s->inst.book != book)
{
s->inst.book = book;
qof_collection_insert_entity (col, &s->inst.entity);
qof_collection_insert_entity (col, &s->inst);
}
}
@ -280,7 +280,7 @@ gnc_book_insert_price (QofBook *book, GNCPrice *pr)
col = qof_book_get_collection (book, GNC_ID_PRICE);
pr->inst.book = book;
qof_collection_insert_entity (col, &pr->inst.entity);
qof_collection_insert_entity (col, &pr->inst);
gnc_pricedb_remove_price (pr->db, pr);
gnc_pricedb_add_price (gnc_pricedb_get_db (book), pr);

View File

@ -197,7 +197,7 @@ gnc_sxes_add_sx(SchedXactions *sxes, SchedXaction *sx)
if (g_list_find(sxes->sx_list, sx) != NULL)
return;
sxes->sx_list = g_list_append(sxes->sx_list, sx);
qof_event_gen(&sxes->inst.entity, GNC_EVENT_ITEM_ADDED, (gpointer)sx);
qof_event_gen(&sxes->inst, GNC_EVENT_ITEM_ADDED, (gpointer)sx);
}
void
@ -208,7 +208,7 @@ gnc_sxes_del_sx(SchedXactions *sxes, SchedXaction *sx)
if (to_remove == NULL)
return;
sxes->sx_list = g_list_delete_link(sxes->sx_list, to_remove);
qof_event_gen(&sxes->inst.entity, GNC_EVENT_ITEM_REMOVED, (gpointer)sx);
qof_event_gen(&sxes->inst, GNC_EVENT_ITEM_REMOVED, (gpointer)sx);
}
/* ====================================================================== */

View File

@ -71,7 +71,7 @@ xaccSchedXactionInit(SchedXaction *sx, QofBook *book)
/* create a new template account for our splits */
sx->template_acct = xaccMallocAccount(book);
xaccAccountSetName( sx->template_acct,
guid_to_string( &sx->inst.entity.guid ));
guid_to_string( &sx->inst.guid ));
xaccAccountSetCommodity
(sx->template_acct,
gnc_commodity_new( book,
@ -91,7 +91,7 @@ xaccSchedXactionMalloc(QofBook *book)
sx = g_new0( SchedXaction, 1 );
xaccSchedXactionInit( sx, book );
qof_event_gen( &sx->inst.entity, QOF_EVENT_CREATE , NULL);
qof_event_gen( &sx->inst, QOF_EVENT_CREATE , NULL);
return sx;
}
@ -158,7 +158,7 @@ xaccSchedXactionFree( SchedXaction *sx )
if ( sx == NULL ) return;
xaccFreqSpecFree( sx->freq );
qof_event_gen( &sx->inst.entity, QOF_EVENT_DESTROY , NULL);
qof_event_gen( &sx->inst, QOF_EVENT_DESTROY , NULL);
if ( sx->name )
g_free( sx->name );
@ -206,7 +206,7 @@ static void commit_err (QofInstance *inst, QofBackendError errcode)
static void commit_done(QofInstance *inst)
{
qof_event_gen (&inst->entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (inst, QOF_EVENT_MODIFY, NULL);
}
static void noop(QofInstance *inst) {}

View File

@ -111,7 +111,7 @@ typedef struct _temporalStateData {
gint num_inst;
} temporalStateData;
#define xaccSchedXactionSetGUID(X,G) qof_entity_set_guid(QOF_ENTITY(X),(G))
#define xaccSchedXactionSetGUID(X,G) qof_instance_set_guid(QOF_INSTANCE(X),(G))
/**
* Creates and initializes a scheduled transaction.
@ -297,7 +297,7 @@ gboolean SXRegister (void);
/** \deprecated */
#define xaccSchedXactionIsDirty(X) qof_instance_is_dirty (QOF_INSTANCE(X))
/** \deprecated */
#define xaccSchedXactionGetGUID(X) qof_entity_get_guid(QOF_ENTITY(X))
#define xaccSchedXactionGetGUID(X) qof_instance_get_guid(QOF_INSTANCE(X))
/** \deprecated */
#define xaccSchedXactionGetSlots(X) qof_instance_get_slots(QOF_INSTANCE(X))

View File

@ -319,7 +319,7 @@ remove_guids (Split *sa, Split *sb)
/* Find and remove the matching guid's */
ksub = (KvpFrame*)gnc_kvp_bag_find_by_guid (sa->inst.kvp_data, "lot-split",
"peer_guid", &sb->inst.entity.guid);
"peer_guid", &sb->inst.guid);
if (ksub)
{
gnc_kvp_bag_remove_frame (sa->inst.kvp_data, "lot-split", ksub);
@ -328,7 +328,7 @@ remove_guids (Split *sa, Split *sb)
/* Now do it in the other direction */
ksub = (KvpFrame*)gnc_kvp_bag_find_by_guid (sb->inst.kvp_data, "lot-split",
"peer_guid", &sa->inst.entity.guid);
"peer_guid", &sa->inst.guid);
if (ksub)
{
gnc_kvp_bag_remove_frame (sb->inst.kvp_data, "lot-split", ksub);
@ -422,7 +422,7 @@ restart:
* repeatedly merging adjacent subsplits, we'll get the non-
* adjacent ones too. */
if (gnc_kvp_bag_find_by_guid (split->inst.kvp_data, "lot-split",
"peer_guid", &s->inst.entity.guid) == NULL)
"peer_guid", &s->inst.guid) == NULL)
continue;
merge_splits (split, s);

View File

@ -154,9 +154,9 @@ xaccDupeSplit (const Split *s)
* splits as something official. If we ever use this split, we'll
* have to fix this up.
*/
split->inst.entity.e_type = NULL;
split->inst.entity.collection = NULL;
split->inst.entity.guid = s->inst.entity.guid;
split->inst.e_type = NULL;
split->inst.collection = NULL;
split->inst.guid = s->inst.guid;
split->inst.book = s->inst.book;
split->parent = s->parent;
@ -336,7 +336,7 @@ xaccSplitEqual(const Split *sa, const Split *sb,
if (sa == sb) return TRUE;
if (check_guids) {
if (!guid_equal(&(sa->inst.entity.guid), &(sb->inst.entity.guid)))
if (!guid_equal(&(sa->inst.guid), &(sb->inst.guid)))
{
PWARN ("GUIDs differ");
return FALSE;
@ -512,9 +512,9 @@ xaccSplitCommitEdit(Split *s)
if (node) {
orig_acc->splits = g_list_delete_link (orig_acc->splits, node);
//FIXME: find better event type
qof_event_gen (&orig_acc->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&orig_acc->inst, QOF_EVENT_MODIFY, NULL);
// And send the account-based event, too
qof_event_gen(&orig_acc->inst.entity, GNC_EVENT_ITEM_REMOVED, s);
qof_event_gen(&orig_acc->inst, GNC_EVENT_ITEM_REMOVED, s);
} else PERR("Account lost track of moved or deleted split.");
orig_acc->balance_dirty = TRUE;
xaccAccountRecomputeBalance(orig_acc);
@ -537,10 +537,10 @@ xaccSplitCommitEdit(Split *s)
xaccAccountInsertLot (acc, s->lot);
//FIXME: find better event
qof_event_gen (&acc->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
/* Also send an event based on the account */
qof_event_gen(&acc->inst.entity, GNC_EVENT_ITEM_ADDED, s);
qof_event_gen(&acc->inst, GNC_EVENT_ITEM_ADDED, s);
} else PERR("Account grabbed split prematurely.");
acc->balance_dirty = TRUE;
xaccSplitSetAmount(s, xaccSplitGetAmount(s));
@ -549,12 +549,12 @@ xaccSplitCommitEdit(Split *s)
if (s->parent != s->orig_parent) {
//FIXME: find better event
if (s->orig_parent)
qof_event_gen(&s->orig_parent->inst.entity, QOF_EVENT_MODIFY,
qof_event_gen(&s->orig_parent->inst, QOF_EVENT_MODIFY,
NULL);
}
if (s->lot) {
/* A change of value/amnt affects gains display, etc. */
qof_event_gen (&s->lot->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&s->lot->inst, QOF_EVENT_MODIFY, NULL);
}
/* Important: we save off the original parent transaction and account
@ -590,7 +590,7 @@ xaccSplitRollbackEdit(Split *s)
s->inst.do_free = FALSE;
ed.node = s;
ed.idx = -1; /* unused */
qof_event_gen(&s->parent->inst.entity, GNC_EVENT_ITEM_ADDED, &ed);
qof_event_gen(&s->parent->inst, GNC_EVENT_ITEM_ADDED, &ed);
}
/* But for the parent trans, we want the intermediate events, so
@ -1117,7 +1117,7 @@ xaccSplitDestroy (Split *split)
ed.idx = xaccTransGetSplitIndex(trans, split);
qof_instance_set_dirty(QOF_INSTANCE(split));
split->inst.do_free = TRUE;
qof_event_gen(&trans->inst.entity, GNC_EVENT_ITEM_REMOVED, &ed);
qof_event_gen(&trans->inst, GNC_EVENT_ITEM_REMOVED, &ed);
xaccTransCommitEdit(trans);
return TRUE;
@ -1172,7 +1172,7 @@ xaccSplitDateOrder (const Split *sa, const Split *sb)
DATE_CMP(sa,sb,date_reconciled);
/* else, sort on guid - keeps sort stable. */
retval = guid_compare(&(sa->inst.entity.guid), &(sb->inst.entity.guid));
retval = guid_compare(&(sa->inst.guid), &(sb->inst.guid));
if (retval) return retval;
return 0;
@ -1487,7 +1487,7 @@ xaccSplitSetParent(Split *s, Transaction *t)
ed.node = s;
if (old_trans) {
ed.idx = xaccTransGetSplitIndex(old_trans, s);
qof_event_gen(&old_trans->inst.entity, GNC_EVENT_ITEM_REMOVED, &ed);
qof_event_gen(&old_trans->inst, GNC_EVENT_ITEM_REMOVED, &ed);
}
s->parent = t;
@ -1503,7 +1503,7 @@ xaccSplitSetParent(Split *s, Transaction *t)
t->splits = g_list_append(t->splits, s);
ed.idx = -1; /* unused */
qof_event_gen(&t->inst.entity, GNC_EVENT_ITEM_ADDED, &ed);
qof_event_gen(&t->inst, GNC_EVENT_ITEM_ADDED, &ed);
}
xaccTransCommitEdit(t);
}
@ -1769,7 +1769,7 @@ no_op (gpointer obj, const QofParam *p)
}
static void
qofSplitSetParentTrans(Split *s, QofEntity *ent)
qofSplitSetParentTrans(Split *s, QofInstance *ent)
{
Transaction *trans = (Transaction*)ent;
@ -1778,7 +1778,7 @@ qofSplitSetParentTrans(Split *s, QofEntity *ent)
}
static void
qofSplitSetAccount(Split *s, QofEntity *ent)
qofSplitSetAccount(Split *s, QofInstance *ent)
{
Account *acc = (Account*)ent;
@ -1798,7 +1798,7 @@ gboolean xaccSplitRegister (void)
{ "d-share-amount", QOF_TYPE_DOUBLE,
(QofAccessFunc)DxaccSplitGetShareAmount, NULL },
{ "d-share-int64", QOF_TYPE_INT64,
(QofAccessFunc)qof_entity_get_guid, NULL },
(QofAccessFunc)qof_instance_get_guid, NULL },
{ SPLIT_BALANCE, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccSplitGetBalance, NULL },
{ SPLIT_CLEARED_BALANCE, QOF_TYPE_NUMERIC,
@ -1839,7 +1839,7 @@ gboolean xaccSplitRegister (void)
{ SPLIT_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccSplitGetSlots, NULL },
{ QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)xaccSplitGetBook, NULL },
{ QOF_PARAM_GUID, QOF_TYPE_GUID,
(QofAccessFunc)qof_entity_get_guid, NULL },
(QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};

View File

@ -72,7 +72,7 @@ gnc_numeric xaccSplitConvertAmount (const Split *split, Account * account);
Split * xaccMallocSplit (QofBook *book);
/* Reinit a previously malloc'd split. Split remains in the book it
was already in, and the QofEntity portions also remain unchanged.
was already in, and the QofInstance portions also remain unchanged.
It's basically the data elements that are reverted to default
values. */
void xaccSplitReinit(Split * split);
@ -482,9 +482,9 @@ gnc_numeric xaccSplitVoidFormerValue(const Split *split);
/** @} */
/** \deprecated */
#define xaccSplitGetGUID(X) qof_entity_get_guid(QOF_ENTITY(X))
#define xaccSplitGetGUID(X) qof_instance_get_guid(QOF_INSTANCE(X))
/** \deprecated */
#define xaccSplitReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_ENTITY(X))) : *(guid_null()))
#define xaccSplitReturnGUID(X) (X ? *(qof_instance_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
#endif /* XACC_SPLIT_H */
/** @} */

View File

@ -135,7 +135,7 @@ struct split_s
/* Set the split's GUID. This should only be done when reading
* a split from a datafile, or some other external source. Never
* call this on an existing split! */
#define xaccSplitSetGUID(s,g) qof_entity_set_guid(QOF_ENTITY(s),g)
#define xaccSplitSetGUID(s,g) qof_instance_set_guid(QOF_INSTANCE(s),g)
/* The xaccFreeSplit() method simply frees all memory associated
* with the split. It does not verify that the split isn't

View File

@ -219,12 +219,12 @@ void gen_event_trans (Transaction *trans)
Account *account = s->acc;
GNCLot *lot = s->lot;
if (account)
qof_event_gen (&account->inst.entity, GNC_EVENT_ITEM_CHANGED, s);
qof_event_gen (&account->inst, GNC_EVENT_ITEM_CHANGED, s);
if (lot)
{
/* A change of transaction date might affect opening date of lot */
qof_event_gen (&lot->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&lot->inst, QOF_EVENT_MODIFY, NULL);
}
}
#endif
@ -274,7 +274,7 @@ xaccMallocTransaction (QofBook *book)
trans = g_new(Transaction, 1);
xaccInitTransaction (trans, book);
qof_event_gen (&trans->inst.entity, QOF_EVENT_CREATE, NULL);
qof_event_gen (&trans->inst, QOF_EVENT_CREATE, NULL);
return trans;
}
@ -376,9 +376,9 @@ xaccDupeTransaction (const Transaction *t)
* the cloned transaction as something official. If we ever
* use this transaction, we'll have to fix this up.
*/
trans->inst.entity.e_type = NULL;
trans->inst.entity.guid = *guid_null();
trans->inst.entity.collection = NULL;
trans->inst.e_type = NULL;
trans->inst.guid = *guid_null();
trans->inst.collection = NULL;
trans->inst.book = t->inst.book;
trans->inst.editlevel = 0;
trans->inst.do_free = FALSE;
@ -522,7 +522,7 @@ xaccTransEqual(const Transaction *ta, const Transaction *tb,
if (ta == tb) return TRUE;
if (check_guids) {
if (!guid_equal(&(ta->inst.entity.guid), &(tb->inst.entity.guid)))
if (!guid_equal(&(ta->inst.guid), &(tb->inst.guid)))
{
PWARN ("GUIDs differ");
return FALSE;
@ -885,7 +885,7 @@ do_destroy (Transaction *trans)
if (!shutting_down)
xaccTransWriteLog (trans, 'D');
qof_event_gen (&trans->inst.entity, QOF_EVENT_DESTROY, NULL);
qof_event_gen (&trans->inst, QOF_EVENT_DESTROY, NULL);
/* We only own the splits that still think they belong to us. */
trans->splits = g_list_copy(trans->splits);
@ -953,14 +953,14 @@ static void trans_cleanup_commit(Transaction *trans)
ed.node = trans;
ed.idx = g_list_index(trans->splits, s);
trans->splits = g_list_remove(trans->splits, s);
qof_event_gen(&s->inst.entity, QOF_EVENT_REMOVE, &ed);
qof_event_gen(&s->inst, QOF_EVENT_REMOVE, &ed);
}
if (s->parent == trans) {
/* Split was either added, destroyed or just changed */
if (s->inst.do_free)
qof_event_gen(&s->inst.entity, QOF_EVENT_DESTROY, NULL);
else qof_event_gen(&s->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen(&s->inst, QOF_EVENT_DESTROY, NULL);
else qof_event_gen(&s->inst, QOF_EVENT_MODIFY, NULL);
xaccSplitCommitEdit(s);
}
}
@ -983,7 +983,7 @@ static void trans_cleanup_commit(Transaction *trans)
g_assert(trans->inst.editlevel == 0);
gen_event_trans (trans); //TODO: could be conditional
qof_event_gen (&trans->inst.entity, QOF_EVENT_MODIFY, NULL);
qof_event_gen (&trans->inst, QOF_EVENT_MODIFY, NULL);
}
void
@ -1241,7 +1241,7 @@ xaccTransOrder (const Transaction *ta, const Transaction *tb)
return retval;
/* else, sort on guid - keeps sort stable. */
return guid_compare(&(ta->inst.entity.guid), &(tb->inst.entity.guid));
return guid_compare(&(ta->inst.guid), &(tb->inst.guid));
}
/********************************************************************\
@ -1967,7 +1967,7 @@ gboolean xaccTransRegister (void)
{ QOF_PARAM_BOOK, QOF_ID_BOOK,
(QofAccessFunc)qof_instance_get_book, NULL },
{ QOF_PARAM_GUID, QOF_TYPE_GUID,
(QofAccessFunc)qof_entity_get_guid, NULL },
(QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};

View File

@ -550,9 +550,9 @@ Timespec xaccTransGetVoidTime(const Transaction *tr);
/** \deprecated */
#define xaccTransGetBook(X) qof_instance_get_book (QOF_INSTANCE(X))
/** \deprecated */
#define xaccTransGetGUID(X) qof_entity_get_guid(QOF_ENTITY(X))
#define xaccTransGetGUID(X) qof_instance_get_guid(QOF_INSTANCE(X))
/** \deprecated */
#define xaccTransReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_ENTITY(X))) : *(guid_null()))
#define xaccTransReturnGUID(X) (X ? *(qof_instance_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
/** \deprecated */
#define xaccTransGetSlots(X) qof_instance_get_slots (QOF_INSTANCE(X))

View File

@ -123,7 +123,7 @@ struct transaction_s
/* Set the transaction's GUID. This should only be done when reading
* a transaction from a datafile, or some other external source. Never
* call this on an existing transaction! */
#define xaccTransSetGUID(t,g) qof_entity_set_guid(QOF_ENTITY(t),g)
#define xaccTransSetGUID(t,g) qof_instance_set_guid(QOF_INSTANCE(t),g)
/* This routine makes a 'duplicate' of the indicated transaction.
* This routine cannot be exposed publically since the duplicate

Some files were not shown because too many files have changed in this diff Show More