GnuCash
5.6-150-g038405b370+
|
This file defines an API that adds types to the GncGUID's. More...
Files | |
file | qofid.h |
QOF entity type identification system. | |
Macros | |
#define | QOF_ID_NONE NULL |
#define | QOF_ID_NULL "null" |
#define | QOF_ID_BOOK "Book" |
#define | QOF_ID_SESSION "Session" |
#define | QSTRCMP g_strcmp0 |
#define | QOF_CHECK_TYPE(obj, type) |
return TRUE if object is of the given type More... | |
#define | QOF_CHECK_CAST(obj, e_type, c_type) |
cast object to the indicated type, print error message if its bad More... | |
Typedefs | |
typedef const gchar * | QofIdType |
QofIdType declaration. | |
typedef const gchar * | QofIdTypeConst |
QofIdTypeConst declaration. | |
Collections of Entities | |||||||||
| |||||||||
typedef void(* | QofInstanceForeachCB) (QofInstance *, gpointer user_data) | ||||||||
Callback type for qof_collection_foreach. | |||||||||
QofCollection * | qof_collection_new (QofIdType type) | ||||||||
create a new collection of entities of type | |||||||||
guint | qof_collection_count (const QofCollection *col) | ||||||||
return the number of entities in the collection. More... | |||||||||
void | qof_collection_destroy (QofCollection *col) | ||||||||
destroy the collection More... | |||||||||
QofIdType | qof_collection_get_type (const QofCollection *) | ||||||||
return the type that the collection stores | |||||||||
QofInstance * | qof_collection_lookup_entity (const QofCollection *, const GncGUID *) | ||||||||
Find the entity going only from its guid. | |||||||||
void | qof_collection_foreach_sorted (const QofCollection *col, QofInstanceForeachCB cb_func, gpointer user_data, GCompareFunc sort_fn) | ||||||||
Call the callback for each entity in the collection. More... | |||||||||
void | qof_collection_foreach (const QofCollection *, QofInstanceForeachCB, gpointer user_data) | ||||||||
gpointer | qof_collection_get_data (const QofCollection *col) | ||||||||
Store and retrieve arbitrary object-defined data. More... | |||||||||
void | qof_collection_set_data (QofCollection *col, gpointer user_data) | ||||||||
gboolean | qof_collection_is_dirty (const QofCollection *col) | ||||||||
Return value of 'dirty' flag on collection. | |||||||||
QOF_TYPE_COLLECT: Linking one entity to many of one type | |
QOF_TYPE_COLLECT is a secondary collection, used to select entities of one object type as references of another entity.
| |
gboolean | qof_collection_add_entity (QofCollection *coll, QofInstance *ent) |
Add an entity to a QOF_TYPE_COLLECT. More... | |
void | qof_collection_remove_entity (QofInstance *ent) |
gint | qof_collection_compare (QofCollection *target, QofCollection *merge) |
Compare two secondary collections. More... | |
QofCollection * | qof_collection_from_glist (QofIdType type, const GList *glist) |
Create a secondary collection from a GList. More... | |
This file defines an API that adds types to the GncGUID's.
GncGUID's with types can be used to identify and reference typed entities.
The idea here is that a GncGUID can be used to uniquely identify some thing. By adding a type, one can then talk about the type of thing identified. By adding a collection, one can then work with a handle to a collection of things of a given type, each uniquely identified by a given ID. QOF Entities can be used independently of any other part of the system. In particular, Entities can be useful even if one is not using the Query and Object parts of the QOF system.
Identifiers are globally-unique and permanent, i.e., once an entity has been assigned an identifier, it retains that same identifier for its lifetime. Identifiers can be encoded as hex strings.
GncGUID Identifiers are 'typed' with strings. The native ids used by QOF are defined below.
If you have a type name, and you want to have a way of finding a collection that is associated with that type, then you must use Books.
Entities can refer to other entities as well as to the basic QOF types, using the qofclass parameters.
#define QOF_CHECK_CAST | ( | obj, | |
e_type, | |||
c_type | |||
) |
cast object to the indicated type, print error message if its bad
#define QOF_CHECK_TYPE | ( | obj, | |
type | |||
) |
return TRUE if object is of the given type
gboolean qof_collection_add_entity | ( | QofCollection * | coll, |
QofInstance * | ent | ||
) |
Add an entity to a QOF_TYPE_COLLECT.
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_instance_insert_entity or ::qof_instance_remove_entity.
Definition at line 109 of file qofid.cpp.
gint qof_collection_compare | ( | QofCollection * | target, |
QofCollection * | merge | ||
) |
Compare two secondary collections.
Performs a deep comparison of the collections. Each QofInstance in each collection is looked up in the other collection, via the GncGUID.
Definition at line 174 of file qofid.cpp.
guint qof_collection_count | ( | const QofCollection * | col | ) |
void qof_collection_destroy | ( | QofCollection * | col | ) |
void qof_collection_foreach_sorted | ( | const QofCollection * | col, |
QofInstanceForeachCB | cb_func, | ||
gpointer | user_data, | ||
GCompareFunc | sort_fn | ||
) |
Call the callback for each entity in the collection.
QofCollection* qof_collection_from_glist | ( | QofIdType | type, |
const GList * | glist | ||
) |
Create a secondary collection from a GList.
type | The QofIdType of the QofCollection and of all entities in the GList. |
glist | GList of entities of the same QofIdType. |
Definition at line 224 of file qofid.cpp.
gpointer qof_collection_get_data | ( | const QofCollection * | col | ) |
Store and retrieve arbitrary object-defined data.
XXX We need to add a callback for when the collection is being destroyed, so that the user has a chance to clean up anything that was put in the 'data' member here.