src/measure/ModelMeasure.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 MEASURE_MODELMEASURE_HPP | ||
| 7 | #define MEASURE_MODELMEASURE_HPP | ||
| 8 | |||
| 9 | #include "MeasureAPI.hpp" | ||
| 10 | #include "OSMeasure.hpp" | ||
| 11 | |||
| 12 | #include "../utilities/core/Logger.hpp" | ||
| 13 | |||
| 14 | namespace openstudio { | ||
| 15 | |||
| 16 | namespace model { | ||
| 17 | class Model; | ||
| 18 | } | ||
| 19 | |||
| 20 | namespace measure { | ||
| 21 | |||
| 22 | /** ModelMeasure is an abstract base class for UserScripts that operate on OpenStudio Models. */ | ||
| 23 | class MEASURE_API ModelMeasure : public OSMeasure | ||
| 24 | { | ||
| 25 | public: | ||
| 26 | /** @name Constructors and Destructors */ | ||
| 27 | //@{ | ||
| 28 | |||
| 29 | 62 | virtual ~ModelMeasure() = default; | |
| 30 | |||
| 31 | //@} | ||
| 32 | /** @name Getters */ | ||
| 33 | //@{ | ||
| 34 | |||
| 35 | /** Returns the arguments for this script. In interactive applications, an OSRunner presents | ||
| 36 | * these arguments to the user to produce an OSArgumentMap of user_arguments that it then passes | ||
| 37 | * to this script's run method. The same basic steps should happen in applications with non- | ||
| 38 | * interactive scripts, but in that case an entity other than an OSRunner may be in charge of | ||
| 39 | * collecting user arguments. The base class implementation returns an empty vector. */ | ||
| 40 | virtual std::vector<OSArgument> arguments(const openstudio::model::Model& model) const; | ||
| 41 | |||
| 42 | /** Returns the outputs for this script. The base class implementation returns an empty vector. */ | ||
| 43 | virtual std::vector<OSOutput> outputs() const; | ||
| 44 | |||
| 45 | //@} | ||
| 46 | /** @name Actions */ | ||
| 47 | //@{ | ||
| 48 | |||
| 49 | /** Run the script on the given model with the given runner and user_arguments. The base class | ||
| 50 | * implementation calls runner.prepareForMeasureRun(*this) and should be called at the | ||
| 51 | * beginning of derived class implementations of this method. (In C++, that call looks like | ||
| 52 | * ModelMeasure::run(model, runner, user_arguments). In Ruby that call looks like | ||
| 53 | * super(model, runner, user_arguments). */ | ||
| 54 | virtual bool run(openstudio::model::Model& model, OSRunner& runner, const std::map<std::string, OSArgument>& user_arguments) const; | ||
| 55 | |||
| 56 | //@} | ||
| 57 | // | ||
| 58 | protected: | ||
| 59 | ModelMeasure(); | ||
| 60 | |||
| 61 | private: | ||
| 62 | REGISTER_LOGGER("openstudio.measure.ModelMeasure"); | ||
| 63 | }; | ||
| 64 | |||
| 65 | } // namespace measure | ||
| 66 | } // namespace openstudio | ||
| 67 | |||
| 68 | #endif // MEASURE_MODELMEASURE_HPP | ||
| 69 |