src/model/ExternalFile.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_EXTERNALFILE_HPP | ||
| 7 | #define MODEL_EXTERNALFILE_HPP | ||
| 8 | |||
| 9 | #include "ModelAPI.hpp" | ||
| 10 | #include "ResourceObject.hpp" | ||
| 11 | |||
| 12 | #include "../utilities/core/Path.hpp" | ||
| 13 | |||
| 14 | namespace openstudio { | ||
| 15 | |||
| 16 | namespace model { | ||
| 17 | |||
| 18 | class ScheduleFile; | ||
| 19 | class PythonPluginInstance; | ||
| 20 | class ChillerElectricASHRAE205; | ||
| 21 | |||
| 22 | namespace detail { | ||
| 23 | |||
| 24 | class ExternalFile_Impl; | ||
| 25 | |||
| 26 | } // namespace detail | ||
| 27 | |||
| 28 | /** ExternalFile is a ResourceObject that wraps the OpenStudio IDD object 'OS:External:File'. */ | ||
| 29 | class MODEL_API ExternalFile : public ResourceObject | ||
| 30 | { | ||
| 31 | public: | ||
| 32 | /** @name Constructors and Destructors */ | ||
| 33 | //@{ | ||
| 34 | |||
| 35 | 389 | virtual ~ExternalFile() override = default; | |
| 36 | // Default the copy and move operators because the virtual dtor is explicit | ||
| 37 | 65 | ExternalFile(const ExternalFile& other) = default; | |
| 38 | 171 | ExternalFile(ExternalFile&& other) = default; | |
| 39 | ✗ | ExternalFile& operator=(const ExternalFile&) = default; | |
| 40 | ✗ | ExternalFile& operator=(ExternalFile&&) = default; | |
| 41 | |||
| 42 | //@} | ||
| 43 | |||
| 44 | static IddObjectType iddObjectType(); | ||
| 45 | |||
| 46 | static std::vector<std::string> columnSeparatorValues(); | ||
| 47 | |||
| 48 | /** This factory method will look for an existing ExternalFile with the same file name. If not it will try to create one. | ||
| 49 | * - If copyFile is true, the file will be copied to the first entry of the WorkflowJSON's absoluteFilePaths() (or absoluteRootDir() if empty); | ||
| 50 | * - If copyFile is false, it assumes this is an absolute path. | ||
| 51 | * In both cases, the filename should resolve to a valid path or this will return an empty optional. */ | ||
| 52 | static boost::optional<ExternalFile> getExternalFile(const Model& model, const std::string& filename, bool copyFile = true); | ||
| 53 | |||
| 54 | /** @name Getters */ | ||
| 55 | //@{ | ||
| 56 | |||
| 57 | std::string fileName() const; | ||
| 58 | |||
| 59 | path filePath() const; | ||
| 60 | |||
| 61 | //boost::optional<std::string> columnSeparator() const; | ||
| 62 | |||
| 63 | //bool isColumnSeparatorDefaulted() const; | ||
| 64 | |||
| 65 | //@} | ||
| 66 | /** @name Setters */ | ||
| 67 | //@{ | ||
| 68 | |||
| 69 | //bool setColumnSeparator(const std::string& columnSeparator); | ||
| 70 | |||
| 71 | //void resetColumnSeparator(); | ||
| 72 | |||
| 73 | //@} | ||
| 74 | /** @name Other */ | ||
| 75 | //@{ | ||
| 76 | |||
| 77 | //bool isValid(); | ||
| 78 | |||
| 79 | std::vector<ScheduleFile> scheduleFiles() const; | ||
| 80 | |||
| 81 | std::vector<PythonPluginInstance> pythonPluginInstances() const; | ||
| 82 | |||
| 83 | std::vector<ChillerElectricASHRAE205> chillerElectricASHRAE205s() const; | ||
| 84 | |||
| 85 | //@} | ||
| 86 | protected: | ||
| 87 | /// @cond | ||
| 88 | using ImplType = detail::ExternalFile_Impl; | ||
| 89 | |||
| 90 | explicit ExternalFile(std::shared_ptr<detail::ExternalFile_Impl> impl); | ||
| 91 | |||
| 92 | friend class Model; | ||
| 93 | friend class IdfObject; | ||
| 94 | friend class openstudio::detail::IdfObject_Impl; | ||
| 95 | /// @endcond | ||
| 96 | private: | ||
| 97 | − | REGISTER_LOGGER("openstudio.model.ExternalFile"); | |
| 98 | |||
| 99 | ExternalFile(const Model& model, const std::string& filename, bool copyFile = true); | ||
| 100 | |||
| 101 | bool setFileName(const std::string& fileName); | ||
| 102 | }; | ||
| 103 | |||
| 104 | /** \relates ExternalFile*/ | ||
| 105 | using OptionalExternalFile = boost::optional<ExternalFile>; | ||
| 106 | |||
| 107 | /** \relates ExternalFile*/ | ||
| 108 | using ExternalFileVector = std::vector<ExternalFile>; | ||
| 109 | |||
| 110 | } // namespace model | ||
| 111 | } // namespace openstudio | ||
| 112 | |||
| 113 | #endif // MODEL_EXTERNALFILE_HPP | ||
| 114 |