* Sets the property using the provided name * @param property name * @param value property value. * @return result of setting property. */
| 66 | * @return result of setting property. |
| 67 | */ |
| 68 | bool ConfigurableComponent::setProperty(const std::string name, std::string value) { |
| 69 | std::lock_guard<std::mutex> lock(configuration_mutex_); |
| 70 | auto it = properties_.find(name); |
| 71 | |
| 72 | if (it != properties_.end()) { |
| 73 | Property orig_property = it->second; |
| 74 | Property& new_property = it->second; |
| 75 | auto onExit = gsl::finally([&]{ |
| 76 | onPropertyModified(orig_property, new_property); |
| 77 | logger_->log_debug("Component %s property name %s value %s", name, new_property.getName(), value); |
| 78 | }); |
| 79 | new_property.setValue(value); |
| 80 | return true; |
| 81 | } else { |
| 82 | if (accept_all_properties_) { |
| 83 | Property new_property(name, STAR_PROPERTIES, value, false, "", { }, { }); |
| 84 | new_property.setTransient(); |
| 85 | new_property.setValue(value); |
| 86 | properties_.insert(std::pair<std::string, Property>(name, new_property)); |
| 87 | return true; |
| 88 | } else { |
| 89 | logger_->log_debug("Component %s cannot be set to %s", name, value); |
| 90 | return false; |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Sets the property using the provided name |