src/model/ComponentData.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_COMPONENTDATA_HPP | ||
| 7 | #define MODEL_COMPONENTDATA_HPP | ||
| 8 | |||
| 9 | #include "ModelAPI.hpp" | ||
| 10 | #include "ResourceObject.hpp" | ||
| 11 | |||
| 12 | #include "../utilities/core/UUID.hpp" | ||
| 13 | |||
| 14 | namespace openstudio { | ||
| 15 | namespace model { | ||
| 16 | |||
| 17 | namespace detail { | ||
| 18 | class ComponentData_Impl; | ||
| 19 | } // namespace detail | ||
| 20 | |||
| 21 | /** ComponentData is a ModelObject that wraps the OpenStudio IDD object 'OS:ComponentData'. It is | ||
| 22 | * used in \link Component Components\endlink to provide a contents list and data (unique | ||
| 23 | * identifiers and timestamps) that link the Component back to the Building Component Library | ||
| 24 | * (BCL). It is used in \link Model Models \endlink to indicate which objects are associated | ||
| 25 | * with which Components. */ | ||
| 26 | class MODEL_API ComponentData : public ResourceObject | ||
| 27 | { | ||
| 28 | public: | ||
| 29 | /** @name Constructors and Destructors */ | ||
| 30 | //@{ | ||
| 31 | |||
| 32 | 3311 | virtual ~ComponentData() override = default; | |
| 33 | // Default the copy and move operators because the virtual dtor is explicit | ||
| 34 | 1095 | ComponentData(const ComponentData& other) = default; | |
| 35 | 1120 | ComponentData(ComponentData&& other) = default; | |
| 36 | 2 | ComponentData& operator=(const ComponentData&) = default; | |
| 37 | 2 | ComponentData& operator=(ComponentData&&) = default; | |
| 38 | |||
| 39 | //@} | ||
| 40 | |||
| 41 | static IddObjectType iddObjectType(); | ||
| 42 | |||
| 43 | /** @name Getters */ | ||
| 44 | //@{ | ||
| 45 | |||
| 46 | /** The unique identifier of the component. This identifier is generated on initial construction | ||
| 47 | * with ModelObject::createComponent, and then maintained as-is for the life of the Component. | ||
| 48 | * It is used to track the Component across multiple models, on disk (.osc and .osm), in the | ||
| 49 | * project::ProjectDatabase, and in local and online BCLs. */ | ||
| 50 | UUID uuid() const; | ||
| 51 | |||
| 52 | /** Returns the unique identifier of the current version of the component. This UUID is | ||
| 53 | * automatically regenerated when any Component data changes. */ | ||
| 54 | UUID versionUUID() const; | ||
| 55 | |||
| 56 | /** Timestamp at time of creation (when the uuid was initially generated). Unix timestamp from | ||
| 57 | * January 1, 1970 00:00 GMT, in seconds. */ | ||
| 58 | boost::optional<int> creationTimestamp() const; | ||
| 59 | |||
| 60 | /** Timestamp of last versioning event (creation of versionUUID). Unix timestamp from January 1, | ||
| 61 | * 1970 00:00 GMT, in seconds. */ | ||
| 62 | boost::optional<int> versionTimestamp() const; | ||
| 63 | |||
| 64 | /** Returns the primary object of this component, which defines the Component's overall type. | ||
| 65 | * This method is equivalent to getComponentObject(0). */ | ||
| 66 | ModelObject primaryComponentObject() const; | ||
| 67 | |||
| 68 | /** Returns all of the \link ModelObject ModelObjects\endlink that are part of this Component. | ||
| 69 | * The primaryComponentObject() will be listed first. */ | ||
| 70 | std::vector<ModelObject> componentObjects() const; | ||
| 71 | |||
| 72 | /** Returns the ModelObject at objectIndex in the contents. Throws an openstudio::Exception if | ||
| 73 | * objectIndex >= numComponentObjects. */ | ||
| 74 | ModelObject getComponentObject(unsigned objectIndex) const; | ||
| 75 | |||
| 76 | //@} | ||
| 77 | /** @name Setters */ | ||
| 78 | //@{ | ||
| 79 | |||
| 80 | /** Creates and returns a new value for versionUUID(). */ | ||
| 81 | UUID createVersionUUID(); | ||
| 82 | |||
| 83 | //@} | ||
| 84 | /** @name Queries */ | ||
| 85 | //@{ | ||
| 86 | |||
| 87 | /** Returns the number of objects in the Component described by this object. Must be >= 1. */ | ||
| 88 | unsigned numComponentObjects() const; | ||
| 89 | |||
| 90 | //@} | ||
| 91 | protected: | ||
| 92 | /// @cond | ||
| 93 | using ImplType = detail::ComponentData_Impl; | ||
| 94 | |||
| 95 | friend class Model; | ||
| 96 | friend class openstudio::IdfObject; | ||
| 97 | |||
| 98 | // constructor | ||
| 99 | explicit ComponentData(const Model& model); | ||
| 100 | |||
| 101 | // constructor | ||
| 102 | explicit ComponentData(std::shared_ptr<detail::ComponentData_Impl> impl); | ||
| 103 | |||
| 104 | /// @endcond | ||
| 105 | private: | ||
| 106 | REGISTER_LOGGER("openstudio.model.ComponentData"); | ||
| 107 | }; | ||
| 108 | |||
| 109 | /** \relates ComponentData */ | ||
| 110 | using OptionalComponentData = boost::optional<ComponentData>; | ||
| 111 | |||
| 112 | /** \relates ComponentData */ | ||
| 113 | using ComponentDataVector = std::vector<ComponentData>; | ||
| 114 | |||
| 115 | } // namespace model | ||
| 116 | } // namespace openstudio | ||
| 117 | |||
| 118 | #endif // MODEL_COMPONENTDATA_HPP | ||
| 119 |