[Galago-commits] r2621 - in trunk/libgalago: . libgalago tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Fri Mar 24 00:41:20 PST 2006
Author: chipx86
Date: 2006-03-24 00:41:16 -0800 (Fri, 24 Mar 2006)
New Revision: 2621
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-object.c
trunk/libgalago/libgalago/galago-object.h
trunk/libgalago/libgalago/galago-status.c
trunk/libgalago/tests/get-presence.c
Log:
Add galago_object_get_has_attribute(), and remove galago_status_attr_exists().
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-03-24 04:29:48 UTC (rev 2620)
+++ trunk/libgalago/ChangeLog 2006-03-24 08:41:16 UTC (rev 2621)
@@ -1,3 +1,12 @@
+Fri Mar 24 00:40:43 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-object.c:
+ * libgalago/galago-object.h:
+ * libgalago/galago-status.c:
+ * tests/get-presence.c:
+ - Add galago_object_get_has_attribute(), and remove
+ galago_status_attr_exists().
+
Sun Mar 19 17:23:49 PST 2006 Christian Hammond <chipx86 at chipx86.com>
A libgalago/galago-key-value.c:
Modified: trunk/libgalago/libgalago/galago-object.c
===================================================================
--- trunk/libgalago/libgalago/galago-object.c 2006-03-24 04:29:48 UTC (rev 2620)
+++ trunk/libgalago/libgalago/galago-object.c 2006-03-24 08:41:16 UTC (rev 2621)
@@ -598,6 +598,17 @@
return GALAGO_OBJECT_GET_CLASS(object)->get_attribute(object, name);
}
+gboolean
+galago_object_get_has_attribute(const GalagoObject *object, const char *name)
+{
+ g_return_val_if_fail(object != NULL, FALSE);
+ g_return_val_if_fail(GALAGO_IS_OBJECT(object), FALSE);
+ g_return_val_if_fail(GALAGO_OBJECT_SUPPORTS_ATTRS(object), FALSE);
+ g_return_val_if_fail(name != NULL && *name != '\0', FALSE);
+
+ return galago_object_get_attribute(object, name) != NULL;
+}
+
static GList *
galago_object_real_get_attributes(const GalagoObject *object)
{
Modified: trunk/libgalago/libgalago/galago-object.h
===================================================================
--- trunk/libgalago/libgalago/galago-object.h 2006-03-24 04:29:48 UTC (rev 2620)
+++ trunk/libgalago/libgalago/galago-object.h 2006-03-24 08:41:16 UTC (rev 2621)
@@ -356,6 +356,17 @@
const char *name);
/**
+ * Returns whether or not an object has a specific attribute set.
+ *
+ * @param object The object.
+ * @param name The name of the attribute.
+ *
+ * @return TRUE if the attribute is set, or FALSE.
+ */
+gboolean galago_object_get_has_attribute(const GalagoObject *object,
+ const char *name);
+
+/**
* Returns the list of attributes in an object, represented by GalagoKeyValue
* structs.
*
Modified: trunk/libgalago/libgalago/galago-status.c
===================================================================
--- trunk/libgalago/libgalago/galago-status.c 2006-03-24 04:29:48 UTC (rev 2620)
+++ trunk/libgalago/libgalago/galago-status.c 2006-03-24 08:41:16 UTC (rev 2621)
@@ -685,16 +685,6 @@
return (key_value == NULL ? NULL : key_value->value);
}
-gboolean
-galago_status_attr_exists(const GalagoStatus *status, const char *attr_id)
-{
- g_return_val_if_fail(status != NULL, FALSE);
- g_return_val_if_fail(attr_id != NULL, FALSE);
- g_return_val_if_fail(GALAGO_IS_STATUS(status), FALSE);
-
- return g_hash_table_lookup(status->priv->attrs_table, attr_id) != NULL;
-}
-
GList *
galago_status_get_attributes(const GalagoObject *object)
{
Modified: trunk/libgalago/tests/get-presence.c
===================================================================
--- trunk/libgalago/tests/get-presence.c 2006-03-24 04:29:48 UTC (rev 2620)
+++ trunk/libgalago/tests/get-presence.c 2006-03-24 08:41:16 UTC (rev 2621)
@@ -108,12 +108,52 @@
l != NULL;
l = l->next)
{
+ GList *attrs, *l2;
+
status = (GalagoStatus *)l->data;
printf("\tType: %s\n",
get_name_from_status_type(galago_status_get_primitive(status)));
printf("\tID: %s\n", galago_status_get_id(status));
printf("\tName: %s\n", galago_status_get_name(status));
+
+ attrs = galago_object_get_attributes(GALAGO_OBJECT(status));
+
+ if (attrs != NULL)
+ {
+ printf("\tAttributes:\n");
+
+ for (l2 = attrs; l2 != NULL; l2 = l2->next)
+ {
+ GalagoKeyValue *key_value = (GalagoKeyValue *)l2->data;
+
+ if (G_VALUE_HOLDS_INT(key_value->value))
+ {
+ printf("\t\t%s: %d\n",
+ key_value->key,
+ g_value_get_int(key_value->value));
+ }
+ else if (G_VALUE_HOLDS_STRING(key_value->value))
+ {
+ printf("\t\t%s: %s\n",
+ key_value->key,
+ g_value_get_string(key_value->value));
+ }
+ else if (G_VALUE_HOLDS_DOUBLE(key_value->value))
+ {
+ printf("\t\t%s: %f\n",
+ key_value->key,
+ g_value_get_double(key_value->value));
+ }
+ else if (G_VALUE_HOLDS_BOOLEAN(key_value->value))
+ {
+ printf("\t\t%s: %s\n",
+ key_value->key,
+ g_value_get_boolean(key_value->value)
+ ? "true" : "false");
+ }
+ }
+ }
}
}
More information about the galago-commits
mailing list