MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / PythonPluginInstance

Method PythonPluginInstance

src/model/PythonPluginInstance.cpp:151–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149 } // namespace detail
150
151 PythonPluginInstance::PythonPluginInstance(const ExternalFile& externalfile, const std::string& pluginClassName)
152 : ResourceObject(PythonPluginInstance::iddObjectType(), externalfile.model()) {
153 OS_ASSERT(getImpl<detail::PythonPluginInstance_Impl>());
154
155 auto filePath = externalfile.filePath();
156 bool ok = (toString(filePath.extension()) == ".py");
157 if (!ok) {
158 remove();
159 LOG_AND_THROW("External file must have a .py extension, got externalfile='" << filePath << "'.");
160 }
161
162 ok = setPointer(OS_PythonPlugin_InstanceFields::ExternalFileName, externalfile.handle());
163 OS_ASSERT(ok);
164
165 // This must occur after setPointer externalfile
166 ok = setPluginClassName(pluginClassName);
167 if (!ok) {
168 remove();
169 LOG_AND_THROW("Cannot find the Plugin Class Name '" << pluginClassName << "' in external file '" << filePath << "'.");
170 }
171 }
172
173 IddObjectType PythonPluginInstance::iddObjectType() {
174 return {IddObjectType::OS_PythonPlugin_Instance};

Callers 1

runMethod · 0.80

Calls 6

filePathMethod · 0.80
extensionMethod · 0.80
iddObjectTypeFunction · 0.70
toStringFunction · 0.50
modelMethod · 0.45
handleMethod · 0.45

Tested by

no test coverage detected