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 
00076 #include <string.h>
00077 #include "guid.h"
00078 
00080 typedef const gchar *QofIdType;
00082 typedef const gchar *QofIdTypeConst;
00084 typedef const gchar *QofLogModule;
00085 
00086 #define QOF_ID_NONE           NULL
00087 #define QOF_ID_NULL           "null"
00088 
00089 #define QOF_ID_BOOK           "Book"
00090 #define QOF_ID_SESSION        "Session"
00091 
00093 #define QOF_ENTITY(object) ((QofEntity *)(object))
00094 
00096 #define QSTRCMP(da,db) ({                \
00097   gint val = 0;                          \
00098   if ((da) && (db)) {                    \
00099     if ((da) != (db)) {                  \
00100       val = strcmp ((da), (db));         \
00101     }                                    \
00102   } else                                 \
00103   if ((!(da)) && (db)) {                 \
00104     val = -1;                            \
00105   } else                                 \
00106   if ((da) && (!(db))) {                 \
00107     val = 1;                             \
00108   }                                      \
00109   val; /* block assumes value of last statment */  \
00110 })
00111 
00113 #define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
00114   (0 == QSTRCMP((type),(((QofEntity *)(obj))->e_type))))
00115 
00118 #define QOF_CHECK_CAST(obj,e_type,c_type) (                   \
00119   QOF_CHECK_TYPE((obj),(e_type)) ?                            \
00120   (c_type *) (obj) :                                          \
00121   (c_type *) ({                                               \
00122      g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,               \
00123        "Error: Bad QofEntity at %s:%d", __FILE__, __LINE__);  \
00124      (obj);                                                   \
00125   }))
00126 
00128 typedef struct QofEntity_s QofEntity;
00137 typedef struct QofCollection_s QofCollection;
00138 
00146 struct QofEntity_s
00147 {
00148     QofIdType e_type;
00149     GUID guid;
00150     QofCollection *collection;
00151 };
00152 
00156 void qof_entity_init (QofEntity *, QofIdType, QofCollection *);
00157 
00160 void qof_entity_release (QofEntity *);
00164 const GUID *qof_entity_get_guid (QofEntity *);
00165 
00170 QofCollection *qof_collection_new (QofIdType type);
00171 
00173 guint qof_collection_count (QofCollection * col);
00174 
00176 void qof_collection_destroy (QofCollection * col);
00177 
00179 QofIdType qof_collection_get_type (QofCollection *);
00180 
00182 QofEntity *
00183 qof_collection_lookup_entity (QofCollection *, const GUID *);
00184 
00186 typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
00187 
00189 void 
00190 qof_collection_foreach (QofCollection *, QofEntityForeachCB,
00191                         gpointer user_data);
00192 
00199 gpointer 
00200 qof_collection_get_data (QofCollection * col);
00201 
00203 void 
00204 qof_collection_set_data (QofCollection * col, gpointer user_data);
00205 
00207 gboolean 
00208 qof_collection_is_dirty (QofCollection * col);
00209 
00230 gboolean 
00231 qof_collection_add_entity (QofCollection * coll, QofEntity * ent);
00232 
00243 gboolean 
00244 qof_collection_merge (QofCollection * target, QofCollection * merge);
00245 
00257 gint 
00258 qof_collection_compare (QofCollection * target, QofCollection * merge);
00259 
00270 QofCollection *
00271 qof_collection_from_glist (QofIdType type, GList * glist);
00272 
00276 #endif /* QOF_ID_H */
00277 

Generated on Mon Dec 17 17:44:39 2007 for QOF by  doxygen 1.5.2