diff --git a/ext/ghoul b/ext/ghoul index e03f640bee..fbd80eae0f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit e03f640bee6200bf38bf9cb37b5e6b155edcf497 +Subproject commit fbd80eae0ff589a9fa2fb5e2c8af8e4491fe4e2d diff --git a/include/openspace/documentation/documentation.h b/include/openspace/documentation/documentation.h index 15ec83ce52..c8c7385613 100644 --- a/include/openspace/documentation/documentation.h +++ b/include/openspace/documentation/documentation.h @@ -36,6 +36,8 @@ namespace ghoul { class Dictionary; } namespace openspace::documentation { +class Verifier; + BooleanType(Optional); /** @@ -52,9 +54,7 @@ struct TestResult { * offense. */ struct Offense { - /** - * The Reason for the offense - */ + /// The Reason for the offense enum class Reason { Unknown, ///< Unknown reason MissingKey, ///< The offending key that was requested was not found @@ -78,9 +78,7 @@ struct TestResult { * might be removed in a latter version. */ struct Warning { - /** - * The reason for the warning - */ + /// The reason for the warning enum class Reason { Deprecated ///< The value is marked as deprecated and should not used }; @@ -124,8 +122,6 @@ struct SpecificationError : public ghoul::RuntimeError { void logError(const SpecificationError& error, std::string component = ""); -struct Verifier; - /** * A DocumentationEntry provides the specification for a single key, which is tested using * the provided Verifier. Each DocumentationEntry can contain a textual documentation that @@ -172,28 +168,28 @@ struct DocumentationEntry { Optional opt, std::string doc = ""); /** - * The constructor for a DocumentationEntry describing a key \p k in a Documentation. - * The value for the key (or each value in the case of the - * DocumentationEntry::Wildcard) is tested using the verifier \p v, that specifies the - * conditions that the \p k%'s value has to fulfill. The textual documentation - * \p doc shall describe the usage of the key-value pair and will be printed for human - * consumption for example in the DocumentationEngine. Each DocumentationEntry can - * further be \p opt. - * - * \param k The key for which this DocumentationEntry is valid. If this valid is - * equal to DocumentationEntry::Wildcard, each entry in the Documentation that - * contains this DocumentationEntry will be matched - * \param v The Verifier that is used to test the \p key%'s value to determine if it is - * a valid value. The DocumentationEntry will take ownership of the passed - * object - * \param doc The textual documentation that describes the DocumentationEntry in a - * human readable format - * \param opt Determines whether the Documentation containing this DocumentationEntry - * must have a key \p key, or whether it is optional - * - * \pre \p k must not be empty - * \pre \p v must not be nullptr - */ + * The constructor for a DocumentationEntry describing a key \p k in a Documentation. + * The value for the key (or each value in the case of the + * DocumentationEntry::Wildcard) is tested using the verifier \p v, that specifies the + * conditions that the \p k%'s value has to fulfill. The textual documentation + * \p doc shall describe the usage of the key-value pair and will be printed for human + * consumption for example in the DocumentationEngine. Each DocumentationEntry can + * further be \p opt. + * + * \param k The key for which this DocumentationEntry is valid. If this valid is + * equal to DocumentationEntry::Wildcard, each entry in the Documentation that + * contains this DocumentationEntry will be matched + * \param v The Verifier that is used to test the \p key%'s value to determine if it + * is a valid value. The DocumentationEntry will take ownership of the passed + * object + * \param doc The textual documentation that describes the DocumentationEntry in a + * human readable format + * \param opt Determines whether the Documentation containing this DocumentationEntry + * must have a key \p key, or whether it is optional + * + * \pre \p k must not be empty + * \pre \p v must not be nullptr + */ DocumentationEntry(std::string k, Verifier* v, Optional opt, std::string doc = ""); @@ -232,43 +228,14 @@ Documentation doc = { * both the wildcard and the specialized entry will be evaluated. */ struct Documentation { - using DocumentationEntries = std::vector; - - /** - * Creates a Documentation with a human-readable name \p n and a list of entries - * \p ents. - * - * \param n The human-readable name of this Documentation - * \param i A unique identifier which can be used by applications (or other - * Documentation%s to reference this entry - * \param ents A list of DocumentationEntry%s that describe the individual keys for - * this entrie Documentation - */ - Documentation(std::string n, std::string i, DocumentationEntries ents = {}); - - /** - * Creates a Documentation with a human-readable name \p n. - * - * \param n The human-readable name of this Documentation - * \param ents A list of DocumentationEntry%s that describe the individual keys for - * this entrie Documentation - */ - Documentation(std::string n, DocumentationEntries ents = {}); - - /** - * Creates a Documentation. - * - * \param entries A list of DocumentationEntry%s that describe the individual keys for - * this entrie Documentation - */ - Documentation(DocumentationEntries ents = {}); - /// The human-readable name of the Documentation std::string name; /// A unique identifier which can be used to reference this Documentation std::string id; + /// A general description for the entire documented entity + std::string description; /// A list of specifications that are describing this Documentation - DocumentationEntries entries; + std::vector entries; }; /** @@ -287,20 +254,21 @@ TestResult testSpecification(const Documentation& documentation, const ghoul::Dictionary& dictionary); /** -* This method tests whether a provided ghoul::Dictionary \p dictionary adheres to the -* specification \p documentation. If the \p dictionary does not adhere to the -* specification a SpecificationError is thrown, and the exception contains the TestResult -* that contains more information about the offending keys. If the \p dictionary adheres to -* the \p documentation, the method returns normally. -* -* \param documentation The Documentation that the \p dictionary is tested against -* \param dictionary The ghoul::Dictionary that is to be tested against the -* \p documentation -* \param component The component that is using this method; this argument is passed to the -* SpecificationError that is thrown in case of not adhering to the \p documentation -* -* \throw SpecificationError If the \p dictionary does not adhere to the \p documentation -*/ + * This method tests whether a provided ghoul::Dictionary \p dictionary adheres to the + * specification \p documentation. If the \p dictionary does not adhere to the + * specification a SpecificationError is thrown, and the exception contains the TestResult + * that contains more information about the offending keys. If the \p dictionary adheres + * to the \p documentation, the method returns normally. + * + * \param documentation The Documentation that the \p dictionary is tested against + * \param dictionary The ghoul::Dictionary that is to be tested against the + * \p documentation + * \param component The component that is using this method; this argument is passed to + * the SpecificationError that is thrown in case of not adhering to the + * \p documentation + * + * \throw SpecificationError If the \p dictionary does not adhere to the \p documentation + */ void testSpecificationAndThrow(const Documentation& documentation, const ghoul::Dictionary& dictionary, std::string component); diff --git a/include/openspace/documentation/verifier.h b/include/openspace/documentation/verifier.h index dd263a6ea5..6bc3d302f9 100644 --- a/include/openspace/documentation/verifier.h +++ b/include/openspace/documentation/verifier.h @@ -41,7 +41,8 @@ namespace openspace::documentation { * Verifier. Furthermore, the Verifier::documentation method returns a human-readable * description of the Verifier subclass and what it tests for. */ -struct Verifier { +class Verifier { +public: virtual ~Verifier() = default; /** @@ -100,7 +101,8 @@ struct Verifier { * \tparam T The type against which the key's value is tested */ template -struct TemplateVerifier : public Verifier { +class TemplateVerifier : public Verifier { +public: using Type = T; /** @@ -126,7 +128,8 @@ struct TemplateVerifier : public Verifier { * A Verifier that checks whether a given key inside a ghoul::Dictionary is of type * `bool`. No implicit conversion is considered in this testing. */ -struct BoolVerifier : public TemplateVerifier { +class BoolVerifier : public TemplateVerifier { +public: std::string type() const override; }; @@ -134,7 +137,8 @@ struct BoolVerifier : public TemplateVerifier { * A Verifier that checks whether a given key inside a ghoul::Dictionary is of type * `double`. No implicit conversion is considered in this testing. */ -struct DoubleVerifier : public TemplateVerifier { +class DoubleVerifier : public TemplateVerifier { +public: std::string type() const override; }; @@ -143,7 +147,8 @@ struct DoubleVerifier : public TemplateVerifier { * `int`. It will also return `true` if the key's value is of type `double`, but is a * integer value (for example, `0.0`, `12.0`, but not `0.5`). */ -struct IntVerifier : public TemplateVerifier { +class IntVerifier : public TemplateVerifier { +public: TestResult operator()(const ghoul::Dictionary& dict, const std::string& key) const override; @@ -154,7 +159,8 @@ struct IntVerifier : public TemplateVerifier { * A Verifier that checks whether a given key inside a ghoul::Dictionary is of type * `std::string`. No implicit conversion is considered in this testing. */ -struct StringVerifier : public TemplateVerifier { +class StringVerifier : public TemplateVerifier { +public: StringVerifier(bool mustBeNotEmpty = false); TestResult operator()(const ghoul::Dictionary& dictionary, @@ -172,7 +178,8 @@ private: * A Verifier that checks whether a given string is a valid identifier, meaning that is * does not contain any whitespaces or dots */ -struct IdentifierVerifier : public StringVerifier { +class IdentifierVerifier : public StringVerifier { +public: IdentifierVerifier(); TestResult operator()(const ghoul::Dictionary& dict, @@ -187,7 +194,8 @@ struct IdentifierVerifier : public StringVerifier { * A Verifier that checks whether a given key inside a ghoul::Dictionary is a string and * refers to an existing file on disk. */ -struct FileVerifier : public StringVerifier { +class FileVerifier : public StringVerifier { +public: FileVerifier(); TestResult operator()(const ghoul::Dictionary& dict, @@ -197,10 +205,11 @@ struct FileVerifier : public StringVerifier { }; /** -* A Verifier that checks whether a given key inside a ghoul::Dictionary is a string and -* refers to an existing directory on disk. -*/ -struct DirectoryVerifier : public StringVerifier { + * A Verifier that checks whether a given key inside a ghoul::Dictionary is a string and + * refers to an existing directory on disk. + */ +class DirectoryVerifier : public StringVerifier { +public: DirectoryVerifier(); TestResult operator()(const ghoul::Dictionary& dict, @@ -213,7 +222,8 @@ struct DirectoryVerifier : public StringVerifier { * A Verifier that checks whether a given key inside a ghoul::Dictionary is a string and * a valid date time */ -struct DateTimeVerifier : public StringVerifier { +class DateTimeVerifier : public StringVerifier { +public: DateTimeVerifier(); TestResult operator()(const ghoul::Dictionary& dict, @@ -232,7 +242,8 @@ struct DateTimeVerifier : public StringVerifier { * DocumentationEntry checks for a nested key `a` and this does not comply, this Verifier * will return `Table.a` as an offender. */ -struct TableVerifier : public TemplateVerifier { +class TableVerifier : public TemplateVerifier { +public: /** * This constructor takes a list of DocumentationEntry%s that are used recursively to * check the table (= ghoul::Dictionary) contained in the key's value. Similar to the @@ -270,7 +281,8 @@ struct TableVerifier : public TemplateVerifier { /** * A Verifier that checks whether all values contained in a Table are of type `string`. */ -struct StringListVerifier : public TableVerifier { +class StringListVerifier : public TableVerifier { +public: /** * Constructor for a StringListVerifier. * @@ -284,7 +296,8 @@ struct StringListVerifier : public TableVerifier { /** * A Verifier that checks whether all values contained in a Table are of type `int`. */ -struct IntListVerifier : public TableVerifier { +class IntListVerifier : public TableVerifier { +public: /** * Constructor for a IntListVerifier. * @@ -299,40 +312,37 @@ struct IntListVerifier : public TableVerifier { // Vector verifiers //---------------------------------------------------------------------------------------- -/** - * This struct is the base class for all Verifier%s that check for `glm` vector types. - * The template parameter for the subclasses is the containing type, not the full vector - * type. For example to check for `glm::dvec3`, one would create a - * `Vector3Verifier`. - */ -struct VectorVerifier {}; - /// This Verifier checks whether the value is of type `glm::tvec2` template -struct Vector2Verifier : public TemplateVerifier>, public VectorVerifier { +class Vector2Verifier : public TemplateVerifier> { +public: std::string type() const override; }; /// This Verifier checks whether the value is of type `glm::tvec3` template -struct Vector3Verifier : public TemplateVerifier>, public VectorVerifier { +class Vector3Verifier : public TemplateVerifier> { +public: std::string type() const override; }; /// This Verifier checks whether the value is of type `glm::tvec4` template -struct Vector4Verifier : public TemplateVerifier>, public VectorVerifier { +class Vector4Verifier : public TemplateVerifier> { +public: std::string type() const override; }; -struct Color3Verifier : public Vector3Verifier { +class Color3Verifier : public Vector3Verifier { +public: TestResult operator()(const ghoul::Dictionary& dictionary, const std::string& key) const override; std::string type() const override; }; -struct Color4Verifier : public Vector4Verifier { +class Color4Verifier : public Vector4Verifier { +public: TestResult operator()(const ghoul::Dictionary& dictionary, const std::string& key) const override; @@ -344,7 +354,8 @@ struct Color4Verifier : public Vector4Verifier { * type `glm::tvec2` */ template -struct Vector2ListVerifier : public TableVerifier { +class Vector2ListVerifier : public TableVerifier { +public: Vector2ListVerifier(std::string elementDocumentation = "") : TableVerifier({ { "*", new Vector2Verifier, Optional::No, std::move(elementDocumentation) } @@ -361,7 +372,8 @@ struct Vector2ListVerifier : public TableVerifier { * type `glm::tvec3` */ template -struct Vector3ListVerifier : public TableVerifier { +class Vector3ListVerifier : public TableVerifier { +public: Vector3ListVerifier(std::string elementDocumentation = "") : TableVerifier({ { "*", new Vector3Verifier, Optional::No, std::move(elementDocumentation) } @@ -378,7 +390,8 @@ struct Vector3ListVerifier : public TableVerifier { * type `glm::tvec4` */ template -struct Vector4ListVerifier : public TableVerifier { +class Vector4ListVerifier : public TableVerifier { +public: Vector4ListVerifier(std::string elementDocumentation = "") : TableVerifier({ { "*", new Vector4Verifier, Optional::No, std::move(elementDocumentation) } @@ -394,20 +407,12 @@ struct Vector4ListVerifier : public TableVerifier { // Matrix verifiers //---------------------------------------------------------------------------------------- -/** - * This struct is the base class for all Verifier%s that check for `glm` matrix types. - * The template parameter for the subclasses is the containing type, not the full matrix - * type. For example to check for `glm::dmat4x3`, one would create a - * `Matrix4x3Verifier`. - */ -struct MatrixVerifier {}; - /** * This Verifier checks whether the value is of type `glm::mat2x2` */ template -struct Matrix2x2Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix2x2Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -415,8 +420,8 @@ struct Matrix2x2Verifier : public TemplateVerifier>, public Matr * This Verifier checks whether the value is of type `glm::mat2x3` */ template -struct Matrix2x3Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix2x3Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -424,8 +429,8 @@ struct Matrix2x3Verifier : public TemplateVerifier>, public Matr * This Verifier checks whether the value is of type `glm::mat2x4` */ template -struct Matrix2x4Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix2x4Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -433,8 +438,8 @@ struct Matrix2x4Verifier : public TemplateVerifier>, public Matr * This Verifier checks whether the value is of type `glm::mat3x2` */ template -struct Matrix3x2Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix3x2Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -442,8 +447,8 @@ struct Matrix3x2Verifier : public TemplateVerifier>, public Matr * This Verifier checks whether the value is of type `glm::mat3x3` */ template -struct Matrix3x3Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix3x3Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -451,8 +456,8 @@ struct Matrix3x3Verifier : public TemplateVerifier>, public Matr * This Verifier checks whether the value is of type `glm::mat3x4` */ template -struct Matrix3x4Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix3x4Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -460,8 +465,8 @@ struct Matrix3x4Verifier : public TemplateVerifier>, public Matr * This Verifier checks whether the value is of type `glm::mat4x2` */ template -struct Matrix4x2Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix4x2Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -469,8 +474,8 @@ struct Matrix4x2Verifier : public TemplateVerifier>, public Matr * This Verifier checks whether the value is of type `glm::mat4x3` */ template -struct Matrix4x3Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix4x3Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -478,8 +483,8 @@ struct Matrix4x3Verifier : public TemplateVerifier>, public Matr * This Verifier checks whether the value is of type `glm::mat4x4` */ template -struct Matrix4x4Verifier : public TemplateVerifier>, public MatrixVerifier -{ +class Matrix4x4Verifier : public TemplateVerifier> { +public: std::string type() const override; }; @@ -503,7 +508,8 @@ struct Matrix4x4Verifier : public TemplateVerifier>, public Matr * reason TestResult::Offense::Verification is returned instead. */ template -struct OperatorVerifier : public T { +class OperatorVerifier : public T { +public: /** * Constructor for an OperatorVerifier. As all operators need to compare the incoming * value to a stored value, we require the comparison \p value to be passed in here. @@ -539,18 +545,17 @@ struct OperatorVerifier : public T { * as) BoolVerifier, StringVerifier, TableVerifier, or VectorVerifier. */ template -struct LessVerifier : public OperatorVerifier> { - static_assert(!std::is_base_of::value, "T cannot be BoolVerifier"); - static_assert( - !std::is_base_of::value, "T cannot be StringVerifier" - ); - static_assert(!std::is_base_of::value, "T cannot be TableVerifier"); - +class LessVerifier : public OperatorVerifier> { +public: using OperatorVerifier>::OperatorVerifier; + using OperatorVerifier>::value; std::string documentation() const override; - using OperatorVerifier>::value; +private: + static_assert(!std::is_base_of_v, "T cannot be BoolVerifier"); + static_assert(!std::is_base_of_v, "T cannot be StringVerifier"); + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; /** @@ -559,19 +564,17 @@ struct LessVerifier : public OperatorVerifier> { * as) BoolVerifier, StringVerifier, TableVerifier, or VectorVerifier. */ template -struct LessEqualVerifier : public OperatorVerifier> { - static_assert(!std::is_base_of::value, "T cannot be BoolVerifier"); - static_assert( - !std::is_base_of::value, - "T cannot be StringVerifier" - ); - static_assert(!std::is_base_of::value, "T cannot be TableVerifier"); - +class LessEqualVerifier : public OperatorVerifier> { +public: using OperatorVerifier>::OperatorVerifier; + using OperatorVerifier>::value; std::string documentation() const override; - using OperatorVerifier>::value; +private: + static_assert(!std::is_base_of_v, "T cannot be BoolVerifier"); + static_assert(!std::is_base_of_v, "T cannot be StringVerifier"); + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; /** @@ -580,19 +583,17 @@ struct LessEqualVerifier : public OperatorVerifier -struct GreaterVerifier : public OperatorVerifier> { - static_assert(!std::is_base_of::value, "T cannot be BoolVerifier"); - static_assert( - !std::is_base_of::value, - "T cannot be StringVerifier" - ); - static_assert(!std::is_base_of::value, "T cannot be TableVerifier"); - +class GreaterVerifier : public OperatorVerifier> { +public: using OperatorVerifier>::OperatorVerifier; + using OperatorVerifier>::value; std::string documentation() const override; - using OperatorVerifier>::value; +private: + static_assert(!std::is_base_of_v, "T cannot be BoolVerifier"); + static_assert(!std::is_base_of_v, "T cannot be StringVerifier"); + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; /** @@ -601,21 +602,19 @@ struct GreaterVerifier : public OperatorVerifier -struct GreaterEqualVerifier : public OperatorVerifier> { - static_assert(!std::is_base_of::value, "T cannot be BoolVerifier"); - static_assert( - !std::is_base_of::value, - "T cannot be StringVerifier" - ); - static_assert(!std::is_base_of::value, "T cannot be TableVerifier"); - +public: using OperatorVerifier>::OperatorVerifier; + using OperatorVerifier>::value; std::string documentation() const override; - using OperatorVerifier>::value; +private: + static_assert(!std::is_base_of_v, "T cannot be BoolVerifier"); + static_assert(!std::is_base_of_v, "T cannot be StringVerifier"); + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; /** @@ -624,14 +623,15 @@ struct GreaterEqualVerifier : public OperatorVerifier -struct EqualVerifier : public OperatorVerifier> { - static_assert(!std::is_base_of::value, "T cannot be TableVerifier"); - +class EqualVerifier : public OperatorVerifier> { +public: using OperatorVerifier>::OperatorVerifier; + using OperatorVerifier>::value; std::string documentation() const override; - using OperatorVerifier>::value; +private: + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; /** @@ -640,14 +640,15 @@ struct EqualVerifier : public OperatorVerifier -struct UnequalVerifier : public OperatorVerifier> { - static_assert(!std::is_base_of::value, "T cannot be TableVerifier"); - +class UnequalVerifier : public OperatorVerifier> { +public: using OperatorVerifier>::OperatorVerifier; + using OperatorVerifier>::value; std::string documentation() const override; - using OperatorVerifier>::value; +private: + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; //---------------------------------------------------------------------------------------- @@ -661,9 +662,8 @@ struct UnequalVerifier : public OperatorVerifier -struct InListVerifier : public T { - static_assert(!std::is_base_of::value, "T cannot be TableVerifier"); - +class InListVerifier : public T { +public: /** * Constructs an InListVerifier that checks whether the incoming value is of the * correct type and whether the value is part of the list passed as \p values. @@ -692,6 +692,9 @@ struct InListVerifier : public T { /// The list of values against which the incoming value is tested std::vector values; + +private: + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; /** @@ -701,9 +704,8 @@ struct InListVerifier : public T { * be a subclass of (or the same as) TableVerifier. */ template -struct NotInListVerifier : public T { - static_assert(!std::is_base_of::value, "T cannot be TableVerifier"); - +class NotInListVerifier : public T { +public: /** * Constructs a NotInListVerifier that checks whether the incoming value is of the * correct type and whether the value is not part of the list passed as \p values. @@ -731,6 +733,9 @@ struct NotInListVerifier : public T { std::string documentation() const override; std::vector values; + +private: + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; //---------------------------------------------------------------------------------------- @@ -745,20 +750,8 @@ struct NotInListVerifier : public T { * TableVerifier, or VectorVerifier. Both the lower and the higher limit are inclusive). */ template -struct InRangeVerifier : public T { - static_assert( - !std::is_base_of::value, - "T cannot be BoolVerifier" - ); - static_assert( - !std::is_base_of::value, - "T cannot be StringVerifier" - ); - static_assert( - !std::is_base_of::value, - "T cannot be TableVerifier" - ); - +class InRangeVerifier : public T { +public: /** * Constructs a InRangeVerifier that checks whether the incoming value is of the * correct type and whether the value is greater or equal to \p lower and less or @@ -793,6 +786,11 @@ struct InRangeVerifier : public T { typename T::Type lower; typename T::Type upper; + +private: + static_assert(!std::is_base_of_v, "T cannot be BoolVerifier"); + static_assert(!std::is_base_of_v, "T cannot be StringVerifier"); + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; /** @@ -803,20 +801,8 @@ struct InRangeVerifier : public T { * TableVerifier, or VectorVerifier. Both the lower and the higher limit are exclusive). */ template -struct NotInRangeVerifier : public T { - static_assert( - !std::is_base_of::value, - "T cannot be BoolVerifier" - ); - static_assert( - !std::is_base_of::value, - "T cannot be StringVerifier" - ); - static_assert( - !std::is_base_of::value, - "T cannot be TableVerifier" - ); - +class NotInRangeVerifier : public T { +public: /** * Constructs a InRangeVerifier that checks whether the incoming value is of the * correct type and whether the value is less then \p lower and greater than \p upper. @@ -850,6 +836,11 @@ struct NotInRangeVerifier : public T { typename T::Type lower; typename T::Type upper; + +private: + static_assert(!std::is_base_of_v, "T cannot be BoolVerifier"); + static_assert(!std::is_base_of_v, "T cannot be StringVerifier"); + static_assert(!std::is_base_of_v, "T cannot be TableVerifier"); }; @@ -865,7 +856,8 @@ struct NotInRangeVerifier : public T { * the user that the parameter should be a file of a specific type. */ template -struct AnnotationVerifier : public T { +class AnnotationVerifier : public T { +public: /** * Constructs an AnnotationVerifier that contains the passed \p annotation which is * passed to the user when a documentation is requested. @@ -883,34 +875,6 @@ struct AnnotationVerifier : public T { std::string annotation; }; -/** - * This Verifier is a marker that performs the same testing as the `T` parameter, but - * also adds a warning to the test result informing the user of the deprecation. - * Furthermore, the documentation will contain the word `(deprecated)` in - * addition to the documentation returned by `T` - * \tparam T The Verifier that is to be marked deprecated - */ -template -struct DeprecatedVerifier : public T { - /** - * Tests the \p dictionary%s \p key using the Verifier `T` and adds a warning to the - * TestResult informing the caller of the deprecation. - * - * \param dictionary The ghoul::Dictionary whose \p key should be tested - * \param key The key inside the \p dictionary that is to be tested - * \return A TestResult that contains the results of the testing - */ - TestResult operator()(const ghoul::Dictionary& dictionary, - const std::string& key) const override; - - /** - * Returns the documentation as reported by `T` and adds the word - * `(deprecated)` to it. - * \return The deprecated version of `T`%'s documentation - */ - std::string documentation() const override; -}; - /** * This Verifier can reference and apply other Documentation%s that have been registered * with a DocumentationEngine. The dependency is only resolved when the operator() is @@ -919,7 +883,8 @@ struct DeprecatedVerifier : public T { * If the referenced Documentation exists, the stored Table will be checked against that * Documentation. */ -struct ReferencingVerifier : public TableVerifier { +class ReferencingVerifier : public TableVerifier { +public: /** * Creates a ReferencingVerifier that references a documentation with the provided * identifier \p identifier. The ReferencingVerifier will use the static @@ -958,54 +923,14 @@ struct ReferencingVerifier : public TableVerifier { // Misc verifiers //---------------------------------------------------------------------------------------- -/** - * This Verifier takes two Verifiers and performs a boolean `and` operation on their - * results. In essence, a value only passes this Verifier if it passes both Verifier%s - * that are passed in the constructor. Opposed to the `C++` `&&` - * operator, the AndVerifier does not perform any short-circut evaluation. - */ -struct AndVerifier : public Verifier { - /** - * Constructs an AndVerifier with Verifiers that must be cleared by incoming values in - * order to pass this Verifier. - * - * \param values The list of Verifiers that are to be tested - * - * \pre values must contain at least two values - */ - AndVerifier(const std::vector values); - - /** - * Checks whether the \p dictionary contains the \p key and whether this key passes - * all Verifier%s that were passed in the constructor. If the value fails at least - * one Verifiers, it is only added once to the TestResult::offenses list with a reason - * of TestResult::Offense::Reason::Verification. - * - * \param dictionary The ghoul::Dictionary that is to be tested - * \param key The key contained in \p dictionary that is to be tested - * \return A TestResult object that contains the test results. If the value fails - * any passed Verifiers, TestResult::success is `false` and the - * TestResult::offenses list contains \p with a reason of - * TestResult::Offense::Reason::Verification. If \p key%'s value passes both - * Verifier%s, the result's TestResult::success is `true` and the - * TestResult::offenses is empty. - */ - TestResult operator()(const ghoul::Dictionary& dictionary, - const std::string& key) const override; - - std::string type() const override; - std::string documentation() const override; - - std::vector> values; -}; - /** * This Verifier takes two Verifiers and performs a boolean `or` operation on their * results. In essence, a value only passes this Verifier if it passes either of the two * Verifier%s that are passed in the constructor. Opposed to the `C++` `||` operator, the * OrVerifier does not perform any short-circut evaluation. */ -struct OrVerifier : public Verifier { +class OrVerifier : public Verifier { +public: /** * Constructs an OrVerifier with Verifiers that must be cleared by incoming values in * order to pass this Verifier. @@ -1161,92 +1086,68 @@ using StringAnnotationVerifier = AnnotationVerifier; /// `ghoul::Dictionary` using TableAnnotationVerifier = AnnotationVerifier; -/// A short-hand definition for a DeprecatedVerifier with a type check for `bool` -using BoolDeprecatedVerifier = DeprecatedVerifier; -/// A short-hand definition for a DeprecatedVerifier with a type check for `int` -using IntDeprecatedVerifier = DeprecatedVerifier; -/// A short-hand definition for a DeprecatedVerifier with a type check for `double` -using DoubleDeprecatedVerifier = DeprecatedVerifier; -/// A short-hand definition for a DeprecatedVerifier with a type check for `string` -using StringDeprecatedVerifier = DeprecatedVerifier; -/// A short-hand definition for a DeprecatedVerifier with a type check for -/// `ghoul::Dictionary` -using TableDeprecatedVerifier = DeprecatedVerifier; - // Definitions of external templates that are instantiated in the cpp file // This cuts down the compilation times as almost all of the possible template types do // not need to be instantiated multiple times -extern template struct Vector2Verifier; -extern template struct Vector2Verifier; -extern template struct Vector3Verifier; -extern template struct Vector3Verifier; -extern template struct Vector4Verifier; -extern template struct Vector4Verifier; +extern template class Vector2Verifier; +extern template class Vector2Verifier; +extern template class Vector3Verifier; +extern template class Vector3Verifier; +extern template class Vector4Verifier; +extern template class Vector4Verifier; -extern template struct Matrix2x2Verifier; -extern template struct Matrix2x3Verifier; -extern template struct Matrix2x4Verifier; -extern template struct Matrix3x2Verifier; -extern template struct Matrix3x3Verifier; -extern template struct Matrix3x4Verifier; -extern template struct Matrix4x2Verifier; -extern template struct Matrix4x3Verifier; -extern template struct Matrix4x4Verifier; +extern template class Matrix2x2Verifier; +extern template class Matrix2x3Verifier; +extern template class Matrix2x4Verifier; +extern template class Matrix3x2Verifier; +extern template class Matrix3x3Verifier; +extern template class Matrix3x4Verifier; +extern template class Matrix4x2Verifier; +extern template class Matrix4x3Verifier; +extern template class Matrix4x4Verifier; -extern template struct LessVerifier; -extern template struct LessVerifier; -extern template struct LessEqualVerifier; -extern template struct LessEqualVerifier; -extern template struct GreaterVerifier; -extern template struct GreaterVerifier; -extern template struct GreaterEqualVerifier; -extern template struct GreaterEqualVerifier; -extern template struct EqualVerifier; -extern template struct EqualVerifier; -extern template struct EqualVerifier; -extern template struct EqualVerifier; -extern template struct UnequalVerifier; -extern template struct UnequalVerifier; -extern template struct UnequalVerifier; -extern template struct UnequalVerifier; +extern template class LessVerifier; +extern template class LessVerifier; +extern template class LessEqualVerifier; +extern template class LessEqualVerifier; +extern template class GreaterVerifier; +extern template class GreaterVerifier; +extern template class GreaterEqualVerifier; +extern template class GreaterEqualVerifier; +extern template class EqualVerifier; +extern template class EqualVerifier; +extern template class EqualVerifier; +extern template class EqualVerifier; +extern template class UnequalVerifier; +extern template class UnequalVerifier; +extern template class UnequalVerifier; +extern template class UnequalVerifier; -extern template struct InListVerifier; -extern template struct InListVerifier; -extern template struct InListVerifier; -extern template struct InListVerifier; -extern template struct NotInListVerifier; -extern template struct NotInListVerifier; -extern template struct NotInListVerifier; -extern template struct NotInListVerifier; +extern template class InListVerifier; +extern template class InListVerifier; +extern template class InListVerifier; +extern template class InListVerifier; +extern template class NotInListVerifier; +extern template class NotInListVerifier; +extern template class NotInListVerifier; +extern template class NotInListVerifier; -extern template struct InRangeVerifier; -extern template struct InRangeVerifier; -extern template struct NotInRangeVerifier; -extern template struct NotInRangeVerifier; +extern template class InRangeVerifier; +extern template class InRangeVerifier; +extern template class NotInRangeVerifier; +extern template class NotInRangeVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; -extern template struct AnnotationVerifier; - -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; -extern template struct DeprecatedVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; +extern template class AnnotationVerifier; } // namespace openspace::documentation diff --git a/include/openspace/documentation/verifier.inl b/include/openspace/documentation/verifier.inl index 4fc3cc9671..298ca7f1fd 100644 --- a/include/openspace/documentation/verifier.inl +++ b/include/openspace/documentation/verifier.inl @@ -30,384 +30,6 @@ #include #include -template <> -struct std::less { - bool operator()(const glm::vec2& a, const glm::vec2& b) const { - return a.x < b.x && a.x < b.y; - } -}; - -template <> -struct std::less { - bool operator()(const glm::vec3& a, const glm::vec3& b) const { - return a.x < b.x && a.x < b.y && a.z < b.z; - } -}; - -template <> -struct std::less { - bool operator()(const glm::vec4& a, const glm::vec4& b) const { - return a.x < b.x && a.x < b.y && a.z < b.z && a.w < b.w; - } -}; - -template <> -struct std::less { - bool operator()(const glm::ivec2& a, const glm::ivec2& b) const { - return a.x < b.x && a.x < b.y; - } -}; - -template <> -struct std::less { - bool operator()(const glm::ivec3& a, const glm::ivec3& b) const { - return a.x < b.x && a.x < b.y && a.z < b.z; - } -}; - -template <> -struct std::less { - bool operator()(const glm::ivec4& a, const glm::ivec4& b) const { - return a.x < b.x && a.x < b.y && a.z < b.z && a.w < b.w; - } -}; - -template <> -struct std::less { - bool operator()(const glm::dvec2& a, const glm::dvec2& b) const { - return a.x < b.x && a.x < b.y; - } -}; - -template <> -struct std::less { - bool operator()(const glm::dvec3& a, const glm::dvec3& b) const { - return a.x < b.x && a.x < b.y && a.z < b.z; - } -}; - -template <> -struct std::less { - bool operator()(const glm::dvec4& a, const glm::dvec4& b) const { - return a.x < b.x && a.x < b.y && a.z < b.z && a.w < b.w; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::vec2& a, const glm::vec2& b) const { - return a.x <= b.x && a.x <= b.y; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::vec3& a, const glm::vec3& b) const { - return a.x <= b.x && a.x <= b.y && a.z <= b.z; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::vec4& a, const glm::vec4& b) const { - return a.x <= b.x && a.x <= b.y && a.z <= b.z && a.w <= b.w; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::ivec2& a, const glm::ivec2& b) const { - return a.x <= b.x && a.x <= b.y; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::ivec3& a, const glm::ivec3& b) const { - return a.x <= b.x && a.x <= b.y && a.z <= b.z; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::ivec4& a, const glm::ivec4& b) const { - return a.x <= b.x && a.x <= b.y && a.z <= b.z && a.w <= b.w; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::dvec2& a, const glm::dvec2& b) const { - return a.x <= b.x && a.x <= b.y; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::dvec3& a, const glm::dvec3& b) const { - return a.x <= b.x && a.x <= b.y && a.z <= b.z; - } -}; - -template <> -struct std::less_equal { - bool operator()(const glm::dvec4& a, const glm::dvec4& b) const { - return a.x <= b.x && a.x <= b.y && a.z <= b.z && a.w <= b.w; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::vec2& a, const glm::vec2& b) const { - return a.x > b.x && a.x > b.y; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::vec3& a, const glm::vec3& b) const { - return a.x > b.x && a.x > b.y && a.z > b.z; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::vec4& a, const glm::vec4& b) const { - return a.x > b.x && a.x > b.y && a.z > b.z && a.w > b.w; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::ivec2& a, const glm::ivec2& b) const { - return a.x > b.x && a.x > b.y; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::ivec3& a, const glm::ivec3& b) const { - return a.x > b.x && a.x > b.y && a.z > b.z; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::ivec4& a, const glm::ivec4& b) const { - return a.x > b.x && a.x > b.y && a.z > b.z && a.w > b.w; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::dvec2& a, const glm::dvec2& b) const { - return a.x > b.x && a.x > b.y; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::dvec3& a, const glm::dvec3& b) const { - return a.x > b.x && a.x > b.y && a.z > b.z; - } -}; - -template <> -struct std::greater { - bool operator()(const glm::dvec4& a, const glm::dvec4& b) const { - return a.x > b.x && a.x > b.y && a.z > b.z && a.w > b.w; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::vec2& a, const glm::vec2& b) const { - return a.x >= b.x && a.x >= b.y; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::vec3& a, const glm::vec3& b) const { - return a.x >= b.x && a.x >= b.y && a.z >= b.z; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::vec4& a, const glm::vec4& b) const { - return a.x >= b.x && a.x >= b.y && a.z >= b.z && a.w >= b.w; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::ivec2& a, const glm::ivec2& b) const { - return a.x >= b.x && a.x >= b.y; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::ivec3& a, const glm::ivec3& b) const { - return a.x >= b.x && a.x >= b.y && a.z >= b.z; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::ivec4& a, const glm::ivec4& b) const { - return a.x >= b.x && a.x >= b.y && a.z >= b.z && a.w >= b.w; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::dvec2& a, const glm::dvec2& b) const { - return a.x >= b.x && a.x >= b.y; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::dvec3& a, const glm::dvec3& b) const { - return a.x >= b.x && a.x >= b.y && a.z >= b.z; - } -}; - -template <> -struct std::greater_equal { - bool operator()(const glm::dvec4& a, const glm::dvec4& b) const { - return a.x >= b.x && a.x >= b.y && a.z >= b.z && a.w >= b.w; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::vec2& a, const glm::vec2& b) const { - return a.x == b.x && a.x == b.y; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::vec3& a, const glm::vec3& b) const { - return a.x == b.x && a.x == b.y && a.z == b.z; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::vec4& a, const glm::vec4& b) const { - return a.x == b.x && a.x == b.y && a.z == b.z && a.w == b.w; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::ivec2& a, const glm::ivec2& b) const { - return a.x == b.x && a.x == b.y; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::ivec3& a, const glm::ivec3& b) const { - return a.x == b.x && a.x == b.y && a.z == b.z; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::ivec4& a, const glm::ivec4& b) const { - return a.x == b.x && a.x == b.y && a.z == b.z && a.w == b.w; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::dvec2& a, const glm::dvec2& b) const { - return a.x == b.x && a.x == b.y; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::dvec3& a, const glm::dvec3& b) const { - return a.x == b.x && a.x == b.y && a.z == b.z; - } -}; - -template <> -struct std::equal_to { - bool operator()(const glm::dvec4& a, const glm::dvec4& b) const { - return a.x == b.x && a.x == b.y && a.z == b.z && a.w == b.w; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::vec2& a, const glm::vec2& b) const { - return a.x != b.x && a.x != b.y; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::vec3& a, const glm::vec3& b) const { - return a.x != b.x && a.x != b.y && a.z != b.z; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::vec4& a, const glm::vec4& b) const { - return a.x != b.x && a.x != b.y && a.z != b.z && a.w != b.w; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::ivec2& a, const glm::ivec2& b) const { - return a.x != b.x && a.x != b.y; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::ivec3& a, const glm::ivec3& b) const { - return a.x != b.x && a.x != b.y && a.z != b.z; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::ivec4& a, const glm::ivec4& b) const { - return a.x != b.x && a.x != b.y && a.z != b.z && a.w != b.w; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::dvec2& a, const glm::dvec2& b) const { - return a.x != b.x && a.x != b.y; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::dvec3& a, const glm::dvec3& b) const { - return a.x != b.x && a.x != b.y && a.z != b.z; - } -}; - -template <> -struct std::not_equal_to { - bool operator()(const glm::dvec4& a, const glm::dvec4& b) const { - return a.x != b.x && a.x != b.y && a.z != b.z && a.w != b.w; - } -}; - namespace openspace::documentation { template <> @@ -1073,21 +695,4 @@ std::string AnnotationVerifier::documentation() const { return annotation; } -template -TestResult DeprecatedVerifier::operator()(const ghoul::Dictionary& dict, - const std::string& key) const -{ - TestResult res = T::operator()(dict, key); - TestResult::Warning w; - w.offender = key; - w.reason = TestResult::Warning::Reason::Deprecated; - res.warnings.push_back(w); - return res; -} - -template -std::string DeprecatedVerifier::documentation() const { - return T::documentation() + " (deprecated)"; -} - } // namespace openspace::documentation diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index 12217ef19d..83b1b493c5 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -104,6 +104,9 @@ namespace { openspace::properties::Property::Visibility::User }; + // This DashboardItem shows the angle between two scenegraph nodes relative to a + // reference node. The angle is calculated in the plane that is defined by the + // 'SourceNodeName', 'DestinationNodeName', and the 'ReferenceNodeName'. struct [[codegen::Dictionary(DashboardItemAngle)]] Parameters { enum class [[codegen::map(Type)]] Type { Node, diff --git a/modules/globebrowsing/src/layermanager.cpp b/modules/globebrowsing/src/layermanager.cpp index df3ce27a73..fd56646c63 100644 --- a/modules/globebrowsing/src/layermanager.cpp +++ b/modules/globebrowsing/src/layermanager.cpp @@ -40,6 +40,7 @@ documentation::Documentation LayerManager::Documentation() { return { "LayerManager", "globebrowsing_layermanager", + "", { { "*", diff --git a/modules/server/src/serverinterface.cpp b/modules/server/src/serverinterface.cpp index 88bd9cd3cb..048adb7283 100644 --- a/modules/server/src/serverinterface.cpp +++ b/modules/server/src/serverinterface.cpp @@ -171,9 +171,9 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config) readList(DenyAddressesInfo.identifier, _denyAddresses); readList(RequirePasswordAddressesInfo.identifier, _requirePasswordAddresses); - this->setIdentifier(identifier); - this->setGuiName(identifier); - this->setDescription("Settings for server interface " + identifier); + setIdentifier(identifier); + setGuiName(identifier); + setDescription("Settings for server interface " + identifier); const std::string type = config.value(TypeInfo.identifier); if (type == TcpSocketType) { diff --git a/modules/spout/renderablespherespout.cpp b/modules/spout/renderablespherespout.cpp index 9aaf5cffc2..d68cf9b2ab 100644 --- a/modules/spout/renderablespherespout.cpp +++ b/modules/spout/renderablespherespout.cpp @@ -38,6 +38,7 @@ documentation::Documentation RenderableSphereSpout::Documentation() { return { "Renderable Sphere Spout", "spout_sphere_spout", + "", { { "Name", diff --git a/modules/volume/transferfunctionhandler.cpp b/modules/volume/transferfunctionhandler.cpp index c6968542cb..405a670c77 100644 --- a/modules/volume/transferfunctionhandler.cpp +++ b/modules/volume/transferfunctionhandler.cpp @@ -90,7 +90,7 @@ void TransferFunctionHandler::initialize() { addProperty(_maxValue); addProperty(_saveTransferFunction); - this->addTag("TF"); + addTag("TF"); _texture = std::make_shared( glm::uvec3(1024, 1, 1), GL_TEXTURE_1D, diff --git a/src/documentation/documentation.cpp b/src/documentation/documentation.cpp index 794d00ddfb..9918bb4044 100644 --- a/src/documentation/documentation.cpp +++ b/src/documentation/documentation.cpp @@ -189,20 +189,6 @@ DocumentationEntry::DocumentationEntry(std::string k, Verifier* v, Optional opt, std::move(doc)) {} -Documentation::Documentation(std::string n, std::string i, DocumentationEntries ents) - : name(std::move(n)) - , id(std::move(i)) - , entries(std::move(ents)) -{} - -Documentation::Documentation(std::string n, DocumentationEntries ents) - : Documentation(std::move(n), "", std::move(ents)) -{} - -Documentation::Documentation(DocumentationEntries ents) - : Documentation("", "", std::move(ents)) -{} - TestResult testSpecification(const Documentation& documentation, const ghoul::Dictionary& dictionary) { diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp index 6096c5007d..1a0f2f0c8d 100644 --- a/src/documentation/documentationengine.cpp +++ b/src/documentation/documentationengine.cpp @@ -77,6 +77,7 @@ nlohmann::json generateJsonDocumentation(const Documentation& d) { json["name"] = d.name; json["id"] = d.id; + json["description"] = d.description; json["properties"] = nlohmann::json::array(); for (const DocumentationEntry& p : d.entries) { @@ -110,7 +111,8 @@ nlohmann::json generateJsonDocumentation(const Documentation& d) { } } else if (tv) { - nlohmann::json restrictions = generateJsonDocumentation(tv->documentations); + Documentation doc = { .entries = tv->documentations }; + nlohmann::json restrictions = generateJsonDocumentation(doc); // We have a TableVerifier, so we need to recurse entry["restrictions"] = restrictions; } diff --git a/src/documentation/verifier.cpp b/src/documentation/verifier.cpp index 4c26f3a181..30536b6cdd 100644 --- a/src/documentation/verifier.cpp +++ b/src/documentation/verifier.cpp @@ -119,21 +119,6 @@ template struct AnnotationVerifier; template struct AnnotationVerifier; template struct AnnotationVerifier; -template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -//template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -//template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -//template struct DeprecatedVerifier; -template struct DeprecatedVerifier; -template struct DeprecatedVerifier; - std::string BoolVerifier::type() const { return "Boolean"; } @@ -143,7 +128,7 @@ std::string DoubleVerifier::type() const { } TestResult IntVerifier::operator()(const ghoul::Dictionary& dict, - const std::string & key) const + const std::string& key) const { if (dict.hasValue(key)) { // We have a key and the value is int, we are done @@ -201,8 +186,7 @@ std::string IntVerifier::type() const { } StringVerifier::StringVerifier(bool mustBeNotEmpty) - : TemplateVerifier() - , _mustBeNotEmpty(mustBeNotEmpty) + : _mustBeNotEmpty(mustBeNotEmpty) {} TestResult StringVerifier::operator()(const ghoul::Dictionary& dictionary, @@ -612,16 +596,17 @@ TestResult TableVerifier::operator()(const ghoul::Dictionary& dictionary, { if (dictionary.hasValue(key)) { ghoul::Dictionary d = dictionary.value(key); - TestResult res = testSpecification({documentations}, d); + Documentation doc = { .entries = documentations }; + TestResult res = testSpecification(doc, d); // Add the 'key' as a prefix to make the new offender a fully qualified identifer for (TestResult::Offense& s : res.offenses) { - s.offender = key + "." + s.offender; + s.offender = fmt::format("{}.{}", key, s.offender); } // Add the 'key' as a prefix to make the new warning a fully qualified identifer for (TestResult::Warning& w : res.warnings) { - w.offender = key + "." + w.offender; + w.offender = fmt::format("{}.{}", key, w.offender); } return res; @@ -700,22 +685,17 @@ TestResult ReferencingVerifier::operator()(const ghoul::Dictionary& dictionary, return res; } - //ghoul_assert( - // it != docs.end(), - // "Did not find referencing identifier '" + identifier + "'" - //); - ghoul::Dictionary d = dictionary.value(key); TestResult r = testSpecification(*it, d); // Add the 'key' as a prefix to make the offender a fully qualified identifer for (TestResult::Offense& s : r.offenses) { - s.offender = key + "." + s.offender; + s.offender = fmt::format("{}.{}", key, s.offender); } // Add the 'key' as a prefix to make the warning a fully qualified identifer for (TestResult::Warning& w : r.warnings) { - w.offender = key + "." + w.offender; + w.offender = fmt::format("{}.{}", key, w.offender); } return r; @@ -729,86 +709,16 @@ std::string ReferencingVerifier::documentation() const { return "Referencing Documentation: '" + identifier + "'"; } -AndVerifier::AndVerifier(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)); - } -} - -TestResult AndVerifier::operator()(const ghoul::Dictionary& dictionary, - const std::string& key) const -{ - std::vector res(values.size()); - std::transform( - values.cbegin(), - values.cend(), - res.begin(), - [dictionary, key](const std::shared_ptr& v) { - return v->operator()(dictionary, key); - } - ); - - const bool success = std::all_of( - res.cbegin(), - res.cend(), - std::mem_fn(&TestResult::success) - ); - - if (success) { - TestResult r; - r.success = true; - return r; - } - else { - TestResult r; - r.success = false; - TestResult::Offense o; - o.offender = key; - o.reason = TestResult::Offense::Reason::Verification; - r.offenses.push_back(o); - return r; - } -} - -std::string AndVerifier::type() const { - // Dirty hack to get an "and " inserted before the last element - std::vector types(values.size() - 1); - std::transform( - values.cbegin(), - values.cend() - 1, - types.begin(), - std::mem_fn(&Verifier::type) - ); - types.push_back(std::string("and ") + values.back()->type()); - - return ghoul::join(types, ", "); -} - -std::string AndVerifier::documentation() const { - // Dirty hack to get an "and " inserted before the last element - std::vector documentations(values.size() - 1); - std::transform( - values.cbegin(), - values.cend() - 1, - documentations.begin(), - std::mem_fn(&Verifier::documentation) - ); - documentations.push_back(std::string("and ") + values.back()->documentation()); - - return ghoul::join(documentations, ", "); -} - OrVerifier::OrVerifier( const std::vector>> values_) { ghoul_assert(!values_.empty(), "values must not be empty"); for (const std::variant>& v : values_) { if (std::holds_alternative(v)) { - this->values.push_back(std::shared_ptr(std::get(v))); + values.push_back(std::shared_ptr(std::get(v))); } else { - this->values.push_back(std::get>(v)); + values.push_back(std::get>(v)); } } } @@ -857,7 +767,7 @@ std::string OrVerifier::type() const { types.begin(), std::mem_fn(&Verifier::type) ); - types.push_back(std::string("or ") + values.back()->type()); + types.push_back(fmt::format("or {}", values.back()->type())); return ghoul::join(types, ", "); } @@ -871,7 +781,7 @@ std::string OrVerifier::documentation() const { documentations.begin(), std::mem_fn(&Verifier::documentation) ); - documentations.push_back(std::string("or ") + values.back()->documentation()); + documentations.push_back(fmt::format("or {}", values.back()->documentation())); return ghoul::join(documentations, ", "); } diff --git a/src/interaction/tasks/convertrecfileversiontask.cpp b/src/interaction/tasks/convertrecfileversiontask.cpp index 6f700fc6dd..717f4d8053 100644 --- a/src/interaction/tasks/convertrecfileversiontask.cpp +++ b/src/interaction/tasks/convertrecfileversiontask.cpp @@ -103,6 +103,7 @@ documentation::Documentation ConvertRecFileVersionTask::documentation() { return { "ConvertRecFileVersionTask", "convert_file_version_task", + "", { { "InputFilePath", diff --git a/src/interaction/tasks/convertrecformattask.cpp b/src/interaction/tasks/convertrecformattask.cpp index 52bc0bda3a..3e4f998483 100644 --- a/src/interaction/tasks/convertrecformattask.cpp +++ b/src/interaction/tasks/convertrecformattask.cpp @@ -314,6 +314,7 @@ documentation::Documentation ConvertRecFormatTask::documentation() { return { "ConvertRecFormatTask", "convert_format_task", + "", { { "InputFilePath", diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp index 5a5c3d006a..755b1e3efa 100644 --- a/src/util/factorymanager.cpp +++ b/src/util/factorymanager.cpp @@ -47,6 +47,7 @@ nlohmann::json generateJsonDocumentation(const Documentation& d) { json["name"] = d.name; json["identifier"] = d.id; + json["description"] = d.description; json["members"] = nlohmann::json::array(); for (const DocumentationEntry& p : d.entries) { @@ -80,7 +81,8 @@ nlohmann::json generateJsonDocumentation(const Documentation& d) { } } else if (tv) { - nlohmann::json restrictions = generateJsonDocumentation(tv->documentations); + Documentation doc = { .entries = tv->documentations }; + nlohmann::json restrictions = generateJsonDocumentation(doc); // We have a TableVerifier, so we need to recurse entry["restrictions"] = restrictions; } diff --git a/support/coding/codegen b/support/coding/codegen index abe1b74019..b38743ad76 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit abe1b74019f332c1e5a62774776bf11d42cf8f85 +Subproject commit b38743ad76edb7affe7db8e77445450b15face72 diff --git a/tests/test_documentation.cpp b/tests/test_documentation.cpp index bae134b1b9..debd5ed418 100644 --- a/tests/test_documentation.cpp +++ b/tests/test_documentation.cpp @@ -277,8 +277,8 @@ TEST_CASE("Documentation: Constructor", "[documentation]") { TEST_CASE("Documentation: Initializer Constructor", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - { + Documentation doc = { + .entries = { // Basic Verifiers {"BoolVerifier", new BoolVerifier, Optional::No }, {"DoubleVerifier", new DoubleVerifier, Optional::No }, @@ -344,8 +344,10 @@ TEST_CASE("Documentation: Initializer Constructor", "[documentation]") { TEST_CASE("Documentation: BoolVerifier", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Bool", new BoolVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "Bool", new BoolVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -376,8 +378,10 @@ TEST_CASE("Documentation: BoolVerifier", "[documentation]") { TEST_CASE("Documentation: DoubleVerifier", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new DoubleVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "Double", new DoubleVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -407,8 +411,10 @@ TEST_CASE("Documentation: DoubleVerifier", "[documentation]") { TEST_CASE("Documentation: IntVerifier", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "Int", new IntVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -444,8 +450,10 @@ TEST_CASE("Documentation: StringVerifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - {{ "String", new StringVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "String", new StringVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -475,8 +483,10 @@ TEST_CASE("Documentation: IdentifierVerifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc{ - {{ "Identifier", new IdentifierVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "Identifier", new IdentifierVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -538,8 +548,10 @@ TEST_CASE("Documentation: FileVerifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - {{ "File", new FileVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "File", new FileVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -577,8 +589,10 @@ TEST_CASE("Documentation: DirectoryVerifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc{ - {{ "Dir", new DirectoryVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "Dir", new DirectoryVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -616,8 +630,10 @@ TEST_CASE("Documentation: DateTimeVerifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc{ - {{ "DateTime", new DateTimeVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "DateTime", new DateTimeVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -654,8 +670,10 @@ TEST_CASE("Documentation: DateTimeVerifier", "[documentation]") { TEST_CASE("Documentation: TableVerifierType", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Table", new TableVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "Table", new TableVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -685,8 +703,10 @@ TEST_CASE("Documentation: StringListVerifierType", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "StringList", new StringListVerifier, Optional::No } } + Documentation doc = { + .entries = { + { "StringList", new StringListVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -737,8 +757,10 @@ TEST_CASE("Documentation: IntListVerifierType", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "IntList", new IntListVerifier, Optional::No } } + Documentation doc = { + .entries = { + { "IntList", new IntListVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -788,8 +810,8 @@ TEST_CASE("Documentation: MixedVerifiers", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { + Documentation doc = { + .entries = { { "Bool", new BoolVerifier, Optional::No }, { "Double", new DoubleVerifier, Optional::No }, { "Int", new IntVerifier, Optional::No }, @@ -839,8 +861,8 @@ TEST_CASE("Documentation: NestedTables", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { + Documentation doc = { + .entries = { { "Outer_Int", new IntVerifier, Optional::No }, { "Outer_Table", new TableVerifier({ { "Inner_Double", new DoubleVerifier, Optional::No }, @@ -1018,8 +1040,8 @@ TEST_CASE("Documentation: NestedTables", "[documentation]") { TEST_CASE("Documentation: Optional", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - { + Documentation doc = { + .entries = { { "Bool_Force", new BoolVerifier, Optional::No }, { "Bool_Optional", new BoolVerifier, Optional::Yes } } @@ -1066,23 +1088,25 @@ TEST_CASE("Documentation: Optional", "[documentation]") { TEST_CASE("Documentation: Required In Optional", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ - "a", - new TableVerifier({ - { - "b", - new IntVerifier, - Optional::No - }, - { - "c", - new IntVerifier, - Optional::Yes - } - }), - Optional::Yes - }} + Documentation doc = { + .entries = { + { + "a", + new TableVerifier({ + { + "b", + new IntVerifier, + Optional::No + }, + { + "c", + new IntVerifier, + Optional::Yes + } + }), + Optional::Yes + } + } }; ghoul::Dictionary positive; @@ -1127,8 +1151,10 @@ TEST_CASE("Documentation: Required In Optional", "[documentation]") { TEST_CASE("Documentation: Exhaustive", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntVerifier, Optional::No }} + Documentation doc = { + .entries = { + { "Int", new IntVerifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -1157,11 +1183,14 @@ TEST_CASE("Documentation: Exhaustive", "[documentation]") { TEST_CASE("Documentation: Nested Exhaustive", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Table", new TableVerifier( - { { "a", new IntVerifier, Optional::No } } - ), Optional::No - }} + Documentation doc = { + .entries = { + { + "Table", + new TableVerifier({ { "a", new IntVerifier, Optional::No } }), + Optional::No + } + } }; ghoul::Dictionary positive; @@ -1207,12 +1236,10 @@ TEST_CASE("Documentation: Empty Entries Non Exhaustive", "[documentation]") { TEST_CASE("Documentation: Empty Nested Exhaustive", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ - "Table", - new TableVerifier(), - Optional::No, - }} + Documentation doc = { + .entries = { + { "Table", new TableVerifier(), Optional::No } + } }; ghoul::Dictionary positive; @@ -1235,8 +1262,10 @@ TEST_CASE("Documentation: Empty Nested Exhaustive", "[documentation]") { TEST_CASE("Documentation: Less Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntLessVerifier(5), Optional::No }} + Documentation doc = { + .entries = { + { "Int", new IntLessVerifier(5), Optional::No } + } }; ghoul::Dictionary positive; @@ -1257,8 +1286,8 @@ TEST_CASE("Documentation: Less Int", "[documentation]") { TEST_CASE("Documentation: Less Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new DoubleLessVerifier(5.0), Optional::No }} + Documentation doc = { + .entries = { { "Double", new DoubleLessVerifier(5.0), Optional::No } } }; ghoul::Dictionary positive; @@ -1279,8 +1308,8 @@ TEST_CASE("Documentation: Less Double", "[documentation]") { TEST_CASE("Documentation: LessEqual Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntLessEqualVerifier(5), Optional::No }} + Documentation doc = { + .entries = { { "Int", new IntLessEqualVerifier(5), Optional::No } } }; ghoul::Dictionary positive; @@ -1307,8 +1336,8 @@ TEST_CASE("Documentation: LessEqual Int", "[documentation]") { TEST_CASE("Documentation: LessEqual Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new DoubleLessEqualVerifier(5.0), Optional::No }} + Documentation doc = { + .entries = { { "Double", new DoubleLessEqualVerifier(5.0), Optional::No } } }; ghoul::Dictionary positive; @@ -1335,8 +1364,8 @@ TEST_CASE("Documentation: LessEqual Double", "[documentation]") { TEST_CASE("Documentation: Greater Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntGreaterVerifier(5), Optional::No }} + Documentation doc = { + .entries = { { "Int", new IntGreaterVerifier(5), Optional::No } } }; ghoul::Dictionary positive; @@ -1357,8 +1386,8 @@ TEST_CASE("Documentation: Greater Int", "[documentation]") { TEST_CASE("Documentation: Greater Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new DoubleGreaterVerifier(5.0), Optional::No }} + Documentation doc = { + .entries = { { "Double", new DoubleGreaterVerifier(5.0), Optional::No } } }; ghoul::Dictionary positive; @@ -1379,8 +1408,8 @@ TEST_CASE("Documentation: Greater Double", "[documentation]") { TEST_CASE("Documentation: GreaterEqual Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntGreaterEqualVerifier(5), Optional::No }} + Documentation doc = { + .entries = { { "Int", new IntGreaterEqualVerifier(5), Optional::No } } }; ghoul::Dictionary positive; @@ -1407,8 +1436,8 @@ TEST_CASE("Documentation: GreaterEqual Int", "[documentation]") { TEST_CASE("Documentation: GreaterEqual Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new DoubleGreaterEqualVerifier(5.0), Optional::No }} + Documentation doc = { + .entries = { { "Double", new DoubleGreaterEqualVerifier(5.0), Optional::No } } }; ghoul::Dictionary positive; @@ -1435,8 +1464,8 @@ TEST_CASE("Documentation: GreaterEqual Double", "[documentation]") { TEST_CASE("Documentation: Equal Bool", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Bool", new BoolEqualVerifier(true), Optional::No }} + Documentation doc = { + .entries = { { "Bool", new BoolEqualVerifier(true), Optional::No } } }; ghoul::Dictionary positive; @@ -1457,8 +1486,8 @@ TEST_CASE("Documentation: Equal Bool", "[documentation]") { TEST_CASE("Documentation: Equal Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntEqualVerifier(1), Optional::No }} + Documentation doc = { + .entries = { { "Int", new IntEqualVerifier(1), Optional::No } } }; ghoul::Dictionary positive; @@ -1479,8 +1508,8 @@ TEST_CASE("Documentation: Equal Int", "[documentation]") { TEST_CASE("Documentation: Equal Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new DoubleEqualVerifier(1.0), Optional::No }} + Documentation doc = { + .entries = { { "Double", new DoubleEqualVerifier(1.0), Optional::No } } }; ghoul::Dictionary positive; @@ -1502,8 +1531,8 @@ TEST_CASE("Documentation: Equal String", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - {{ "String", new StringEqualVerifier("string"s), Optional::No }} + Documentation doc = { + .entries = { { "String", new StringEqualVerifier("string"s), Optional::No } } }; ghoul::Dictionary positive; @@ -1524,8 +1553,8 @@ TEST_CASE("Documentation: Equal String", "[documentation]") { TEST_CASE("Documentation: Unequal Bool", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Bool", new BoolUnequalVerifier(true), Optional::No }} + Documentation doc = { + .entries = { { "Bool", new BoolUnequalVerifier(true), Optional::No } } }; ghoul::Dictionary positive; @@ -1546,8 +1575,8 @@ TEST_CASE("Documentation: Unequal Bool", "[documentation]") { TEST_CASE("Documentation: Unequal Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntUnequalVerifier(1), Optional::No }} + Documentation doc = { + .entries = { { "Int", new IntUnequalVerifier(1), Optional::No } } }; ghoul::Dictionary positive; @@ -1568,8 +1597,8 @@ TEST_CASE("Documentation: Unequal Int", "[documentation]") { TEST_CASE("Documentation: Unequal Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new DoubleUnequalVerifier(1.0), Optional::No }} + Documentation doc = { + .entries = { { "Double", new DoubleUnequalVerifier(1.0), Optional::No } } }; ghoul::Dictionary positive; @@ -1591,8 +1620,8 @@ TEST_CASE("Documentation: Unequal String", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - {{ "String", new StringUnequalVerifier("string"s), Optional::No }} + Documentation doc = { + .entries = { { "String", new StringUnequalVerifier("string"s), Optional::No } } }; ghoul::Dictionary positive; @@ -1613,8 +1642,8 @@ TEST_CASE("Documentation: Unequal String", "[documentation]") { TEST_CASE("Documentation: List Bool", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Bool" , new BoolInListVerifier({ true }), Optional::No }} + Documentation doc = { + .entries = { { "Bool" , new BoolInListVerifier({ true }), Optional::No } } }; ghoul::Dictionary positive; @@ -1635,8 +1664,8 @@ TEST_CASE("Documentation: List Bool", "[documentation]") { TEST_CASE("Documentation: List Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int" , new IntInListVerifier({ 0, 1, 2 }), Optional::No }} + Documentation doc = { + .entries = { { "Int" , new IntInListVerifier({ 0, 1, 2 }), Optional::No } } }; ghoul::Dictionary positive; @@ -1663,8 +1692,10 @@ TEST_CASE("Documentation: List Int", "[documentation]") { TEST_CASE("Documentation: List Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double" , new DoubleInListVerifier({ 0.0, 1.0, 2.0 }), Optional::No }} + Documentation doc = { + .entries = { + { "Double" , new DoubleInListVerifier({ 0.0, 1.0, 2.0 }), Optional::No } + } }; ghoul::Dictionary positive; @@ -1692,8 +1723,10 @@ TEST_CASE("Documentation: List String", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - {{ "String" , new StringInListVerifier({ "0"s, "1"s, "2"s }), Optional::No }} + Documentation doc = { + .entries = { + { "String" , new StringInListVerifier({ "0"s, "1"s, "2"s }), Optional::No } + } }; ghoul::Dictionary positive; @@ -1720,8 +1753,8 @@ TEST_CASE("Documentation: List String", "[documentation]") { TEST_CASE("Documentation: NotList Bool", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Bool" , new BoolNotInListVerifier({ true }), Optional::No }} + Documentation doc = { + .entries = { { "Bool" , new BoolNotInListVerifier({ true }), Optional::No } } }; ghoul::Dictionary positive; @@ -1742,8 +1775,8 @@ TEST_CASE("Documentation: NotList Bool", "[documentation]") { TEST_CASE("Documentation: NotList Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int" , new IntNotInListVerifier({ 0, 1, 2 }), Optional::No }} + Documentation doc = { + .entries = { { "Int" , new IntNotInListVerifier({ 0, 1, 2 }), Optional::No } } }; ghoul::Dictionary positive; @@ -1770,8 +1803,10 @@ TEST_CASE("Documentation: NotList Int", "[documentation]") { TEST_CASE("Documentation: NotList Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double" , new DoubleNotInListVerifier({ 0.0, 1.0, 2.0 }), Optional::No }} + Documentation doc = { + .entries = { + { "Double" , new DoubleNotInListVerifier({ 0.0, 1.0, 2.0 }), Optional::No } + } }; ghoul::Dictionary positive; @@ -1799,8 +1834,10 @@ TEST_CASE("Documentation: NotList String", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - {{ "String" , new StringNotInListVerifier({ "0"s, "1"s, "2"s }), Optional::No }} + Documentation doc = { + .entries = { + { "String" , new StringNotInListVerifier({ "0"s, "1"s, "2"s }), Optional::No } + } }; ghoul::Dictionary positive; @@ -1827,8 +1864,8 @@ TEST_CASE("Documentation: NotList String", "[documentation]") { TEST_CASE("Documentation: Annotation Bool", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Bool", new BoolAnnotationVerifier("Bool"), Optional::No }} + Documentation doc = { + .entries = { { "Bool", new BoolAnnotationVerifier("Bool"), Optional::No } } }; ghoul::Dictionary positive; @@ -1849,8 +1886,8 @@ TEST_CASE("Documentation: Annotation Bool", "[documentation]") { TEST_CASE("Documentation: Annotation Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new IntAnnotationVerifier("Int"), Optional::No }} + Documentation doc = { + .entries = { { "Int", new IntAnnotationVerifier("Int"), Optional::No } } }; ghoul::Dictionary positive; @@ -1871,8 +1908,8 @@ TEST_CASE("Documentation: Annotation Int", "[documentation]") { TEST_CASE("Documentation: Annotation Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new DoubleAnnotationVerifier("Double"), Optional::No }} + Documentation doc = { + .entries = { { "Double", new DoubleAnnotationVerifier("Double"), Optional::No } } }; ghoul::Dictionary positive; @@ -1894,8 +1931,8 @@ TEST_CASE("Documentation: Annotation String", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - {{ "String", new StringAnnotationVerifier("String"), Optional::No }} + Documentation doc = { + .entries = { { "String", new StringAnnotationVerifier("String"), Optional::No } } }; ghoul::Dictionary positive; @@ -1916,8 +1953,8 @@ TEST_CASE("Documentation: Annotation String", "[documentation]") { TEST_CASE("Documentation: Annotation Table", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Table", new TableAnnotationVerifier("Table"), Optional::No }} + Documentation doc = { + .entries = { { "Table", new TableAnnotationVerifier("Table"), Optional::No } } }; ghoul::Dictionary positive; @@ -1938,8 +1975,8 @@ TEST_CASE("Documentation: Annotation Table", "[documentation]") { TEST_CASE("Documentation: InRange Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new InRangeVerifier(0, 5), Optional::No }} + Documentation doc = { + .entries = { { "Int", new InRangeVerifier(0, 5), Optional::No } } }; ghoul::Dictionary positive; @@ -1972,8 +2009,10 @@ TEST_CASE("Documentation: InRange Int", "[documentation]") { TEST_CASE("Documentation: InRange Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new InRangeVerifier(0.0, 5.0), Optional::No }} + Documentation doc = { + .entries = { + { "Double", new InRangeVerifier(0.0, 5.0), Optional::No } + } }; ghoul::Dictionary positive; @@ -2012,8 +2051,8 @@ TEST_CASE("Documentation: InRange Double", "[documentation]") { TEST_CASE("Documentation: NotInRange Int", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Int", new NotInRangeVerifier(0, 5), Optional::No }} + Documentation doc = { + .entries = { { "Int", new NotInRangeVerifier(0, 5), Optional::No } } }; ghoul::Dictionary positive; @@ -2056,8 +2095,10 @@ TEST_CASE("Documentation: NotInRange Int", "[documentation]") { TEST_CASE("Documentation: NotInRange Double", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ "Double", new NotInRangeVerifier(0.0, 5.0), Optional::No }} + Documentation doc = { + .entries = { + { "Double", new NotInRangeVerifier(0.0, 5.0), Optional::No } + } }; ghoul::Dictionary positive; @@ -2100,8 +2141,8 @@ TEST_CASE("Documentation: NotInRange Double", "[documentation]") { TEST_CASE("Documentation: Wildcard", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - {{ DocumentationEntry::Wildcard, new IntVerifier, Optional::No }} + Documentation doc = { + .entries = { { DocumentationEntry::Wildcard, new IntVerifier, Optional::No } } }; ghoul::Dictionary positive; @@ -2152,9 +2193,9 @@ TEST_CASE("Documentation: Wildcard", "[documentation]") { TEST_CASE("Documentation: Wildcard Mixed", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - { - { DocumentationEntry::Wildcard, new IntVerifier, Optional::No}, + Documentation doc = { + .entries = { + { DocumentationEntry::Wildcard, new IntVerifier, Optional::No }, { "b", new IntGreaterVerifier(5), Optional::No } } }; @@ -2221,9 +2262,10 @@ TEST_CASE("Documentation: Wildcard Mixed", "[documentation]") { TEST_CASE("Documentation: Referencing", "[documentation]") { using namespace openspace::documentation; - Documentation referenced { + Documentation referenced = { "Referenced Name", "referenced_id", + "", { { "a", new IntVerifier, Optional::No }, { "b", new DoubleVerifier, Optional::No } @@ -2231,9 +2273,11 @@ TEST_CASE("Documentation: Referencing", "[documentation]") { }; DocEng.addDocumentation(referenced); - Documentation doc {{ - { "Table", new ReferencingVerifier("referenced_id"), Optional::No } - }}; + Documentation doc = { + .entries = { + { "Table", new ReferencingVerifier("referenced_id"), Optional::No } + } + }; ghoul::Dictionary positive; { @@ -2268,9 +2312,11 @@ TEST_CASE("Documentation: Referencing", "[documentation]") { CHECK(negativeRes.offenses[0].reason == TestResult::Offense::Reason::WrongType); - Documentation wrongDoc {{ - { "Table", new ReferencingVerifier("WRONG"), Optional::No } - } }; + Documentation wrongDoc = { + .entries = { + { "Table", new ReferencingVerifier("WRONG"), Optional::No } + } + }; ghoul::Dictionary wrongNegative; { ghoul::Dictionary inner; @@ -2287,50 +2333,14 @@ TEST_CASE("Documentation: Referencing", "[documentation]") { ); } -TEST_CASE("Documentation: AndOperator", "[documentation]") { - using namespace openspace::documentation; - - Documentation doc { - { - { - "a", - new AndVerifier({ - new IntGreaterEqualVerifier(2), new IntLessEqualVerifier(5) - }), - Optional::No - } - } - }; - - ghoul::Dictionary positive; - positive.setValue("a", 4.0); - TestResult positiveRes = testSpecification(doc, positive); - CHECK(positiveRes.success); - CHECK(positiveRes.offenses.empty()); - - ghoul::Dictionary negative; - negative.setValue("a", 0.0); - TestResult negativeRes = testSpecification(doc, negative); - CHECK_FALSE(negativeRes.success); - REQUIRE(negativeRes.offenses.size() == 1); - CHECK(negativeRes.offenses[0].offender == "a"); - CHECK(negativeRes.offenses[0].reason == TestResult::Offense::Reason::Verification); - - ghoul::Dictionary negative2; - negative2.setValue("a", 8.0); - negativeRes = testSpecification(doc, negative2); - CHECK_FALSE(negativeRes.success); - REQUIRE(negativeRes.offenses.size() == 1); - CHECK(negativeRes.offenses[0].offender == "a"); - CHECK(negativeRes.offenses[0].reason == TestResult::Offense::Reason::Verification); -} - TEST_CASE("Documentation: OrOperator", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - {{ "a", new OrVerifier({ new StringVerifier, new IntVerifier }), Optional::No }} + Documentation doc = { + .entries = { + { "a", new OrVerifier({ new StringVerifier, new IntVerifier }), Optional::No } + } }; ghoul::Dictionary positive; @@ -2357,8 +2367,10 @@ TEST_CASE("Documentation: OrOperator", "[documentation]") { TEST_CASE("Documentation: IntVector2Verifier", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - { { "a", new IntVector2Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new IntVector2Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2392,8 +2404,10 @@ TEST_CASE("Documentation: IntVector2Verifier", "[documentation]") { TEST_CASE("Documentation: DoubleVector2Verifier", "[documentation]") { using namespace openspace::documentation; - Documentation doc { - { { "a", new DoubleVector2Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleVector2Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2428,8 +2442,10 @@ TEST_CASE("Documentation: IntVector3Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new IntVector3Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new IntVector3Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2465,8 +2481,10 @@ TEST_CASE("Documentation: DoubleVector3Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleVector3Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleVector3Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2502,8 +2520,10 @@ TEST_CASE("Documentation: IntVector4Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new IntVector4Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new IntVector4Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2540,8 +2560,10 @@ TEST_CASE("Documentation: DoubleVector4Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleVector4Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleVector4Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2578,8 +2600,10 @@ TEST_CASE("Documentation: DoubleMatrix2x2Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix2x2Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix2x2Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2615,8 +2639,10 @@ TEST_CASE("Documentation: DoubleMatrix2x3Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix2x3Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix2x3Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2652,8 +2678,10 @@ TEST_CASE("Documentation: DoubleMatrix2x4Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix2x4Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix2x4Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2689,8 +2717,10 @@ TEST_CASE("Documentation: DoubleMatrix3x2Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix3x2Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix3x2Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2726,8 +2756,10 @@ TEST_CASE("Documentation: DoubleMatrix3x3Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix3x3Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix3x3Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2763,8 +2795,10 @@ TEST_CASE("Documentation: DoubleMatrix3x4Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix3x4Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix3x4Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2800,8 +2834,10 @@ TEST_CASE("Documentation: DoubleMatrix4x2Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix4x2Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix4x2Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2837,8 +2873,10 @@ TEST_CASE("Documentation: DoubleMatrix4x3Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix4x3Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix4x3Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2874,8 +2912,10 @@ TEST_CASE("Documentation: DoubleMatrix4x4Verifier", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; - Documentation doc { - { { "a", new DoubleMatrix4x4Verifier, Optional::No } } + Documentation doc = { + .entries = { + { "a", new DoubleMatrix4x4Verifier, Optional::No } + } }; ghoul::Dictionary positive; @@ -2907,61 +2947,6 @@ TEST_CASE("Documentation: DoubleMatrix4x4Verifier", "[documentation]") { CHECK(negativeRes.offenses[0].reason == TestResult::Offense::Reason::WrongType); } -TEST_CASE("Documentation: DeprecatedVerifier", "[documentation]") { - using namespace openspace::documentation; - using namespace std::string_literals; - - Documentation doc { { - { "bool", new BoolDeprecatedVerifier, Optional::No }, - { "int" , new IntDeprecatedVerifier, Optional::No }, - { "double", new DoubleDeprecatedVerifier, Optional::No }, - { "string" , new StringDeprecatedVerifier, Optional::No }, - { "intvec2", new DeprecatedVerifier, Optional::No }, - { "doublevec2", new DeprecatedVerifier, Optional::No }, - { "intvec3", new DeprecatedVerifier, Optional::No }, - { "doublevec3", new DeprecatedVerifier, Optional::No }, - { "intvec4", new DeprecatedVerifier, Optional::No }, - { "doublevec4", new DeprecatedVerifier, Optional::No } - }}; - - ghoul::Dictionary positive; - positive.setValue("bool", true); - positive.setValue("int", 1); - positive.setValue("double", 2.0); - positive.setValue("string", ""s); - positive.setValue("intvec2", glm::ivec2(0)); - positive.setValue("doublevec2", glm::dvec2(0.0)); - positive.setValue("intvec3", glm::ivec3(0)); - positive.setValue("doublevec3", glm::dvec3(0.0)); - positive.setValue("intvec4", glm::ivec4(0)); - positive.setValue("doublevec4", glm::dvec4(0.0)); - TestResult positiveRes = testSpecification(doc, positive); - CHECK(positiveRes.success); - CHECK(positiveRes.offenses.empty()); - REQUIRE(positiveRes.warnings.size() == 10); - - CHECK(positiveRes.warnings[0].offender == "bool"); - CHECK(positiveRes.warnings[0].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[1].offender == "double"); - CHECK(positiveRes.warnings[1].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[2].offender == "doublevec2"); - CHECK(positiveRes.warnings[2].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[3].offender == "doublevec3"); - CHECK(positiveRes.warnings[3].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[4].offender == "doublevec4"); - CHECK(positiveRes.warnings[4].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[5].offender == "int"); - CHECK(positiveRes.warnings[5].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[6].offender == "intvec2"); - CHECK(positiveRes.warnings[6].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[7].offender == "intvec3"); - CHECK(positiveRes.warnings[7].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[8].offender == "intvec4"); - CHECK(positiveRes.warnings[8].reason == TestResult::Warning::Reason::Deprecated); - CHECK(positiveRes.warnings[9].offender == "string"); - CHECK(positiveRes.warnings[9].reason == TestResult::Warning::Reason::Deprecated); -} - TEST_CASE("Documentation: Verifier Type Post Conditions", "[documentation]") { using namespace openspace::documentation; using namespace std::string_literals; @@ -3023,18 +3008,6 @@ TEST_CASE("Documentation: Verifier Type Post Conditions", "[documentation]") { CHECK(AnnotationVerifier("A"s).type() != ""); CHECK(AnnotationVerifier("A"s).type() != ""); - CHECK(BoolDeprecatedVerifier().type() != ""); - CHECK(IntDeprecatedVerifier().type() != ""); - CHECK(DoubleDeprecatedVerifier().type() != ""); - CHECK(StringDeprecatedVerifier().type() != ""); - CHECK(TableDeprecatedVerifier().type() != ""); - CHECK(DeprecatedVerifier().type() != ""); - CHECK(DeprecatedVerifier().type() != ""); - CHECK(DeprecatedVerifier().type() != ""); - CHECK(DeprecatedVerifier().type() != ""); - CHECK(DeprecatedVerifier().type() != ""); - CHECK(DeprecatedVerifier().type() != ""); - CHECK(ReferencingVerifier("identifier"s).type() != ""); } @@ -3099,17 +3072,5 @@ TEST_CASE("Documentation: Verifier Documentation Post Conditions", "[documentati CHECK(AnnotationVerifier("A"s).documentation() != ""); CHECK(AnnotationVerifier("A"s).documentation() != ""); - CHECK(BoolDeprecatedVerifier().documentation() != ""); - CHECK(IntDeprecatedVerifier().documentation() != ""); - CHECK(DoubleDeprecatedVerifier().documentation() != ""); - CHECK(StringDeprecatedVerifier().documentation() != ""); - CHECK(TableDeprecatedVerifier().documentation() != ""); - CHECK(DeprecatedVerifier().documentation() != ""); - CHECK(DeprecatedVerifier().documentation() != ""); - CHECK(DeprecatedVerifier().documentation() != ""); - CHECK(DeprecatedVerifier().documentation() != ""); - CHECK(DeprecatedVerifier().documentation() != ""); - CHECK(DeprecatedVerifier().documentation() != ""); - CHECK(ReferencingVerifier("identifier"s).documentation() != ""); }