Skip to content

Commit

Permalink
[modify_ai]action=change now automatically inserts an id= key if not …
Browse files Browse the repository at this point in the history
…present

Also when changing an aspect, name= is inserted if not present.
  • Loading branch information
CelticMinstrel authored and mattsc committed Mar 22, 2016
1 parent 155d700 commit 5954e3f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/ai/composite/property_handler.hpp
Expand Up @@ -64,7 +64,7 @@ class base_property_handler {
virtual ~base_property_handler() {}

virtual component* handle_get(const path_element &child) = 0;
virtual bool handle_change(const path_element &child, const config &cfg) = 0;
virtual bool handle_change(const path_element &child, config cfg) = 0;
virtual bool handle_add(const path_element &child, const config &cfg) = 0;
virtual bool handle_delete(const path_element &child) = 0;
virtual std::vector< component* > handle_get_children() = 0;
Expand All @@ -90,11 +90,14 @@ class vector_property_handler : public base_property_handler {
}
return NULL;
}
bool handle_change(const path_element &child, const config &cfg)
bool handle_change(const path_element &child, config cfg)
{
if (!handle_delete(child)) {
return false;
}
if (!cfg.has_attribute("id")) {
cfg["id"] = child.id;
}

return handle_add(child,cfg);
}
Expand Down Expand Up @@ -189,7 +192,7 @@ class facets_property_handler : public vector_property_handler<T> {
return vector_property_handler<T>::handle_get(child);
}

bool handle_change(const path_element &child, const config &cfg)
bool handle_change(const path_element &child, config cfg)
{
//* is a special case - 'replace the default facet'
if (child.id == "*") {
Expand Down Expand Up @@ -235,11 +238,15 @@ class aspect_property_handler : public base_property_handler {
return NULL;
}

bool handle_change(const path_element &child, const config &cfg)
bool handle_change(const path_element &child, config cfg)
{
if (cfg["id"] != child.id || aspects_.find(child.id) == aspects_.end()) {
if (aspects_.find(child.id) == aspects_.end()) {
return false;
}
if (!cfg.has_attribute("name")) {
cfg["name"] = "composite_aspect";
}
cfg["id"] = child.id;
factory_(aspects_, cfg, child.id);
return true;
}
Expand Down

0 comments on commit 5954e3f

Please sign in to comment.