src/model/ScheduleBase.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_SCHEDULEBASE_HPP | ||
| 7 | #define MODEL_SCHEDULEBASE_HPP | ||
| 8 | |||
| 9 | #include "ModelAPI.hpp" | ||
| 10 | #include "ResourceObject.hpp" | ||
| 11 | |||
| 12 | namespace openstudio { | ||
| 13 | namespace model { | ||
| 14 | |||
| 15 | class ScheduleTypeLimits; | ||
| 16 | |||
| 17 | namespace detail { | ||
| 18 | |||
| 19 | class ScheduleBase_Impl; | ||
| 20 | |||
| 21 | } // namespace detail | ||
| 22 | |||
| 23 | /** ScheduleBase is a ResourceObject that serves as a base class for Schedule and ScheduleDay, | ||
| 24 | * that is, objects with ScheduleTypeLimits. This class provides getters and setters for | ||
| 25 | * ScheduleTypeLimits. Note that while users can explicitly set their own ScheduleTypeLimits, | ||
| 26 | * we recommend using the \link ScheduleTypeRegistry ScheduleTypeRegistry\endlink and | ||
| 27 | * related non-member functions, or letting user \link ModelObject ModelObjects\endlink set | ||
| 28 | * this field, instead. */ | ||
| 29 | class MODEL_API ScheduleBase : public ResourceObject | ||
| 30 | { | ||
| 31 | public: | ||
| 32 | /** @name Constructors and Destructors */ | ||
| 33 | //@{ | ||
| 34 | |||
| 35 | 272638 | virtual ~ScheduleBase() override = default; | |
| 36 | // Default the copy and move operators because the virtual dtor is explicit | ||
| 37 | 45848 | ScheduleBase(const ScheduleBase& other) = default; | |
| 38 | 104318 | ScheduleBase(ScheduleBase&& other) = default; | |
| 39 | 2 | ScheduleBase& operator=(const ScheduleBase&) = default; | |
| 40 | 2010 | ScheduleBase& operator=(ScheduleBase&&) = default; | |
| 41 | |||
| 42 | //@} | ||
| 43 | /** @name Getters */ | ||
| 44 | //@{ | ||
| 45 | |||
| 46 | /** Returns the ScheduleTypeLimits of this object, if set. */ | ||
| 47 | boost::optional<ScheduleTypeLimits> scheduleTypeLimits() const; | ||
| 48 | |||
| 49 | //@} | ||
| 50 | /** @name Setters */ | ||
| 51 | //@{ | ||
| 52 | |||
| 53 | /** Returns true if scheduleTypeLimits is compatible with this object and is actually set. | ||
| 54 | * The operation will fail if the Schedule or ScheduleDay is in use in a way that restricts | ||
| 55 | * the allowable ScheduleTypeLimits and the new value (scheduleTypeLimits) is incompatible | ||
| 56 | * with that use. For instance, if a Schedule is used with a Lights object, then only | ||
| 57 | * properly configured fractional ScheduleTypeLimits will succeed. ScheduleDay objects used | ||
| 58 | * in a ScheduleRuleset or a ScheduleRule are restricted to use ScheduleTypeLimits compatible | ||
| 59 | * with those of their (ScheduleRuleset or ScheduleRule) parent. */ | ||
| 60 | bool setScheduleTypeLimits(const ScheduleTypeLimits& scheduleTypeLimits); | ||
| 61 | |||
| 62 | /** Returns true if the scheduleTypeLimits() of this object is successfully cleared. Will fail | ||
| 63 | * if this object is being used by an object that expects it to have a ScheduleTypeLimits. */ | ||
| 64 | bool resetScheduleTypeLimits(); | ||
| 65 | |||
| 66 | // ensure that this object does not contain the date 2/29 | ||
| 67 | void ensureNoLeapDays(); | ||
| 68 | |||
| 69 | //@} | ||
| 70 | protected: | ||
| 71 | /// @cond | ||
| 72 | using ImplType = detail::ScheduleBase_Impl; | ||
| 73 | |||
| 74 | explicit ScheduleBase(std::shared_ptr<detail::ScheduleBase_Impl> impl); | ||
| 75 | |||
| 76 | ScheduleBase(IddObjectType type, const Model& model); | ||
| 77 | |||
| 78 | friend class openstudio::IdfObject; | ||
| 79 | friend class openstudio::detail::IdfObject_Impl; | ||
| 80 | friend class detail::ScheduleBase_Impl; | ||
| 81 | friend class Model; | ||
| 82 | |||
| 83 | /// @endcond | ||
| 84 | private: | ||
| 85 | REGISTER_LOGGER("openstudio.model.ScheduleBase"); | ||
| 86 | }; | ||
| 87 | |||
| 88 | /** \relates ScheduleBase*/ | ||
| 89 | using OptionalScheduleBase = boost::optional<ScheduleBase>; | ||
| 90 | |||
| 91 | /** \relates ScheduleBase*/ | ||
| 92 | using ScheduleBaseVector = std::vector<ScheduleBase>; | ||
| 93 | |||
| 94 | } // namespace model | ||
| 95 | } // namespace openstudio | ||
| 96 | |||
| 97 | #endif // MODEL_SCHEDULEBASE_HPP | ||
| 98 |