/* diversity-object.h - DiversityObject, lovely resident in DiversityWorld * * Copyright 2007-2008 OpenMoko, Inc. * Authored by Chia-I Wu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _DIVERSITY_OBJECT_H_ #define _DIVERSITY_OBJECT_H_ #define G_DISABLE_CAST_CHECKS #include #include G_BEGIN_DECLS #define DIVERSITY_TYPE_OBJECT (diversity_object_get_type()) #define DIVERSITY_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), DIVERSITY_TYPE_OBJECT, DiversityObject)) #define DIVERSITY_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), DIVERSITY_TYPE_OBJECT, DiversityObjectClass)) #define DIVERSITY_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), DIVERSITY_TYPE_OBJECT)) #define DIVERSITY_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), DIVERSITY_TYPE_OBJECT)) #define DIVERSITY_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), DIVERSITY_TYPE_OBJECT, DiversityObjectClass)) typedef struct _DiversityObject DiversityObject; typedef struct _DiversityObjectClass DiversityObjectClass; typedef enum _DiversityObjectType DiversityObjectType; typedef enum _DiversityObjectAccuracy DiversityObjectAccuracy; enum _DiversityObjectType { DIVERSITY_OBJECT_TYPE_OBJECT, DIVERSITY_OBJECT_TYPE_VIEWPORT, DIVERSITY_OBJECT_TYPE_TAG, DIVERSITY_OBJECT_TYPE_BARD, DIVERSITY_OBJECT_TYPE_AP, DIVERSITY_OBJECT_TYPE_MAP, NUM_DIVERSITY_OBJECT_TYPES, }; enum _DiversityObjectFlag { DIVERSITY_OBJECT_FLAG_PERSISTENT = 0x1, DIVERSITY_OBJECT_FLAG_PUBLIC = 0x2, DIVERSITY_OBJECT_FLAG_PUSHED = 0x4, }; enum _DiversityObjectAccuracy { DIVERSITY_OBJECT_ACCURACY_NONE, DIVERSITY_OBJECT_ACCURACY_DERIVED, DIVERSITY_OBJECT_ACCURACY_DIRECT, /* from GPS, and etc. */ DIVERSITY_OBJECT_ACCURACY_EXACT, }; struct _DiversityObject { GObject parent_object; /* avoid DIVERSITY_IS_XXX overhead */ DiversityObjectType type; gchar *id; guint32 serial_number; gboolean ubiquitous; }; struct _DiversityObjectClass { GObjectClass parent_class; guint32 serial_number; void (*property_changed)(DiversityObject *obj, const gchar *name, const GValue *value); void (*geometry_changed)(DiversityObject *obj, gdouble lon, gdouble lat, gdouble width, gdouble height); void (*connect)(DiversityObject *obj, DiversityObject *target); void (*disconnect)(DiversityObject *obj, DiversityObject *target); }; GType diversity_object_get_type(void) G_GNUC_CONST; DiversityObject *diversity_object_new(const char *id); void diversity_object_geometry_set(DiversityObject *obj, gdouble lon, gdouble lat, gdouble width, gdouble height); void diversity_object_geometry_get(DiversityObject *obj, gdouble *lon, gdouble *lat, gdouble *width, gdouble *height); void diversity_object_set_accuracy(DiversityObject *obj, DiversityObjectAccuracy accuracy); DiversityObjectAccuracy diversity_object_get_accuracy(DiversityObject *obj); void diversity_object_set_flags(DiversityObject *obj, guint flags); guint diversity_object_get_flags(DiversityObject *obj); void diversity_object_set_persistent(DiversityObject *obj, gboolean persist); gboolean diversity_object_get_persistent(DiversityObject *obj); void diversity_object_set_public(DiversityObject *obj, gboolean pub); gboolean diversity_object_get_public(DiversityObject *obj); void diversity_object_set_pushed(DiversityObject *obj, gboolean pushed); gboolean diversity_object_get_pushed(DiversityObject *obj); void diversity_object_touch(DiversityObject *obj); GTime diversity_object_get_timestamp(DiversityObject *obj); void diversity_object_connect(DiversityObject *obj, DiversityObject *target); void diversity_object_disconnect(DiversityObject *obj, DiversityObject *target); const GSList *diversity_object_get_connections(DiversityObject *obj); gboolean diversity_object_contain(DiversityObject *obj1, DiversityObject *obj2); gboolean diversity_object_intersect(DiversityObject *obj1, DiversityObject *obj2); G_END_DECLS #endif /* _DIVERSITY_OBJECT_H_ */