GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 0 / 1 / 1
Functions: -% 0 / 1 / 1
Branches: -% 0 / 1 / 1

src/model/ModelMerger.hpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #ifndef MODEL_MODELMERGER_HPP
7 #define MODEL_MODELMERGER_HPP
8
9 #include "ModelAPI.hpp"
10 #include "Model.hpp"
11
12 #include "../utilities/core/Logger.hpp"
13 #include "../utilities/core/StringStreamLogSink.hpp"
14
15 #include <map>
16
17 namespace openstudio {
18 namespace model {
19 class Site;
20 class Facility;
21 class Building;
22 class Space;
23 class ShadingSurfaceGroup;
24 class ThermalZone;
25 class SpaceType;
26 class BuildingStory;
27 class BuildingUnit;
28 class DefaultConstructionSet;
29
30 /** ModelMerger updates content in a current OpenStudio Model based on data from a new OpenStudio Model.
31 * A map of handles which relates objects in the current OpenStudio Model to objects in the new OpenStudio Model is required.
32 * Objects in current OpenStudio Model may map to 0-1 objects in new OpenStudio Model. If an object in the new OpenStudio Model
33 * does not correspond to an object in the current OpenStudio Model it is assumed to be a new object.
34 */
35 class MODEL_API ModelMerger
36 {
37 public:
38 ModelMerger();
39
40 /// Merges changes from newModel into currentModel
41 /// Handle mapping is mapping of handles in currentModel (keys) to handles in newModel (values)
42 void mergeModels(Model& currentModel, const Model& newModel, const std::map<UUID, UUID>& handleMapping);
43
44 /// List of IddObjectTypes which are merged
45 std::vector<IddObjectType> iddObjectTypesToMerge() const;
46
47 /// Allow users to specify which IddObjectTypes to merge, not yet implemented (always returns false)
48 bool setIddObjectTypesToMerge(const std::vector<IddObjectType>& iddObjectTypesToMerge);
49
50 /// Suggest a handle mapping between currentModel and newModel
51 /// First checks if objects with same handle and type exist
52 /// Second checks if objects with same CADObjectId attribute and type exist
53 /// Third checks if objects with same name and type
54 std::map<UUID, UUID> suggestHandleMapping(const Model& currentModel, const Model& newModel) const;
55
56 /// Get warning messages generated by the last translation.
57 std::vector<LogMessage> warnings() const;
58
59 /// Get error messages generated by the last translation.
60 std::vector<LogMessage> errors() const;
61
62 private:
63 − REGISTER_LOGGER("openstudio.model.ModelMerger");
64
65 void mergeSite(Site& currentSite, const Site& newSite);
66 void mergeFacility(Facility& currentFacility, const Facility& newFacility);
67 void mergeBuilding(Building& currentBuilding, const Building& newBuilding);
68 void mergeSpace(Space& currentSpace, const Space& newSpace);
69 void mergeShadingSurfaceGroup(ShadingSurfaceGroup& currentGroup, const ShadingSurfaceGroup& newGroup);
70 void mergeThermalZone(ThermalZone& currentThermalZone, const ThermalZone& newThermalZone);
71 void mergeSpaceType(SpaceType& currentSpaceType, const SpaceType& newSpaceType);
72 void mergeBuildingStory(BuildingStory& currentBuildingStory, const BuildingStory& newBuildingStory);
73 void mergeBuildingUnit(BuildingUnit& currentBuildingUnit, const BuildingUnit& newBuildingUnit);
74 void mergeDefaultConstructionSet(DefaultConstructionSet& currentDefaultConstructionSet, const DefaultConstructionSet& newDefaultConstructionSet);
75
76 boost::optional<UUID> getNewModelHandle(const UUID& currentHandle);
77 boost::optional<UUID> getCurrentModelHandle(const UUID& newHandle);
78
79 boost::optional<WorkspaceObject> getCurrentModelObject(const WorkspaceObject& newObject);
80
81 StringStreamLogSink m_logSink;
82
83 Model m_currentModel;
84 Model m_newModel;
85 std::set<UUID> m_newMergedHandles;
86 std::vector<IddObjectType> m_iddObjectTypesToMerge;
87 std::map<UUID, UUID> m_currentToNewHandleMapping;
88 std::map<UUID, UUID> m_newToCurrentHandleMapping;
89 };
90
91 } // namespace model
92 } // namespace openstudio
93 #endif //MODEL_MODELMERGER_HPP
94