| 186 | } |
| 187 | |
| 188 | void ArraySchemaEvolution::add_attribute(shared_ptr<const Attribute> attr) { |
| 189 | std::lock_guard<std::mutex> lock(mtx_); |
| 190 | if (!attr) { |
| 191 | throw ArraySchemaEvolutionException( |
| 192 | "Cannot add attribute; Input attribute is null"); |
| 193 | } |
| 194 | for (const auto& a : attributes_to_add_) { |
| 195 | if (a->name() == attr->name()) { |
| 196 | throw ArraySchemaEvolutionException( |
| 197 | "Cannot add attribute; Input attribute name is already there"); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | // Create new attribute and potentially set a default name |
| 202 | /* |
| 203 | * At present, the container for attributes within the schema evolution |
| 204 | * object is based on `unique_ptr`. The argument is `shared_ptr`, since |
| 205 | * that's how C API handles and `class Array` store them. It might be better |
| 206 | * to change the container type, but until then, we copy the attribute into |
| 207 | * a new allocation. |
| 208 | */ |
| 209 | attributes_to_add_.push_back( |
| 210 | tdb_unique_ptr<Attribute>(tdb_new(Attribute, *attr))); |
| 211 | if (attributes_to_drop_.find(attr->name()) != attributes_to_drop_.end()) { |
| 212 | attributes_to_drop_.erase(attr->name()); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | std::vector<std::string> ArraySchemaEvolution::attribute_names_to_add() const { |
| 217 | std::lock_guard<std::mutex> lock(mtx_); |
no test coverage detected