|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * qofinstance.h -- fields common to all object instances * 00003 * * 00004 * This program is free software; you can redistribute it and/or * 00005 * modify it under the terms of the GNU General Public License as * 00006 * published by the Free Software Foundation; either version 2 of * 00007 * the License, or (at your option) any later version. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License* 00015 * along with this program; if not, contact: * 00016 * * 00017 * Free Software Foundation Voice: +1-617-542-5942 * 00018 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00019 * Boston, MA 02110-1301, USA gnu@gnu.org * 00020 * * 00021 \********************************************************************/ 00037 #ifndef QOF_INSTANCE_H 00038 #define QOF_INSTANCE_H 00039 00040 typedef struct _QofInstanceClass QofInstanceClass; 00041 typedef struct QofInstance_s QofInstance; 00042 00044 typedef struct _QofBook QofBook; 00045 00046 #include "qofid.h" 00047 #include "guid.h" 00048 #include "gnc-date.h" 00049 #include "kvp_frame.h" 00050 #include "qof-gobject.h" 00051 00052 /* --- type macros --- */ 00053 #define QOF_TYPE_INSTANCE (qof_instance_get_type ()) 00054 #define QOF_INSTANCE(o) \ 00055 (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_INSTANCE, QofInstance)) 00056 #define QOF_INSTANCE_CLASS(k) \ 00057 (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_INSTANCE, QofInstanceClass)) 00058 #define QOF_IS_INSTANCE(o) \ 00059 (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_INSTANCE)) 00060 #define QOF_IS_INSTANCE_CLASS(k) \ 00061 (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_INSTANCE)) 00062 #define QOF_INSTANCE_GET_CLASS(o) \ 00063 (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_INSTANCE, QofInstanceClass)) 00064 00065 struct QofInstance_s 00066 { 00067 GObject object; 00068 00069 QofIdType e_type; 00071 /* kvp_data is a key-value pair database for storing arbirtary 00072 * information associated with this instance. 00073 * See src/engine/kvp_doc.txt for a list and description of the 00074 * important keys. */ 00075 KvpFrame *kvp_data; 00076 }; 00077 00078 struct _QofInstanceClass 00079 { 00080 GObjectClass parent_class; 00081 00082 /* Returns a displayable string to represent this object */ 00083 gchar* (*get_display_name)(const QofInstance*); 00084 00085 /* Does this object refer to a specific object */ 00086 gboolean (*refers_to_object)(const QofInstance* inst, const QofInstance* ref); 00087 00088 /* Returns a list of my type of object which refers to an object */ 00089 GList* (*get_typed_referring_object_list)(const QofInstance* inst, const QofInstance* ref); 00090 }; 00091 00093 GType qof_instance_get_type(void); 00094 00096 void qof_instance_init_data (QofInstance *, QofIdType, QofBook *); 00097 00099 /*@ dependent @*/ 00100 QofBook *qof_instance_get_book (gconstpointer); 00101 00103 void qof_instance_set_book (gconstpointer inst, QofBook *book); 00104 00106 void qof_instance_copy_book (gpointer ptr1, gconstpointer ptr2); 00107 00109 gboolean qof_instance_books_equal (gconstpointer ptr1, gconstpointer ptr2); 00110 00112 /*@ dependent @*/ 00113 const GncGUID * qof_instance_get_guid (gconstpointer); 00114 00117 /*@ dependent @*/ 00118 const GncGUID * qof_entity_get_guid (gconstpointer); 00119 00121 /*@ dependent @*/ 00122 QofCollection* qof_instance_get_collection (gconstpointer inst); 00123 00125 void qof_instance_set_guid (gpointer inst, const GncGUID *guid); 00126 00130 void qof_instance_copy_guid (gpointer to, gconstpointer from); 00131 00135 gint qof_instance_guid_compare(const gconstpointer ptr1, const gconstpointer ptr2); 00136 00137 //QofIdType qof_instance_get_e_type (const QofInstance *inst); 00138 //void qof_instance_set_e_type (QofInstance *ent, QofIdType e_type); 00139 00141 /*@ dependent @*/ 00142 KvpFrame* qof_instance_get_slots (const QofInstance *); 00143 void qof_instance_set_editlevel(gpointer inst, gint level); 00144 gint qof_instance_get_editlevel (gconstpointer ptr); 00145 void qof_instance_increase_editlevel (gpointer ptr); 00146 void qof_instance_decrease_editlevel (gpointer ptr); 00147 void qof_instance_reset_editlevel (gpointer ptr); 00148 00155 int qof_instance_version_cmp (const QofInstance *left, const QofInstance *right); 00156 00165 gboolean qof_instance_get_destroying (gconstpointer ptr); 00166 00173 void qof_instance_set_destroying (gpointer ptr, gboolean value); 00174 00186 gboolean qof_instance_get_dirty_flag (gconstpointer ptr); 00187 00188 void qof_instance_print_dirty (const QofInstance *entity, gpointer dummy); 00189 00191 #define qof_instance_is_dirty qof_instance_get_dirty 00192 gboolean qof_instance_get_dirty (QofInstance *); 00193 00198 void qof_instance_set_dirty(QofInstance* inst); 00199 00200 /* reset the dirty flag */ 00201 void qof_instance_mark_clean (QofInstance *); 00202 00203 gboolean qof_instance_get_infant(const QofInstance *inst); 00204 00207 gint32 qof_instance_get_version (gconstpointer inst); 00208 00211 void qof_instance_set_version (gpointer inst, gint32 value); 00214 void qof_instance_copy_version (gpointer to, gconstpointer from); 00215 00217 guint32 qof_instance_get_version_check (gconstpointer inst); 00219 void qof_instance_set_version_check (gpointer inst, guint32 value); 00221 void qof_instance_copy_version_check (gpointer to, gconstpointer from); 00222 00225 guint32 qof_instance_get_idata (gconstpointer inst); 00226 void qof_instance_set_idata(gpointer inst, guint32 idata); 00227 00231 gchar* qof_instance_get_display_name(const QofInstance* inst); 00232 00237 GList* qof_instance_get_referring_object_list(const QofInstance* inst); 00238 00240 gboolean qof_instance_refers_to_object(const QofInstance* inst, const QofInstance* ref); 00241 00248 GList* qof_instance_get_typed_referring_object_list(const QofInstance* inst, const QofInstance* ref); 00249 00253 GList* qof_instance_get_referring_object_list_from_collection(const QofCollection* coll, const QofInstance* ref); 00254 00255 /* @} */ 00256 /* @} */ 00257 #endif /* QOF_INSTANCE_H */
1.7.4