From ed980bb5d8bd25b8d9bff009a18080c6529a2056 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 17 Mar 2021 00:18:53 +0100 Subject: [PATCH 1/2] Add support for passing shared pointers into the OrVerifier --- include/openspace/documentation/verifier.h | 10 +++++++++- src/documentation/verifier.cpp | 13 ++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/openspace/documentation/verifier.h b/include/openspace/documentation/verifier.h index 0126a804f7..47f61427b2 100644 --- a/include/openspace/documentation/verifier.h +++ b/include/openspace/documentation/verifier.h @@ -29,6 +29,7 @@ #include #include #include +#include namespace openspace::documentation { @@ -994,8 +995,15 @@ struct OrVerifier : public Verifier { * \param values The list of Verifiers that are to be tested * * \pre values must contain at least two values + * + * \todo: The use of the variant to use both raw pointers and shared pointers is + * definitely undesired. At the momement we are not handling the ownership of + * the verifiers very well and this must be cleaned up when doing a pass over + * the entire ownership model of the documentation/verifiers. For now it was + * necessary to make the codegen work in all cases without complications there */ - OrVerifier(const std::vector values); + OrVerifier(const std::vector>> values); /** * Checks whether the \p dictionary contains the \p key and whether this key passes diff --git a/src/documentation/verifier.cpp b/src/documentation/verifier.cpp index ed326b1910..9de0012f2c 100644 --- a/src/documentation/verifier.cpp +++ b/src/documentation/verifier.cpp @@ -584,10 +584,17 @@ std::string AndVerifier::documentation() const { return ghoul::join(documentations, ", "); } -OrVerifier::OrVerifier(const std::vector values_) { +OrVerifier::OrVerifier( + const std::vector>> values_) +{ ghoul_assert(!values_.empty(), "values must not be empty"); - for (Verifier* v : values_) { - this->values.push_back(std::shared_ptr(v)); + for (const std::variant>& v : values_) { + if (std::holds_alternative(v)) { + this->values.push_back(std::shared_ptr(std::get(v))); + } + else { + this->values.push_back(std::get>(v)); + } } } From 07389bd6bf18fc0386a91281f68972dcc13fd34f Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 17 Mar 2021 00:21:00 +0100 Subject: [PATCH 2/2] Update codegen repository --- support/coding/codegen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/coding/codegen b/support/coding/codegen index 1ca72c0202..1251be9728 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit 1ca72c0202e3bd4b61510f84797db131591c8ca3 +Subproject commit 1251be972816ef313dfb0f6f8ede7c3d7abc3bc1