| 282 | } |
| 283 | |
| 284 | std::vector<ModelObject> EnergyManagementSystemProgram_Impl::referencedObjects() const { |
| 285 | //return vector of model objects that are referenced in program |
| 286 | std::vector<ModelObject> result; |
| 287 | const int subs[] = {1}; |
| 288 | std::string possible_uid; |
| 289 | |
| 290 | const Model m = this->model(); |
| 291 | boost::optional<ModelObject> modelObject; |
| 292 | |
| 293 | boost::optional<std::vector<std::string>> body = this->lines(); |
| 294 | if (body.is_initialized()) { |
| 295 | //assume body is a vector of strings |
| 296 | for (size_t i = 0; i < body.get().size(); i++) { |
| 297 | //find uids |
| 298 | boost::sregex_token_iterator j(body.get().at(i).begin(), body.get().at(i).end(), uuidInString(), subs); |
| 299 | |
| 300 | while (j != boost::sregex_token_iterator()) { |
| 301 | possible_uid = *j++; |
| 302 | //look to see if uid is in the model and return the object |
| 303 | UUID uid = toUUID(possible_uid); |
| 304 | modelObject = m.getModelObject<model::ModelObject>(uid); |
| 305 | if (modelObject) { |
| 306 | result.push_back(modelObject.get()); |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | return result; |
| 312 | } |
| 313 | |
| 314 | std::vector<std::string> EnergyManagementSystemProgram_Impl::invalidReferencedObjects() const { |
| 315 | //return vector of body lines that contain missing uid strings for invalid referenced objects |