Feature/codegen (#1480)

* Add the ability to automatically generate code to extract values out of a Dictionary (see https://github.com/openspace/codegen for more information on how to use this)
* Applied this technique to a large number of cases in the codebase
* Don't add _codegen files to the repository

Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
Alexander Bock
2021-02-09 09:12:43 +01:00
committed by GitHub
parent 78c0b23194
commit 6d821d4f91
104 changed files with 2939 additions and 4769 deletions

View File

@@ -41,24 +41,20 @@ namespace {
"this value is changed, the image at the new path will automatically be loaded "
"and displayed."
};
struct [[codegen::Dictionary(RenderablePlaneImageOnline)]] Parameters {
// [[codegen::verbatim(TextureInfo.description)]]
std::string url [[codegen::key("URL")]];
};
#include "renderableplaneimageonline_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderablePlaneImageOnline::Documentation() {
using namespace documentation;
return {
"Renderable Plane Image Online",
"base_renderable_plane_image_online",
{
{
TextureInfo.identifier,
new StringVerifier,
Optional::No,
TextureInfo.description,
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_plane_image_online";
return doc;
}
RenderablePlaneImageOnline::RenderablePlaneImageOnline(
@@ -66,20 +62,12 @@ RenderablePlaneImageOnline::RenderablePlaneImageOnline(
: RenderablePlane(dictionary)
, _texturePath(TextureInfo)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderablePlaneImageOnline"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
_texturePath.onChange([this]() { _textureIsDirty = true; });
addProperty(_texturePath);
std::string texturePath;
if (dictionary.hasKey(TextureInfo.identifier)) {
_texturePath = dictionary.value<std::string>(TextureInfo.identifier);
}
_texturePath = p.url;
addProperty(_texturePath);
}