| 138 | } |
| 139 | } |
| 140 | |
| 141 | bool ViewNodeAttribute::removeValue(const AttributeOwner* owner) { |
| 142 | if (_hasSingleAttribute) { |
| 143 | auto& attributeValue = getSingleAttributeValue(); |
| 144 | if (attributeValue.owner == owner) { |
| 145 | // Deconstruct our single attribute, which will make our ViewNodeAttribute empty |
| 146 | _hasSingleAttribute = false; |
| 147 | attributeValue.~AttributeValue(); |
| 148 | return true; |
| 149 | } else { |
| 150 | return false; |
| 151 | } |
| 152 | } else if (_hasAttributeCollection) { |
| 153 | auto& attributeCollection = getAttributeValueCollection(); |
| 154 | size_t i = 0; |
| 155 | |
| 156 | for (auto& attributeValue : attributeCollection.values) { |
| 157 | if (attributeValue.owner == owner) { |
| 158 | // Owner found, erase it from the collection |
| 159 | |
| 160 | attributeCollection.values.erase(attributeCollection.values.begin() + i); |
| 161 | |
| 162 | if (i == attributeCollection.resolvedValueIndex) { |
| 163 | // If our owner was the resolved value, update the |
| 164 | attributeCollection.updateResolvedValueIndex(getAttributeId()); |
| 165 | _appliedValueDirty = true; |
| 166 | |
| 167 | return true; |
| 168 | } else if (i < attributeCollection.resolvedValueIndex) { |
| 169 | attributeCollection.resolvedValueIndex--; |
| 170 | } |
| 171 | |
| 172 | return false; |
| 173 | } |
| 174 | |
| 175 | i++; |
| 176 | } |
| 177 | |
| 178 | // Owner was not found in the collection |
| 179 | |
| 180 | return false; |
| 181 | } else { |
| 182 | return false; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | void ViewNodeAttribute::replaceValue(const Value& value) { |
no test coverage detected