galago-object.h
Go to the documentation of this file.00001
00021 #ifndef _GALAGO_OBJECT_H_
00022 #define _GALAGO_OBJECT_H_
00023
00024 #include <libgalago/galago-types.h>
00025
00026 typedef struct _GalagoObjectClass GalagoObjectClass;
00027 typedef struct _GalagoObjectClassInfo GalagoObjectClassInfo;
00028 typedef struct _GalagoObjectClassPrivate GalagoObjectClassPrivate;
00029 typedef struct _GalagoObject GalagoObject;
00030 typedef struct _GalagoObjectPrivate GalagoObjectPrivate;
00031
00032 typedef void (*GalagoObjectClassInitFunc)(GalagoObjectClass *klass);
00033 typedef void (*GalagoObjectClassFinalizeFunc)(GalagoObjectClass *klass);
00034 typedef void (*GalagoObjectInitFunc)(GalagoObject *object);
00035
00036 typedef enum
00037 {
00038 GALAGO_FLAG_FINALIZING = 1 << 1
00040 } GalagoObjectFlags;
00041
00042 typedef enum
00043 {
00044 GALAGO_FLAG_ABSTRACT = 1 << 1
00046 } GalagoObjectClassFlags;
00047
00048 #include <libgalago/galago-context-base.h>
00049 #include <libgalago/galago-signals.h>
00050
00051
00055 struct _GalagoObjectClass
00056 {
00057 unsigned long magic;
00058
00059 GalagoObjectClassPrivate *priv;
00060
00061 GalagoSignalContext *signal_context;
00062
00063 void (*finalize)(GalagoObject *object);
00064
00065 void (*dbus_message_append)(DBusMessageIter *iter,
00066 const GalagoObject *object);
00067 void *(*dbus_message_get)(DBusMessageIter *iter);
00068 void (*dbus_push_full)(GalagoObject *object);
00069
00070 void (*reserved_1)(void);
00071 void (*reserved_2)(void);
00072 void (*reserved_3)(void);
00073 void (*reserved_4)(void);
00074 };
00075
00079 struct _GalagoObjectClassInfo
00080 {
00081 unsigned long flags;
00082 size_t class_size;
00083 GalagoObjectClassInitFunc class_init;
00084 GalagoObjectClassFinalizeFunc class_finalize;
00085 size_t object_size;
00086 GalagoObjectInitFunc object_init;
00087 };
00088
00092 struct _GalagoObject
00093 {
00094 unsigned long magic;
00095
00096 GalagoObjectPrivate *priv;
00097
00098 void (*reserved_1)(void);
00099 void (*reserved_2)(void);
00100 void (*reserved_3)(void);
00101 void (*reserved_4)(void);
00102 };
00103
00104 #define GALAGO_OBJECT_MAGIC 0xB00F
00105 #define GALAGO_CLASS_MAGIC 0xB0B0
00106
00107 #define GALAGO_IS_OBJECT(ptr) \
00108 ((ptr) != NULL && ((GalagoObject *)(ptr))->magic == GALAGO_OBJECT_MAGIC)
00109
00110 #define GALAGO_IS_CLASS(ptr) \
00111 ((ptr) != NULL && ((GalagoObjectClass *)(ptr))->magic == GALAGO_CLASS_MAGIC)
00112
00113 #define GALAGO_OBJECT(ptr) \
00114 ((ptr) == NULL ? NULL : \
00115 (GALAGO_IS_OBJECT(ptr) ? (GalagoObject *)(ptr) : NULL))
00116
00117 #define GALAGO_OBJECT_CLASS(obj) (galago_object_get_class(obj))
00118
00119 #define GALAGO_OBJECT_CAST(obj, klass, type) \
00120 ((obj) == NULL ? NULL : (type *)galago_object_check_cast((obj), (klass)))
00121
00122 #define GALAGO_OBJECT_GET_FLAGS(obj) (galago_object_get_flags(obj))
00123 #define GALAGO_OBJECT_SET_FLAGS(obj, flags) \
00124 galago_object_set_flags((obj), (flags))
00125
00126 #define GALAGO_OBJECT_SET_FLAG(obj, flag) \
00127 GALAGO_OBJECT_SET_FLAGS((obj), GALAGO_OBJECT_GET_FLAGS(obj) | (flag))
00128 #define GALAGO_OBJECT_UNSET_FLAG(obj, flag) \
00129 GALAGO_OBJECT_SET_FLAGS((obj), GALAGO_OBJECT_GET_FLAGS(obj) & ~(flag))
00130
00131 #define GALAGO_OBJECT_HAS_FLAG(obj, flag) \
00132 ((GALAGO_OBJECT_GET_FLAGS(obj) & (flag)) == (flag))
00133
00134 #ifdef __cplusplus
00135 extern "C" {
00136 #endif
00137
00138
00140
00153 GalagoObjectClass *galago_class_register(GalagoObjectClass *parent_class,
00154 const char *name,
00155 const char *dbus_iface,
00156 const GalagoObjectClassInfo *info);
00157
00165 GalagoObjectClass *galago_class_get_parent(const GalagoObjectClass *klass);
00166
00174 const char *galago_class_get_name(const GalagoObjectClass *klass);
00175
00183 const char *galago_class_get_dbus_iface(const GalagoObjectClass *klass);
00184
00192 GalagoSignalContext *galago_class_get_signal_context(
00193 const GalagoObjectClass *klass);
00194
00197
00199
00207 void *galago_object_new(GalagoObjectClass *klass);
00208
00216 void *galago_object_ref(void *object);
00217
00225 void *galago_object_unref(void *object);
00226
00234 GalagoObjectClass *galago_object_get_class(const void *object);
00235
00242 void galago_object_set_flags(void *object, unsigned long flags);
00243
00251 unsigned long galago_object_get_flags(const void *object);
00252
00259 void galago_object_set_dbus_path(void *object, const char *obj_path);
00260
00268 const char *galago_object_get_dbus_path(const void *object);
00269
00276 void galago_object_set_watch(void *object, galago_bool watch);
00277
00285 galago_bool galago_object_is_watched(const void *object);
00286
00294 void galago_object_set_data(void *object, const char *name, void *value);
00295
00304 void *galago_object_get_data(const void *object, const char *name);
00305
00313 GalagoContext *galago_object_get_context(const void *object);
00314
00325 GalagoObject *galago_object_check_cast(const void *ptr,
00326 const GalagoObjectClass *klass);
00327
00330 #ifdef __cplusplus
00331 }
00332 #endif
00333
00334 #endif