Start putting an API in place for access to the members of the

QofInstance object.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16025 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton
2007-04-30 05:33:33 +00:00
parent 05f60bd341
commit ce65024722
22 changed files with 201 additions and 101 deletions

View File

@@ -132,13 +132,6 @@ qof_instance_get_guid (const QofInstance *inst)
return &(inst->guid);
}
QofBook *
qof_instance_get_book (const QofInstance *inst)
{
if (!inst) return NULL;
return inst->book;
}
void
qof_instance_set_guid (QofInstance *ent, const GUID *guid)
{
@@ -151,6 +144,20 @@ qof_instance_set_guid (QofInstance *ent, const GUID *guid)
qof_collection_insert_entity(col, ent);
}
const QofCollection *
qof_instance_get_collection (gconstpointer ptr)
{
g_return_val_if_fail(QOF_IS_INSTANCE(ptr), NULL);
return QOF_INSTANCE(ptr)->collection;
}
QofBook *
qof_instance_get_book (const QofInstance *inst)
{
if (!inst) return NULL;
return inst->book;
}
KvpFrame*
qof_instance_get_slots (const QofInstance *inst)
{
@@ -169,6 +176,38 @@ qof_instance_get_last_update (const QofInstance *inst)
return inst->last_update;
}
gint
qof_instance_get_editlevel (gconstpointer ptr)
{
g_return_val_if_fail(QOF_IS_INSTANCE(ptr), 0);
return QOF_INSTANCE(ptr)->editlevel;
}
void qof_instance_increase_editlevel (gpointer ptr)
{
g_return_if_fail(QOF_IS_INSTANCE(ptr));
QOF_INSTANCE(ptr)->editlevel++;
}
void qof_instance_decrease_editlevel (gpointer ptr)
{
g_return_if_fail(QOF_IS_INSTANCE(ptr));
QOF_INSTANCE(ptr)->editlevel--;
}
void qof_instance_reset_editlevel (gpointer ptr)
{
g_return_if_fail(QOF_IS_INSTANCE(ptr));
QOF_INSTANCE(ptr)->editlevel = 0;
}
gboolean
qof_instance_check_edit(const QofInstance *inst)
{
g_return_val_if_fail(QOF_IS_INSTANCE(inst), FALSE);
return (inst->editlevel > 0);
}
int
qof_instance_version_cmp (const QofInstance *left, const QofInstance *right)
{
@@ -182,6 +221,27 @@ qof_instance_version_cmp (const QofInstance *left, const QofInstance *right)
return 0;
}
gboolean
qof_instance_get_destroying (gconstpointer ptr)
{
g_return_val_if_fail(QOF_IS_INSTANCE(ptr), FALSE);
return QOF_INSTANCE(ptr)->do_free;
}
void
qof_instance_set_destroying (gpointer ptr, gboolean value)
{
g_return_if_fail(QOF_IS_INSTANCE(ptr));
QOF_INSTANCE(ptr)->do_free = value;
}
gboolean
qof_instance_get_dirty_flag (gconstpointer ptr)
{
g_return_val_if_fail(QOF_IS_INSTANCE(ptr), FALSE);
return QOF_INSTANCE(ptr)->dirty;
}
void
qof_instance_print_dirty (const QofInstance *entity, gpointer dummy)
{
@@ -218,13 +278,6 @@ qof_instance_set_dirty(QofInstance* inst)
}
}
gboolean
qof_instance_check_edit(const QofInstance *inst)
{
if(inst->editlevel > 0) { return TRUE; }
return FALSE;
}
gboolean
qof_instance_do_free(const QofInstance *inst)
{

View File

@@ -119,6 +119,9 @@ QofBook * qof_instance_get_book (const QofInstance *);
/** Return the GUID of this instance */
const GUID * qof_instance_get_guid (const QofInstance *);
/** Return the collection this instance belongs to */
const QofCollection* qof_instance_get_collection (gconstpointer inst);
/** Set the GUID of this instance */
void qof_instance_set_guid (QofInstance *ent, const GUID *guid);
@@ -133,6 +136,11 @@ KvpFrame* qof_instance_get_slots (const QofInstance *);
*/
Timespec qof_instance_get_last_update (const QofInstance *inst);
gint qof_instance_get_editlevel (gconstpointer ptr);
void qof_instance_increase_editlevel (gpointer ptr);
void qof_instance_decrease_editlevel (gpointer ptr);
void qof_instance_reset_editlevel (gpointer ptr);
/** Compare two instances, based on thier last update times.
* Returns a negative, zero or positive value, respectively,
* if 'left' is earlier, same as or later than 'right'.
@@ -141,6 +149,37 @@ Timespec qof_instance_get_last_update (const QofInstance *inst);
*/
int qof_instance_version_cmp (const QofInstance *left, const QofInstance *right);
/** Retrieve the flag that indicates whether or not this object is
* about to be destroyed.
*
* @param ptr The object whose flag should be retrieved.
*
* @return TRUE if the object has been marked for destruction. FALSE
* if the object is not marked for destruction, or if a bad parameter
* is passed to the function. */
gboolean qof_instance_get_destroying (gconstpointer ptr);
/** Set the flag that indicates whether or not this object is about to
* be destroyed.
*
* @param ptr The object whose flag should be set.
*
* @param value The new value to be set for this object. */
void qof_instance_set_destroying (gpointer ptr, gboolean value);
/** Retrieve the flag that indicates whether or not this object has
* been modified. This is specifically the flag on the object. It
* does not perform any other checking which might normally be
* performed when testing to see if an object is dirty. If there is
* any question, use the qof_instance_is_dirty() function instead.
*
* @param ptr The object whose flag should be retrieved.
*
* @return TRUE if the object has been modified and not saved. FALSE
* if the object has not been modified, or if a bad parameter is
* passed to the function. */
gboolean qof_instance_get_dirty_flag (gconstpointer ptr);
void qof_instance_print_dirty (const QofInstance *entity, gpointer dummy);
/** Return value of is_dirty flag */