| 105 | } |
| 106 | |
| 107 | std::vector<IdfObject> TableLookup_Impl::remove() { |
| 108 | std::vector<IdfObject> result; |
| 109 | |
| 110 | // ModelObjectList is kinda dumb, it removes all the modelObjects it has, which we don't want |
| 111 | // Instead we look at the independent variables listed, if they are used only once => delete them |
| 112 | // Then clear the modelObjectList, and remove it |
| 113 | if (boost::optional<ModelObjectList> varList = this->independentVariableList()) { |
| 114 | auto vars = castVector<ResourceObject>(varList->modelObjects()); |
| 115 | |
| 116 | for (auto& var : vars) { |
| 117 | if (var.directUseCount() == 1) { |
| 118 | std::vector<IdfObject> removedModelObject = var.remove(); |
| 119 | result.insert(result.end(), removedModelObject.begin(), removedModelObject.end()); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | varList->clearExtensibleGroups(); // Clearer than removeAllModelObjects (which does the same thing, but could mean delete all objects) |
| 124 | std::vector<IdfObject> removedVarList = varList->remove(); |
| 125 | result.insert(result.end(), removedVarList.begin(), removedVarList.end()); |
| 126 | } |
| 127 | |
| 128 | std::vector<IdfObject> removedObject = Curve_Impl::remove(); |
| 129 | result.insert(result.end(), removedObject.begin(), removedObject.end()); |
| 130 | |
| 131 | return result; |
| 132 | } |
| 133 | |
| 134 | boost::optional<ModelObjectList> TableLookup_Impl::independentVariableList() const { |
| 135 | return getObject<ModelObject>().getModelObjectTarget<ModelObjectList>(OS_Table_LookupFields::IndependentVariableListName); |
nothing calls this directly
no test coverage detected