qofid.h

Go to the documentation of this file.
00001 /********************************************************************\
00002  * qofid.h -- QOF entity type identification system                 *
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 \********************************************************************/
00022 
00023 #ifndef QOF_ID_H
00024 #define QOF_ID_H
00025 
00077 #include <string.h>
00078 #include "guid.h"
00079 
00081 typedef const gchar *QofIdType;
00083 typedef const gchar *QofIdTypeConst;
00085 typedef const gchar *QofLogModule;
00086 
00087 #define QOF_ID_NONE           NULL
00088 #define QOF_ID_NULL           "null"
00089 
00090 #define QOF_ID_BOOK           "Book"
00091 #define QOF_ID_SESSION        "Session"
00092 
00094 #define QOF_ENTITY(object) ((QofEntity *)(object))
00095 
00097 #define QSTRCMP(da,db) ({                \
00098   gint val = 0;                          \
00099   if ((da) && (db)) {                    \
00100     if ((da) != (db)) {                  \
00101       val = strcmp ((da), (db));         \
00102     }                                    \
00103   } else                                 \
00104   if ((!(da)) && (db)) {                 \
00105     val = -1;                            \
00106   } else                                 \
00107   if ((da) && (!(db))) {                 \
00108     val = 1;                             \
00109   }                                      \
00110   val; /* block assumes value of last statment */  \
00111 })
00112 
00114 #define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
00115   (0 == QSTRCMP((type),(((QofEntity *)(obj))->e_type))))
00116 
00119 #define QOF_CHECK_CAST(obj,e_type,c_type) (                   \
00120   QOF_CHECK_TYPE((obj),(e_type)) ?                            \
00121   (c_type *) (obj) :                                          \
00122   (c_type *) ({                                               \
00123      g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,               \
00124        "Error: Bad QofEntity at %s:%d", __FILE__, __LINE__);  \
00125      (obj);                                                   \
00126   }))
00127 
00129 typedef struct QofEntity_s QofEntity;
00138 typedef struct QofCollection_s QofCollection;
00139 
00147 struct QofEntity_s
00148 {
00149     QofIdType e_type;
00150     GUID guid;
00151     QofCollection *collection;
00152 };
00153 
00157 void qof_entity_init (QofEntity *, QofIdType, QofCollection *);
00158 
00161 void qof_entity_release (QofEntity *);
00165 const GUID *qof_entity_get_guid (QofEntity *);
00166 
00171 QofCollection *qof_collection_new (QofIdType type);
00172 
00174 guint qof_collection_count (QofCollection * col);
00175 
00177 void qof_collection_destroy (QofCollection * col);
00178 
00180 QofIdType qof_collection_get_type (QofCollection *);
00181 
00183 QofEntity *
00184 qof_collection_lookup_entity (QofCollection *, const GUID *);
00185 
00187 typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
00188 
00190 void 
00191 qof_collection_foreach (QofCollection *, QofEntityForeachCB,
00192                         gpointer user_data);
00193 
00200 gpointer 
00201 qof_collection_get_data (QofCollection * col);
00202 
00204 void 
00205 qof_collection_set_data (QofCollection * col, gpointer user_data);
00206 
00208 gboolean 
00209 qof_collection_is_dirty (QofCollection * col);
00210 
00231 gboolean 
00232 qof_collection_add_entity (QofCollection * coll, QofEntity * ent);
00233 
00244 gboolean 
00245 qof_collection_merge (QofCollection * target, QofCollection * merge);
00246 
00258 gint 
00259 qof_collection_compare (QofCollection * target, QofCollection * merge);
00260 
00271 QofCollection *
00272 qof_collection_from_glist (QofIdType type, GList * glist);
00273 
00277 #endif /* QOF_ID_H */
00278 

Generated on Thu Jan 31 22:50:26 2008 for QOF by  doxygen 1.5.4