From 846d3e4421432794e7f183ccae5cb75a3e7a9066 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 11 Oct 2003 20:49:55 +0000 Subject: [PATCH] gnc objects have a lot in common. This thingy will try to abstract out all teh common-ness between them. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9464 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Makefile.am | 2 ++ src/engine/qofinstance.c | 30 +++++++++++++++++++++++++ src/engine/qofinstance.h | 47 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/engine/qofinstance.c create mode 100644 src/engine/qofinstance.h diff --git a/src/engine/Makefile.am b/src/engine/Makefile.am index 8934365b55..91e1b38c9d 100644 --- a/src/engine/Makefile.am +++ b/src/engine/Makefile.am @@ -46,6 +46,7 @@ libgncmod_engine_la_SOURCES = \ qofbook.c \ qofclass.c \ qofid.c \ + qofinstance.c \ qofobject.c \ qofquery.c \ qofquerycore.c \ @@ -100,6 +101,7 @@ gncinclude_HEADERS = \ qofbook.h \ qofclass.h \ qofid.h \ + qofinstance.h \ qofobject.h \ qofquery.h \ qofquerycore.h \ diff --git a/src/engine/qofinstance.c b/src/engine/qofinstance.c new file mode 100644 index 0000000000..e0dcfaf687 --- /dev/null +++ b/src/engine/qofinstance.c @@ -0,0 +1,30 @@ +/* + * qofinstance.c + * + * Object instance holds many common fields that most + * gnucash objects use. + * + * Copyright (C) 2003 Linas Vepstas + */ + +#include "qofinstance.h" + +void +qof_instance_init (QofInstance *inst) +{ + inst->kvp_data = kvp_frame_new(); +} + +void +qof_instance_release (QofInstance *inst) +{ + kvp_frame_delete (inst->kvp_data); +} + +KvpFrame* +qof_instance_get_slots (QofInstance *inst) +{ + if (!inst) return NULL; + return inst->kvp_data; +} + diff --git a/src/engine/qofinstance.h b/src/engine/qofinstance.h new file mode 100644 index 0000000000..2d0794cdc8 --- /dev/null +++ b/src/engine/qofinstance.h @@ -0,0 +1,47 @@ +/* + * qofinstance.h + * + * Object instance holds many common fields that most + * gnucash objects use. + * + * Copyright (C) 2003 Linas Vepstas + */ + +#ifndef QOF_INSTANCE_H +#define QOF_INSTANCE_H +#include "kvp_frame.h" + +/* --- type macros --- */ +/* cheesy, but will do for now, eventually should be more gtk-like */ +#define QOF_INSTANCE(object) (&((object)->inst)) + +typedef struct QofInstance_s QofInstance; + +struct QofInstance_s +{ +/* + * UNDER CONSTRUCTION! + * This is temp scaffolding for now, + * eventually, it should hold at least the following fields: + * (and maybe more, such as refrence counting...) + * + GUID guid; + QofBook * book; + int editlevel; + gboolean do_free; + gboolean dirty; + */ + KvpFrame *kvp_data; +}; + +/** Initialise the memory associated with an instance */ +void qof_instance_init (QofInstance *inst); + +/** release the data associated with this instance. Dont actually free + * the memory associated with teh instance. */ +void qof_instance_release (QofInstance *inst); + +/** return the pointer to the kvp_data */ +KvpFrame* qof_instance_get_slots (QofInstance *); + +#endif /* QOF_INSTANCE_H */