|
file | qofid.h |
| QOF entity type identification system.
|
|
|
#define | QOF_ID_NONE NULL |
|
#define | QOF_ID_NULL "null" |
|
#define | QOF_ID_BOOK "Book" |
|
#define | QOF_ID_SESSION "Session" |
|
#define | QSTRCMP(da, db) |
|
#define | QOF_CHECK_TYPE(obj, type) |
|
#define | QOF_CHECK_CAST(obj, e_type, c_type) |
|
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 ond 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.
- An id with type QOF_ID_NONE does not refer to any entity.
- An id with type QOF_ID_NULL does not refer to any entity, and will never refer to any entity. =# An identifier with any other type may refer to an actual entity, but that is not guaranteed as that entity does not have to exist within the current book. (See ::PARTIAL_QOFBOOK). Also, creating a new entity from a data source involves creating a temporary GncGUID and then setting the value from the data source. If an id does refer to an entity, the type of the entity will match the type of the identifier.
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 |
|
) |
| |
Value:
(c_type *) (obj) : \
(c_type *) ({ \
"Error: Bad QofInstance at %s:%d", __FILE__, __LINE__); \
(obj); \
}))
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
#define QOF_CHECK_TYPE(obj, type)
cast object to the indicated type, print error message if its bad
Definition at line 129 of file qofid.h.
#define QOF_CHECK_TYPE |
( |
|
obj, |
|
|
|
type |
|
) |
| |
Value:return TRUE if object is of the given type
Definition at line 124 of file qofid.h.
#define QSTRCMP |
( |
|
da, |
|
|
|
db |
|
) |
| |
Value:({ \
gint val = 0; \
if ((da) && (db)) { \
if ((da) != (db)) { \
val = strcmp ((da), (db)); \
} \
} else \
if ((!(da)) && (db)) { \
val = -1; \
} else \
if ((da) && (!(db))) { \
val = 1; \
} \
val; \
})
Inline string comparision; compiler will optimize away most of this
Definition at line 103 of file qofid.h.
QofIdType declaration
Definition at line 85 of file qofid.h.
QofIdTypeConst declaration
Definition at line 87 of file qofid.h.
typedef void(* QofInstanceForeachCB)(QofInstance *, gpointer user_data) |
Callback type for qof_collection_foreach
Definition at line 186 of file qofid.h.
QofLogModule declaration
Definition at line 89 of file qofid.h.
gboolean qof_collection_add_entity |
( |
QofCollection * |
coll, |
|
|
QofInstance * |
ent |
|
) |
| |
Add an entity to a QOF_TYPE_COLLECT.
- Note
- These are NOT the same as the main collections in the book.
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.
gint qof_collection_compare |
( |
QofCollection * |
target, |
|
|
QofCollection * |
merge |
|
) |
| |
Compare two secondary collections.
Performs a deep comparision of the collections. Each QofInstance in each collection is looked up in the other collection, via the GncGUID.
- Returns
- 0 if the collections are identical or both are NULL otherwise -1 if target is NULL or either collection contains an entity with an invalid GncGUID or if the types of the two collections do not match, or +1 if merge is NULL or if any entity exists in one collection but not in the other.
guint qof_collection_count |
( |
const QofCollection * |
col | ) |
|
return the number of entities in the collection.
void qof_collection_destroy |
( |
QofCollection * |
col | ) |
|
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.
- Parameters
-
type | The QofIdType of the QofCollection and of all entities in the GList. |
glist | GList of entities of the same QofIdType. |
- Returns
- NULL if any of the entities fail to match the QofCollection type, else a pointer to the collection on success.
gpointer qof_collection_get_data |
( |
const QofCollection * |
col | ) |
|
Store and retreive 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.
QofIdType qof_collection_get_type |
( |
const QofCollection * |
| ) |
|
return the type that the collection stores
gboolean qof_collection_is_dirty |
( |
const QofCollection * |
col | ) |
|
Return value of 'dirty' flag on collection
Find the entity going only from its guid
QofCollection* qof_collection_new |
( |
QofIdType |
type | ) |
|
create a new collection of entities of type
gboolean qof_get_alt_dirty_mode |
( |
void |
| ) |
|
QofCollection declaration
- Parameters
-
e_type | QofIdType |
is_dirty | gboolean |
hash_of_entities | GHashTable |
data | gpointer, place where object class can hang arbitrary data Is QOF operating in "alternate" dirty mode? |
In normal mode, whenever an instance is dirtied, the collection (and therefore the book) is immediately marked as dirty. In alternate mode, the collection is only marked dirty when a dirty instance is committed. If a dirty instance is freed instead of committed, the dirty state of collection (and therefore the book) is never changed.
void qof_set_alt_dirty_mode |
( |
gboolean |
enabled | ) |
|
Set QOF into "alternate" dirty mode. In normal mode, whenever an instance is dirtied, the collection (and therefore the book) is immediately marked as dirty. In alternate mode, the collection is only marked dirty when a dirty instance is committed. If a dirty instance is freed instead of committed, the dirty state of collection (and therefore the book) is never changed.