Add:Core:Integrated functions to add or remove an attribute
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 4 Oct 2011 18:23:45 +0000 (18:23 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 4 Oct 2011 18:23:45 +0000 (18:23 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4828 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/command.c

index c0c5aa1..be0463c 100644 (file)
@@ -153,6 +153,25 @@ command_object_get_attr(struct context *ctx, struct attr *object, enum attr_type
        return func->get_attr(object->u.data, attr_type, ret, NULL);
 }
 
+static int
+command_object_add_attr(struct context *ctx, struct attr *object, struct attr *attr)
+{
+       struct object_func *func=object_func_lookup(object->type);
+       if (!func || !func->add_attr)
+               return 0;
+       return func->add_attr(object->u.data, attr);
+}
+
+static int
+command_object_remove_attr(struct context *ctx, struct attr *object, struct attr *attr)
+{
+       struct object_func *func=object_func_lookup(object->type);
+       if (!func || !func->remove_attr)
+               return 0;
+       return func->remove_attr(object->u.data, attr);
+}
+
+
 static void
 command_get_attr(struct context *ctx, struct result *res)
 {
@@ -409,6 +428,10 @@ command_call_function(struct context *ctx, struct result *res)
                                res->attr.u.data=func->create(NULL, list);
                        }
                }
+       } else if (!strcmp(function,"add_attr")) {
+               command_object_add_attr(ctx, &res->attr, list[0]);
+       } else if (!strcmp(function,"remove_attr")) {
+               command_object_remove_attr(ctx, &res->attr, list[0]);
        } else {
                if (command_object_get_attr(ctx, &res->attr, attr_callback_list, &cbl)) {
                        int valid;