MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / suggestedStandardsTemplates

Method suggestedStandardsTemplates

src/model/Building.cpp:309–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307 }
308
309 std::vector<std::string> Building_Impl::suggestedStandardsTemplates() const {
310
311 boost::optional<std::string> standardsTemplate = this->standardsTemplate();
312
313 // Make a dummy model and a dummy space Type,
314 // and call suggestedStandardsTemplates from it, so we don't have to repeat code here
315 Model tempModel;
316 SpaceType tempSpaceType(tempModel);
317 std::vector<std::string> result = tempSpaceType.suggestedStandardsTemplates();
318
319 // include values from model
320 for (const SpaceType& other : this->model().getConcreteModelObjects<SpaceType>()) {
321 if (boost::optional<std::string> otherTemplate = other.standardsTemplate()) {
322 result.push_back(*otherTemplate);
323 }
324 }
325
326 // remove standardsTemplate
327 IstringFind finder;
328 if (standardsTemplate) {
329 finder.addTarget(*standardsTemplate);
330 }
331 auto it = std::remove_if(result.begin(), result.end(), finder);
332 result.resize(std::distance(result.begin(), it));
333
334 // sort
335 std::sort(result.begin(), result.end(), IstringCompare());
336
337 // make unique
338 // DLM: have to sort before calling unique, unique only works on consecutive elements
339 it = std::unique(result.begin(), result.end(), IstringEqual());
340 result.resize(std::distance(result.begin(), it));
341
342 // add current to front
343 if (standardsTemplate) {
344 result.insert(result.begin(), *standardsTemplate);
345 }
346
347 return result;
348 }
349
350 bool Building_Impl::setStandardsTemplate(const std::string& standardsTemplate) {
351 bool result = setString(OS_BuildingFields::StandardsTemplate, standardsTemplate);

Callers 1

TEST_FFunction · 0.45

Calls 8

standardsTemplateMethod · 0.95
addTargetMethod · 0.80
beginMethod · 0.80
resizeMethod · 0.80
modelMethod · 0.45
push_backMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by 1

TEST_FFunction · 0.36