QOF: Object_Private

QOF 0.7.5

Files | Data Structures
Object_Private
Query Object Framework » Object: Describing data structure.

## Files
file | qofbackend-p.h
| private api for data storage backend
file | qofbook-p.h
| Private QofBook interface.
file | qofobject-p.h
| the Core Object Registration/Lookup Private Interface

## Data Structures
struct | QofBackendProvider_s
struct | QofBackend_s
struct | _QofBook

## Backend_Private
Pseudo-object defining how the engine can interact with different back-ends (which may be SQL databases, or network interfaces to remote QOF servers. File-io is just one type of backend). The callbacks will be called at the appropriate times during a book session to allow the backend to store the data as needed.
void | qof_backend_register_provider (QofBackendProvider *)
void | qof_backend_init (QofBackend *be)
gchar | qof_book_get_open_marker (QofBook *book)
gint32 | qof_book_get_version (QofBook *book)
guint32 | qof_book_get_idata (QofBook *book)
void | qof_book_set_version (QofBook *book, gint32 version)
void | qof_book_set_idata (QofBook *book, guint32 idata)

## Book_Private
void | qof_book_set_backend (QofBook *book, QofBackend *be)
| Set the backend used by this book. More...
gboolean | qof_book_register (void)

## Class_Private
void | qof_class_init (void)
void | qof_class_shutdown (void)
QofSortFunc | qof_class_get_default_sort (QofIdTypeConst obj_name)

## Entity_Private
void | qof_entity_set_guid (QofEntity *ent, const GUID *guid)
void | qof_collection_insert_entity (QofCollection *, QofEntity *)
void | qof_collection_mark_clean (QofCollection *)
void | qof_collection_mark_dirty (QofCollection *)

## Objects_Private
void | qof_object_book_begin (QofBook *book)
void | qof_object_book_end (QofBook *book)
gboolean | qof_object_is_dirty (QofBook *book)
void | qof_object_mark_clean (QofBook *book)
gboolean | qof_object_compliance (QofIdTypeConst type_name, gboolean warn)
| check an object can be created and supports iteration More...

## Detailed Description

Private interfaces, not meant to be used by applications.

## Function Documentation

## ◆ qof_backend_init()

void qof_backend_init | ( | QofBackend * | be | ) |

Deprecated:

Deprecated:

Definition at line 37 of file qofbackend.c.

38 {
39 be->session_begin = NULL;
40 be->session_end = NULL;
41 be->destroy_backend = NULL;
42 be->load = NULL;
43 be->begin = NULL;
44 be->commit = NULL;
45 be->rollback = NULL;
46 be->compile_query = NULL;
47 be->free_query = NULL;
48 be->run_query = NULL;
49 be->sync = NULL;
50 be->load_config = NULL;
51 be->events_pending = NULL;
52 be->process_events = NULL;
53 be->percentage = NULL;
54 be->backend_configuration = kvp_frame_new ();
55 #ifndef QOF_DISABLE_DEPRECATED
56 be->last_err = QOF_SUCCESS;
57 if (be->error_msg)
58 g_free (be->error_msg);
59 be->error_msg = NULL;
61 be->price_lookup = NULL;
63 be->export = NULL;
64 #endif
65 }
QofBackend_s::price_lookup
void(* price_lookup)(QofBackend *, gpointer)
Definition: qofbackend-p.h:341
QofBackend_s::export
void(* export)(QofBackend *, QofBook *)
Definition: qofbackend-p.h:344
QofBackend_s::last_err
QofErrorId last_err
Definition: qofbackend-p.h:324
QOF_SUCCESS
#define QOF_SUCCESS
Definition: qoferror.h:124
QofBackend_s::error_msg
gchar * error_msg
Definition: qofbackend-p.h:326
kvp_frame_new
KvpFrame * kvp_frame_new(void)
Definition: kvpframe.c:100

## ◆ qof_backend_register_provider()

void qof_backend_register_provider | ( | QofBackendProvider * |  | ) |

Let the sytem know about a new provider of backends. This function is typically called by the provider library at library load time. This function allows the backend library to tell QOF infrastructure that it can handle URL's of a certain type. Note that a single backend library may register more than one provider, if it is capable of handling more than one URL access method.

Definition at line 59 of file qofsession.c.

60 {
61 provider_list = g_slist_prepend (provider_list, prov);
62 }

## ◆ qof_book_get_idata()

guint32 qof_book_get_idata | ( | QofBook * | book | ) |

get the book tag number

used for kvp management in sql backends.

Definition at line 295 of file qofbook.c.

296 {
297 if (!book)
298 {
299 return 0;
300 }
301 return book->idata;
302 }
_QofBook::idata
guint32 idata
Definition: qofbook-p.h:94

## ◆ qof_book_get_open_marker()

gchar qof_book_get_open_marker | ( | QofBook * | book | ) |

Allow backends to see if the book is open

Returns
  'y' if book is open, otherwise 'n'.

Definition at line 275 of file qofbook.c.

276 {
277 if (!book)
278 {
279 return 'n';
280 }
281 return book->book_open;
282 }
_QofBook::book_open
gchar book_open
Definition: qofbook-p.h:70

## ◆ qof_book_get_version()

gint32 qof_book_get_version | ( | QofBook * | book | ) |

get the book version

used for tracking multiuser updates in backends.

Returns
  -1 if no book exists, 0 if the book is new, otherwise the book version number.

Definition at line 285 of file qofbook.c.

286 {
287 if (!book)
288 {
289 return -1;
290 }
291 return book->version;
292 }
_QofBook::version
gint32 version
Definition: qofbook-p.h:80

## ◆ qof_book_register()

gboolean qof_book_register | ( | void |  | ) |

Register books with the framework

Definition at line 376 of file qofbook.c.

377 {
378 static QofParam params[] = {
379 {QOF_PARAM_GUID, QOF_TYPE_GUID,
380 (QofAccessFunc) qof_entity_get_guid,
381 NULL, NULL},
382 {QOF_PARAM_KVP, QOF_TYPE_KVP,
383 (QofAccessFunc) qof_instance_get_slots,
384 NULL, NULL},
385 {NULL, NULL, NULL, NULL, NULL},
386 };
387
388 qof_class_register (QOF_ID_BOOK, NULL, params);
389
390 return TRUE;
391 }
_QofParam
Definition: qofclass.h:195
qof_class_register
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_function, const QofParam *params)
registers a new object class with the Qof subsystem.
Definition: qofclass.c:93
qof_instance_get_slots
KvpFrame * qof_instance_get_slots(QofInstance *inst)
Definition: qofinstance.c:95
QofAccessFunc
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
Definition: qofclass.h:169
QOF_PARAM_KVP
#define QOF_PARAM_KVP
Definition: qofquery.h:108
qof_entity_get_guid
const GUID * qof_entity_get_guid(QofEntity *ent)
Definition: qofid.c:105

## ◆ qof_book_set_backend()

void qof_book_set_backend | ( | QofBook * | book,
|  | QofBackend * | be
| ) |  |

Set the backend used by this book.

qof_book_set_backend() is used by backends to initialize the pointers in the book structure to something that contains actual data. These routines should not be used otherwise. (Its somewhat questionable if the backends should even be doing this much, but for backwards compatibility, we leave these here.)

Should only be used within a backend itself.

Definition at line 170 of file qofbook.c.

171 {
172 if (!book)
173 return;
174 ENTER ("book=%p be=%p", book, be);
175 book->backend = be;
176 LEAVE (" ");
177 }
LEAVE
#define LEAVE(format, args...)
Definition: qoflog.h:227
_QofBook::backend
QofBackend * backend
Definition: qofbook-p.h:87
ENTER
#define ENTER(format, args...)
Definition: qoflog.h:217

## ◆ qof_collection_insert_entity()

void qof_collection_insert_entity | ( | QofCollection * | ,
|  | QofEntity * |
| ) |  |

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.

Definition at line 197 of file qofid.c.

198 {
199 if (!col || !ent)
200 return;
201 if (guid_equal (&ent->guid, guid_null ()))
202 return;
203 g_return_if_fail (col->e_type == ent->e_type);
204 qof_collection_remove_entity (ent);
205 g_hash_table_insert (col->hash_of_entities, &ent->guid, ent);
206 qof_collection_mark_dirty (col);
207 ent->collection = col;
208 }
guid_equal
gboolean guid_equal(const GUID *guid_1, const GUID *guid_2)
Definition: guid.c:652
guid_null
const GUID * guid_null(void)
Definition: guid.c:119

## ◆ qof_collection_mark_clean()

void qof_collection_mark_clean | ( | QofCollection * |  | ) |

reset value of dirty flag

Definition at line 368 of file qofid.c.

369 {
370 if (col)
371 {
372 col->is_dirty = FALSE;
373 }
374 }

## ◆ qof_entity_set_guid()

void qof_entity_set_guid | ( | QofEntity * | ent,
|  | const GUID * | guid
| ) |  |

Set the ID of the entity, over-riding the previous ID. Very dangerous, use only for file i/o work.

Definition at line 92 of file qofid.c.

93 {
94 QofCollection *col;
95 if (guid_equal (guid, &ent->guid))
96 return;
97
98 col = ent->collection;
99 qof_collection_remove_entity (ent);
100 ent->guid = *guid;
101 qof_collection_insert_entity (col, ent);
102 }
guid_equal
gboolean guid_equal(const GUID *guid_1, const GUID *guid_2)
Definition: guid.c:652
QofCollection
struct QofCollection_s QofCollection
Definition: qofid.h:138
qof_collection_insert_entity
void qof_collection_insert_entity(QofCollection *col, QofEntity *ent)
Definition: qofid.c:197

## ◆ qof_object_book_begin()

void qof_object_book_begin | ( | QofBook * | book | ) |

To be called from within the book

Definition at line 60 of file qofobject.c.

61 {
62 GList *l;
63
64 if (!book)
65 return;
66 ENTER (" ");
67 for (l = object_modules; l; l = l->next)
68 {
69 QofObject *obj = l->data;
70 if (obj->book_begin)
71 obj->book_begin (book);
72 }
73
74 /* Remember this book for later */
75 book_list = g_list_prepend (book_list, book);
76 LEAVE (" ");
77 }
LEAVE
#define LEAVE(format, args...)
Definition: qoflog.h:227
_QofObject::book_begin
void(* book_begin)(QofBook *)
Definition: qofobject.h:85
_QofObject
Definition: qofobject.h:70
ENTER
#define ENTER(format, args...)
Definition: qoflog.h:217

## ◆ qof_object_compliance()

gboolean qof_object_compliance | ( | QofIdTypeConst | type_name,
|  | gboolean | warn
| ) |  |

check an object can be created and supports iteration

Parameters

  type_name | object to check
  warn | If called only once per operation, pass TRUE to log objects that fail the compliance check. To prevent repeated log messages when calling more than once, pass FALSE.

Returns
  TRUE if object can be created and supports iteration, else FALSE.

Definition at line 155 of file qofobject.c.

156 {
157 const QofObject *obj;
158
159 obj = qof_object_lookup (type_name);
160 if ((obj->create == NULL) || (obj->foreach == NULL))
161 {
162 if (warn)
163 {
164 PINFO (" Object type %s is not fully QOF compliant",
165 obj->e_type);
166 }
167 return FALSE;
168 }
169 return TRUE;
170 }
PINFO
#define PINFO(format, args...)
Definition: qoflog.h:199
qof_object_lookup
const QofObject * qof_object_lookup(QofIdTypeConst name)
Definition: qofobject.c:305
_QofObject::create
gpointer(* create)(QofBook *)
Definition: qofobject.h:80
_QofObject
Definition: qofobject.h:70
_QofObject::foreach
void(* foreach)(QofCollection *, QofEntityForeachCB, gpointer)
Definition: qofobject.h:105