From 7477da50f89c78b1a86e0d89e1ecf822cb914337 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Mon, 20 Feb 2023 12:05:52 +1300 Subject: [PATCH 01/13] GeneratorProfile: added `profileAsString()`. --- src/api/libcellml/generatorprofile.h | 9 +++++++++ src/bindings/interface/generatorprofile.i | 3 +++ src/bindings/javascript/generatorprofile.cpp | 1 + src/generatorprofile.cpp | 11 +++++++++++ tests/bindings/javascript/generatorprofile.test.js | 3 +++ tests/bindings/python/test_generator_profile.py | 2 ++ tests/generator/generatorprofile.cpp | 2 ++ 7 files changed, 31 insertions(+) diff --git a/src/api/libcellml/generatorprofile.h b/src/api/libcellml/generatorprofile.h index 390fa11ad4..32575e8928 100644 --- a/src/api/libcellml/generatorprofile.h +++ b/src/api/libcellml/generatorprofile.h @@ -72,6 +72,15 @@ class LIBCELLML_EXPORT GeneratorProfile */ Profile profile() const; + /** + * @brief Get the @c Profile as a string for this @c GeneratorProfile. + * + * Return the @c Profile as a string for this @c GeneratorProfile. + * + * @return The @c Profile as a string for this @c GeneratorProfile. + */ + std::string profileAsString() const; + /** * @brief Set the @c Profile. * diff --git a/src/bindings/interface/generatorprofile.i b/src/bindings/interface/generatorprofile.i index d8d41c9074..25bbe11f67 100644 --- a/src/bindings/interface/generatorprofile.i +++ b/src/bindings/interface/generatorprofile.i @@ -13,6 +13,9 @@ %feature("docstring") libcellml::GeneratorProfile::profile "Returns the :enum:`GeneratorProfile::Profile` for this :class:`GeneratorProfile`."; +%feature("docstring") libcellml::GeneratorProfile::profileAsString +"Returns the :enum:`GeneratorProfile::Profile` as a string for this :class:`GeneratorProfile`."; + %feature("docstring") libcellml::GeneratorProfile::setProfile "Sets the :enum:`GeneratorProfile::Profile` for this :class:`GeneratorProfile`."; diff --git a/src/bindings/javascript/generatorprofile.cpp b/src/bindings/javascript/generatorprofile.cpp index 57e29fa6ec..ed95c84d16 100644 --- a/src/bindings/javascript/generatorprofile.cpp +++ b/src/bindings/javascript/generatorprofile.cpp @@ -31,6 +31,7 @@ EMSCRIPTEN_BINDINGS(libcellml_generatorprofile) class_("GeneratorProfile") .smart_ptr_constructor("GeneratorProfile", &libcellml::GeneratorProfile::create) .function("profile", &libcellml::GeneratorProfile::profile) + .function("profileAsString", &libcellml::GeneratorProfile::profileAsString) .function("setProfile", &libcellml::GeneratorProfile::setProfile) .function("hasInterface", &libcellml::GeneratorProfile::hasInterface) .function("setHasInterface", &libcellml::GeneratorProfile::setHasInterface) diff --git a/src/generatorprofile.cpp b/src/generatorprofile.cpp index 506b85fb9b..9161f6def2 100644 --- a/src/generatorprofile.cpp +++ b/src/generatorprofile.cpp @@ -1038,6 +1038,17 @@ GeneratorProfile::Profile GeneratorProfile::profile() const return mPimpl->mProfile; } +std::string GeneratorProfile::profileAsString() const +{ + if (mPimpl->mProfile == Profile::C) { + return "C"; + } + + // mPimpl->mProfile == Profile::PYTHON. + + return "PYTHON"; +} + void GeneratorProfile::setProfile(Profile profile) { mPimpl->loadProfile(profile); diff --git a/tests/bindings/javascript/generatorprofile.test.js b/tests/bindings/javascript/generatorprofile.test.js index 2a259fb2e6..d530c2e289 100644 --- a/tests/bindings/javascript/generatorprofile.test.js +++ b/tests/bindings/javascript/generatorprofile.test.js @@ -23,9 +23,12 @@ describe("GeneratorProfile tests", () => { }); test("Checking GeneratorProfile.profile.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) + expect(x.profile()).toBe(libcellml.GeneratorProfile.Profile.C) + expect(x.profileAsString()).toBe("C") x.setProfile(libcellml.GeneratorProfile.Profile.PYTHON) expect(x.profile()).toBe(libcellml.GeneratorProfile.Profile.PYTHON) + expect(x.profileAsString()).toBe("PYTHON") }); test("Checking GeneratorProfile.hasInterface.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) diff --git a/tests/bindings/python/test_generator_profile.py b/tests/bindings/python/test_generator_profile.py index a132f3013b..eb993666b1 100644 --- a/tests/bindings/python/test_generator_profile.py +++ b/tests/bindings/python/test_generator_profile.py @@ -19,10 +19,12 @@ def test_generator_profile(self): # Create a default, i.e. C, profile. p = GeneratorProfile() self.assertEqual(GeneratorProfile.Profile.C, p.profile()) + self.assertEqual("C", p.profileAsString()) # Make the profile a Python profile. p.setProfile(GeneratorProfile.Profile.PYTHON) self.assertEqual(GeneratorProfile.Profile.PYTHON, p.profile()) + self.assertEqual("PYTHON", p.profileAsString()) # Create a Python profile. pp = GeneratorProfile(GeneratorProfile.Profile.PYTHON) diff --git a/tests/generator/generatorprofile.cpp b/tests/generator/generatorprofile.cpp index 50c9e61a2c..dd872fb446 100644 --- a/tests/generator/generatorprofile.cpp +++ b/tests/generator/generatorprofile.cpp @@ -38,6 +38,7 @@ TEST(GeneratorProfile, defaultGeneralValues) libcellml::GeneratorProfilePtr generatorProfile = libcellml::GeneratorProfile::create(); EXPECT_EQ(libcellml::GeneratorProfile::Profile::C, generatorProfile->profile()); + EXPECT_EQ("C", generatorProfile->profileAsString()); EXPECT_EQ(true, generatorProfile->hasInterface()); } @@ -497,6 +498,7 @@ TEST(GeneratorProfile, generalSettings) generatorProfile->setHasInterface(falseValue); EXPECT_EQ(profile, generatorProfile->profile()); + EXPECT_EQ("PYTHON", generatorProfile->profileAsString()); EXPECT_EQ(falseValue, generatorProfile->hasInterface()); } From 0f92e8330e19e5cdc057f31008a1677b532ea877 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Mon, 20 Feb 2023 14:06:42 +1300 Subject: [PATCH 02/13] Analyser: added some `typeAsString()` methods. --- src/analyserequation.cpp | 23 ++ src/analyserequationast.cpp | 263 ++++++++++++++++++ src/analysermodel.cpp | 31 +++ src/analyservariable.cpp | 27 ++ src/api/libcellml/analyserequation.h | 9 + src/api/libcellml/analyserequationast.h | 9 + src/api/libcellml/analysermodel.h | 9 + src/api/libcellml/analyservariable.h | 9 + src/bindings/interface/analyserequation.i | 3 + src/bindings/interface/analyserequationast.i | 3 + src/bindings/interface/analysermodel.i | 3 + src/bindings/interface/analyservariable.i | 3 + src/bindings/javascript/analyserequation.cpp | 1 + .../javascript/analyserequationast.cpp | 1 + src/bindings/javascript/analysermodel.cpp | 1 + src/bindings/javascript/analyservariable.cpp | 1 + tests/analyser/analyser.cpp | 4 + .../javascript/analyserequation.test.js | 1 + .../javascript/analyserequationast.test.js | 2 + .../bindings/javascript/analysermodel.test.js | 1 + .../javascript/analyservariable.test.js | 1 + tests/bindings/python/test_analyser.py | 5 + tests/coverage/coverage.cpp | 16 ++ tests/generator/generator.cpp | 35 +++ 24 files changed, 461 insertions(+) diff --git a/src/analyserequation.cpp b/src/analyserequation.cpp index ba6f592837..fbd0224d5e 100644 --- a/src/analyserequation.cpp +++ b/src/analyserequation.cpp @@ -68,6 +68,29 @@ AnalyserEquation::Type AnalyserEquation::type() const return mPimpl->mType; } +std::string AnalyserEquation::typeAsString() const +{ + if (mPimpl->mType == Type::TRUE_CONSTANT) { + return "TRUE_CONSTANT"; + } + + if (mPimpl->mType == Type::VARIABLE_BASED_CONSTANT) { + return "VARIABLE_BASED_CONSTANT"; + } + + if (mPimpl->mType == Type::RATE) { + return "RATE"; + } + + if (mPimpl->mType == Type::ALGEBRAIC) { + return "ALGEBRAIC"; + } + + // mPimpl->mType == Type::EXTERNAL. + + return "EXTERNAL"; +} + AnalyserEquationAstPtr AnalyserEquation::ast() const { return mPimpl->mAst.lock(); diff --git a/src/analyserequationast.cpp b/src/analyserequationast.cpp index 76999b36ed..5d135c45fb 100644 --- a/src/analyserequationast.cpp +++ b/src/analyserequationast.cpp @@ -65,6 +65,269 @@ AnalyserEquationAst::Type AnalyserEquationAst::type() const return mPimpl->mType; } +std::string AnalyserEquationAst::typeAsString() const +{ + if (mPimpl->mType == Type::ASSIGNMENT) { + return "ASSIGNMENT"; + } + + if (mPimpl->mType == Type::EQ) { + return "EQ"; + } + + if (mPimpl->mType == Type::NEQ) { + return "NEQ"; + } + + if (mPimpl->mType == Type::LT) { + return "LT"; + } + + if (mPimpl->mType == Type::LEQ) { + return "LEQ"; + } + + if (mPimpl->mType == Type::GT) { + return "GT"; + } + + if (mPimpl->mType == Type::GEQ) { + return "GEQ"; + } + + if (mPimpl->mType == Type::AND) { + return "AND"; + } + + if (mPimpl->mType == Type::OR) { + return "OR"; + } + + if (mPimpl->mType == Type::XOR) { + return "XOR"; + } + + if (mPimpl->mType == Type::NOT) { + return "NOT"; + } + + if (mPimpl->mType == Type::PLUS) { + return "PLUS"; + } + + if (mPimpl->mType == Type::MINUS) { + return "MINUS"; + } + + if (mPimpl->mType == Type::TIMES) { + return "TIMES"; + } + + if (mPimpl->mType == Type::DIVIDE) { + return "DIVIDE"; + } + + if (mPimpl->mType == Type::POWER) { + return "POWER"; + } + + if (mPimpl->mType == Type::ROOT) { + return "ROOT"; + } + + if (mPimpl->mType == Type::ABS) { + return "ABS"; + } + + if (mPimpl->mType == Type::EXP) { + return "EXP"; + } + + if (mPimpl->mType == Type::LN) { + return "LN"; + } + + if (mPimpl->mType == Type::LOG) { + return "LOG"; + } + + if (mPimpl->mType == Type::CEILING) { + return "CEILING"; + } + + if (mPimpl->mType == Type::FLOOR) { + return "FLOOR"; + } + + if (mPimpl->mType == Type::MIN) { + return "MIN"; + } + + if (mPimpl->mType == Type::MAX) { + return "MAX"; + } + + if (mPimpl->mType == Type::REM) { + return "REM"; + } + + if (mPimpl->mType == Type::DIFF) { + return "DIFF"; + } + + if (mPimpl->mType == Type::SIN) { + return "SIN"; + } + + if (mPimpl->mType == Type::COS) { + return "COS"; + } + + if (mPimpl->mType == Type::TAN) { + return "TAN"; + } + + if (mPimpl->mType == Type::SEC) { + return "SEC"; + } + + if (mPimpl->mType == Type::CSC) { + return "CSC"; + } + + if (mPimpl->mType == Type::COT) { + return "COT"; + } + + if (mPimpl->mType == Type::SINH) { + return "SINH"; + } + + if (mPimpl->mType == Type::COSH) { + return "COSH"; + } + + if (mPimpl->mType == Type::TANH) { + return "TANH"; + } + + if (mPimpl->mType == Type::SECH) { + return "SECH"; + } + + if (mPimpl->mType == Type::CSCH) { + return "CSCH"; + } + + if (mPimpl->mType == Type::COTH) { + return "COTH"; + } + + if (mPimpl->mType == Type::ASIN) { + return "ASIN"; + } + + if (mPimpl->mType == Type::ACOS) { + return "ACOS"; + } + + if (mPimpl->mType == Type::ATAN) { + return "ATAN"; + } + + if (mPimpl->mType == Type::ASEC) { + return "ASEC"; + } + + if (mPimpl->mType == Type::ACSC) { + return "ACSC"; + } + + if (mPimpl->mType == Type::ACOT) { + return "ACOT"; + } + + if (mPimpl->mType == Type::ASINH) { + return "ASINH"; + } + + if (mPimpl->mType == Type::ACOSH) { + return "ACOSH"; + } + + if (mPimpl->mType == Type::ATANH) { + return "ATANH"; + } + + if (mPimpl->mType == Type::ASECH) { + return "ASECH"; + } + + if (mPimpl->mType == Type::ACSCH) { + return "ACSCH"; + } + + if (mPimpl->mType == Type::ACOTH) { + return "ACOTH"; + } + + if (mPimpl->mType == Type::PIECEWISE) { + return "PIECEWISE"; + } + + if (mPimpl->mType == Type::PIECE) { + return "PIECE"; + } + + if (mPimpl->mType == Type::OTHERWISE) { + return "OTHERWISE"; + } + + if (mPimpl->mType == Type::CI) { + return "CI"; + } + + if (mPimpl->mType == Type::CN) { + return "CN"; + } + + if (mPimpl->mType == Type::DEGREE) { + return "DEGREE"; + } + + if (mPimpl->mType == Type::LOGBASE) { + return "LOGBASE"; + } + + if (mPimpl->mType == Type::BVAR) { + return "BVAR"; + } + + if (mPimpl->mType == Type::TRUE) { + return "TRUE"; + } + + if (mPimpl->mType == Type::FALSE) { + return "FALSE"; + } + + if (mPimpl->mType == Type::E) { + return "E"; + } + + if (mPimpl->mType == Type::PI) { + return "PI"; + } + + if (mPimpl->mType == Type::INF) { + return "INF"; + } + + // mPimpl->mType == Type::NAN: + + return "NAN"; +} + void AnalyserEquationAst::setType(Type type) { mPimpl->mType = type; diff --git a/src/analysermodel.cpp b/src/analysermodel.cpp index 2c0be99b93..194ec13b61 100644 --- a/src/analysermodel.cpp +++ b/src/analysermodel.cpp @@ -47,6 +47,37 @@ AnalyserModel::Type AnalyserModel::type() const return mPimpl->mType; } +std::string AnalyserModel::typeAsString() const +{ + if (mPimpl->mType == Type::UNKNOWN) { + return "UNKNOWN"; + } + + if (mPimpl->mType == Type::ALGEBRAIC) { + return "ALGEBRAIC"; + } + + if (mPimpl->mType == Type::ODE) { + return "ODE"; + } + + if (mPimpl->mType == Type::INVALID) { + return "INVALID"; + } + + if (mPimpl->mType == Type::UNDERCONSTRAINED) { + return "UNDERCONSTRAINED"; + } + + if (mPimpl->mType == Type::OVERCONSTRAINED) { + return "OVERCONSTRAINED"; + } + + // mPimpl->mType == Type::UNSUITABLY_CONSTRAINED. + + return "UNSUITABLY_CONSTRAINED"; +} + bool AnalyserModel::hasExternalVariables() const { if (!isValid()) { diff --git a/src/analyservariable.cpp b/src/analyservariable.cpp index 4ee38fb63e..24b00335a8 100644 --- a/src/analyservariable.cpp +++ b/src/analyservariable.cpp @@ -53,6 +53,33 @@ AnalyserVariable::Type AnalyserVariable::type() const return mPimpl->mType; } +std::string AnalyserVariable::typeAsString() const +{ + if (mPimpl->mType == Type::VARIABLE_OF_INTEGRATION) { + return "VARIABLE_OF_INTEGRATION"; + } + + if (mPimpl->mType == Type::STATE) { + return "STATE"; + } + + if (mPimpl->mType == Type::CONSTANT) { + return "CONSTANT"; + } + + if (mPimpl->mType == Type::COMPUTED_CONSTANT) { + return "COMPUTED_CONSTANT"; + } + + if (mPimpl->mType == Type::ALGEBRAIC) { + return "ALGEBRAIC"; + } + + // mPimpl->mType == Type::EXTERNAL. + + return "EXTERNAL"; +} + size_t AnalyserVariable::index() const { return mPimpl->mIndex; diff --git a/src/api/libcellml/analyserequation.h b/src/api/libcellml/analyserequation.h index 1f13babcbd..d59e7660ed 100644 --- a/src/api/libcellml/analyserequation.h +++ b/src/api/libcellml/analyserequation.h @@ -61,6 +61,15 @@ class LIBCELLML_EXPORT AnalyserEquation */ Type type() const; + /** + * @brief Get the @c Type as a string of this @c AnalyserEquation. + * + * Return the @c Type as a string of this @c AnalyserEquation. + * + * @return The @c Type as a string. + */ + std::string typeAsString() const; + /** * @brief Get the @c AnalyserEquationAst for this @c AnalyserEquation. * diff --git a/src/api/libcellml/analyserequationast.h b/src/api/libcellml/analyserequationast.h index 2d98c5ca9d..ba65e25363 100644 --- a/src/api/libcellml/analyserequationast.h +++ b/src/api/libcellml/analyserequationast.h @@ -166,6 +166,15 @@ class LIBCELLML_EXPORT AnalyserEquationAst */ Type type() const; + /** + * @brief Get the @c Type as a string of this @ref AnalyserEquationAst. + * + * Return the @c Type as a string of this @ref AnalyserEquationAst. + * + * @return The @c Type as a string. + */ + std::string typeAsString() const; + /** * @brief Set the type of this @ref AnalyserEquationAst. * diff --git a/src/api/libcellml/analysermodel.h b/src/api/libcellml/analysermodel.h index ceeb37fc3f..0256613efc 100644 --- a/src/api/libcellml/analysermodel.h +++ b/src/api/libcellml/analysermodel.h @@ -75,6 +75,15 @@ class LIBCELLML_EXPORT AnalyserModel */ Type type() const; + /** + * @brief Get the @c Type as a string of the @c AnalyserModel. + * + * Return the @c Type as a string of the @c AnalyserModel. + * + * @return The @c Type as a string. + */ + std::string typeAsString() const; + /** * @brief Test to determine if this @c AnalyserModel has external variables. * diff --git a/src/api/libcellml/analyservariable.h b/src/api/libcellml/analyservariable.h index 881a567614..e25ce95159 100644 --- a/src/api/libcellml/analyservariable.h +++ b/src/api/libcellml/analyservariable.h @@ -63,6 +63,15 @@ class LIBCELLML_EXPORT AnalyserVariable */ Type type() const; + /** + * @brief Get the @c Type as a string of this @c AnalyserVariable. + * + * Return the @c Type as a string of this @c AnalyserVariable. + * + * @return The @c Type as a string. + */ + std::string typeAsString() const; + /** * @brief Get the index of this @c AnalyserVariable. * diff --git a/src/bindings/interface/analyserequation.i b/src/bindings/interface/analyserequation.i index 887c81394d..1a8b5691a6 100644 --- a/src/bindings/interface/analyserequation.i +++ b/src/bindings/interface/analyserequation.i @@ -13,6 +13,9 @@ %feature("docstring") libcellml::AnalyserEquation::type "Returns the :enum:`AnalyserEquation::Type` for this :class:`AnalyserEquation` object."; +%feature("docstring") libcellml::AnalyserEquation::typeAsString +"Returns the :enum:`AnalyserEquation::Type` as a string for this :class:`AnalyserEquation` object."; + %feature("docstring") libcellml::AnalyserEquation::ast "Returns the :class:`AnalyserEquationAst` object for this :class:`AnalyserEquation` object."; diff --git a/src/bindings/interface/analyserequationast.i b/src/bindings/interface/analyserequationast.i index c6e4e71f3e..3d064c706f 100644 --- a/src/bindings/interface/analyserequationast.i +++ b/src/bindings/interface/analyserequationast.i @@ -13,6 +13,9 @@ %feature("docstring") libcellml::AnalyserEquationAst::type "Returns the :enum:`AnalyserEquationAst::Type` for this :class:`AnalyserEquationAst` object."; +%feature("docstring") libcellml::AnalyserEquationAst::typeAsString +"Returns the :enum:`AnalyserEquationAst::Type` as a string for this :class:`AnalyserEquationAst` object."; + %feature("docstring") libcellml::AnalyserEquationAst::setType "Sets the :enum:`AnalyserEquationAst::Type` for this :class:`AnalyserEquationAst` object."; diff --git a/src/bindings/interface/analysermodel.i b/src/bindings/interface/analysermodel.i index c6a7a8bf38..704d3e2f41 100644 --- a/src/bindings/interface/analysermodel.i +++ b/src/bindings/interface/analysermodel.i @@ -16,6 +16,9 @@ %feature("docstring") libcellml::AnalyserModel::type "Returns the :enum:`AnalyserModel::Type`."; +%feature("docstring") libcellml::AnalyserModel::typeAsString +"Returns the :enum:`AnalyserModel::Type` as a string."; + %feature("docstring") libcellml::AnalyserModel::hasExternalVariables "Tests if this :class:`AnalyserModel` object has external variables."; diff --git a/src/bindings/interface/analyservariable.i b/src/bindings/interface/analyservariable.i index 97a00ab77a..ca15759a8a 100644 --- a/src/bindings/interface/analyservariable.i +++ b/src/bindings/interface/analyservariable.i @@ -12,6 +12,9 @@ %feature("docstring") libcellml::AnalyserVariable::type "Returns the :enum:`AnalyserVariable::Type`."; +%feature("docstring") libcellml::AnalyserVariable::typeAsString +"Returns the :enum:`AnalyserVariable::Type` as a string."; + %feature("docstring") libcellml::AnalyserVariable::index "Returns the index."; diff --git a/src/bindings/javascript/analyserequation.cpp b/src/bindings/javascript/analyserequation.cpp index b71fe3707a..ffc32e756e 100644 --- a/src/bindings/javascript/analyserequation.cpp +++ b/src/bindings/javascript/analyserequation.cpp @@ -34,6 +34,7 @@ EMSCRIPTEN_BINDINGS(libcellml_analyserequation) class_("AnalyserEquation") .smart_ptr>("AnalyserEquation") .function("type", &libcellml::AnalyserEquation::type) + .function("typeAsString", &libcellml::AnalyserEquation::typeAsString) .function("ast", &libcellml::AnalyserEquation::ast) .function("dependencies", &libcellml::AnalyserEquation::dependencies) .function("isStateRateBased", &libcellml::AnalyserEquation::isStateRateBased) diff --git a/src/bindings/javascript/analyserequationast.cpp b/src/bindings/javascript/analyserequationast.cpp index 9abd7f92c6..7ddb54b75a 100644 --- a/src/bindings/javascript/analyserequationast.cpp +++ b/src/bindings/javascript/analyserequationast.cpp @@ -94,6 +94,7 @@ EMSCRIPTEN_BINDINGS(libcellml_analyserequationast) class_("AnalyserEquationAst") .smart_ptr_constructor("AnalyserEquationAst", &libcellml::AnalyserEquationAst::create) .function("type", &libcellml::AnalyserEquationAst::type) + .function("typeAsString", &libcellml::AnalyserEquationAst::typeAsString) .function("setType", &libcellml::AnalyserEquationAst::setType) .function("value", &libcellml::AnalyserEquationAst::value) .function("setValue", &libcellml::AnalyserEquationAst::setValue) diff --git a/src/bindings/javascript/analysermodel.cpp b/src/bindings/javascript/analysermodel.cpp index 4cd30d87d8..d0591ec908 100644 --- a/src/bindings/javascript/analysermodel.cpp +++ b/src/bindings/javascript/analysermodel.cpp @@ -37,6 +37,7 @@ EMSCRIPTEN_BINDINGS(libcellml_analysermodel) .smart_ptr>("AnalyserModel") .function("isValid", &libcellml::AnalyserModel::isValid) .function("type", &libcellml::AnalyserModel::type) + .function("typeAsString", &libcellml::AnalyserModel::typeAsString) .function("hasExternalVariables", &libcellml::AnalyserModel::hasExternalVariables) .function("voi", &libcellml::AnalyserModel::voi) .function("stateCount", &libcellml::AnalyserModel::stateCount) diff --git a/src/bindings/javascript/analyservariable.cpp b/src/bindings/javascript/analyservariable.cpp index 2698d4d9d8..052781ee32 100644 --- a/src/bindings/javascript/analyservariable.cpp +++ b/src/bindings/javascript/analyservariable.cpp @@ -35,6 +35,7 @@ EMSCRIPTEN_BINDINGS(libcellml_analyservariable) class_("AnalyserVariable") .smart_ptr>("AnalyserVariable") .function("type", &libcellml::AnalyserVariable::type) + .function("typeAsString", &libcellml::AnalyserVariable::typeAsString) .function("index", &libcellml::AnalyserVariable::index) .function("initialisingVariable", &libcellml::AnalyserVariable::initialisingVariable) .function("variable", &libcellml::AnalyserVariable::variable) diff --git a/tests/analyser/analyser.cpp b/tests/analyser/analyser.cpp index 095d127437..4043aa62c2 100644 --- a/tests/analyser/analyser.cpp +++ b/tests/analyser/analyser.cpp @@ -81,6 +81,7 @@ TEST(Analyser, initialisedVariableOfIntegration) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::INVALID, analyser->model()->type()); + EXPECT_EQ("INVALID", analyser->model()->typeAsString()); } TEST(Analyser, initialisedVariableOfIntegrationInNonFirstComponent) @@ -286,6 +287,7 @@ TEST(Analyser, nonInitialisedState) EXPECT_EQ(expectedVariableName, analyser->issue(0)->item()->variable()->name()); EXPECT_EQ(libcellml::AnalyserModel::Type::UNDERCONSTRAINED, analyser->model()->type()); + EXPECT_EQ("UNDERCONSTRAINED", analyser->model()->typeAsString()); } TEST(Analyser, underconstrained) @@ -336,6 +338,7 @@ TEST(Analyser, overconstrainedOneVariable) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::OVERCONSTRAINED, analyser->model()->type()); + EXPECT_EQ("OVERCONSTRAINED", analyser->model()->typeAsString()); } TEST(Analyser, overconstrainedTwoVariables) @@ -423,6 +426,7 @@ TEST(Analyser, unsuitablyConstrained) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::UNSUITABLY_CONSTRAINED, analyser->model()->type()); + EXPECT_EQ("UNSUITABLY_CONSTRAINED", analyser->model()->typeAsString()); } TEST(Analyser, addSameExternalVariable) diff --git a/tests/bindings/javascript/analyserequation.test.js b/tests/bindings/javascript/analyserequation.test.js index 40b42f0164..384ae985eb 100644 --- a/tests/bindings/javascript/analyserequation.test.js +++ b/tests/bindings/javascript/analyserequation.test.js @@ -44,6 +44,7 @@ describe("Analyser Equation tests", () => { }); test('Checking Analyser Equation type.', () => { expect(eqn.type().value).toBe(libcellml.AnalyserEquation.Type.RATE.value) + expect(eqn.typeAsString()).toBe("RATE") }); test('Checking Analyser Equation isStateRateBased.', () => { expect(eqn.isStateRateBased()).toBe(false) diff --git a/tests/bindings/javascript/analyserequationast.test.js b/tests/bindings/javascript/analyserequationast.test.js index 6129a6dd26..1de433d0ed 100644 --- a/tests/bindings/javascript/analyserequationast.test.js +++ b/tests/bindings/javascript/analyserequationast.test.js @@ -26,12 +26,14 @@ describe("Analyser Equation AST tests", () => { const aea = new libcellml.AnalyserEquationAst() expect(aea.type().value).toBe(libcellml.AnalyserEquationAst.Type.ASSIGNMENT.value) + expect(aea.typeAsString()).toBe("ASSIGNMENT") expect(aea.type()).toStrictEqual(libcellml.AnalyserEquationAst.Type.ASSIGNMENT) expect(aea.type()).not.toStrictEqual(libcellml.AnalyserEquationAst.Type.OTHERWISE) aea.setType(libcellml.AnalyserEquationAst.Type.OTHERWISE) expect(aea.type().value).toBe(libcellml.AnalyserEquationAst.Type.OTHERWISE.value) + expect(aea.typeAsString()).toBe("OTHERWISE") }); test('Checking Analyser Equation AST value.', () => { const aea = new libcellml.AnalyserEquationAst() diff --git a/tests/bindings/javascript/analysermodel.test.js b/tests/bindings/javascript/analysermodel.test.js index 59cc0a697c..67dfebbffb 100644 --- a/tests/bindings/javascript/analysermodel.test.js +++ b/tests/bindings/javascript/analysermodel.test.js @@ -39,6 +39,7 @@ describe("Analyser Model tests", () => { }); test('Checking Analyser Model type.', () => { expect(am.type().value).toBe(libcellml.AnalyserModel.Type.ODE.value) + expect(am.typeAsString()).toBe("ODE") }); test('Checking Analyser Model isValid.', () => { expect(am.isValid()).toBe(true) diff --git a/tests/bindings/javascript/analyservariable.test.js b/tests/bindings/javascript/analyservariable.test.js index 68086134c5..5acba5a325 100644 --- a/tests/bindings/javascript/analyservariable.test.js +++ b/tests/bindings/javascript/analyservariable.test.js @@ -42,6 +42,7 @@ describe("Analyser Variable tests", () => { test('Checking Analyser Variable type.', () => { const av = am.variable(5) expect(av.type().value).toBe(libcellml.AnalyserVariable.Type.ALGEBRAIC.value) + expect(av.typeAsString()).toBe("ALGEBRAIC") }); test('Checking Analyser Variable index.', () => { const av = am.variable(7) diff --git a/tests/bindings/python/test_analyser.py b/tests/bindings/python/test_analyser.py index d07a1f5e7d..a3f4b3d3f4 100644 --- a/tests/bindings/python/test_analyser.py +++ b/tests/bindings/python/test_analyser.py @@ -40,6 +40,7 @@ def test_analyse_model(self): self.assertEqual(0, a.errorCount()) self.assertEqual(AnalyserModel.Type.UNKNOWN, a.model().type()) + self.assertEqual("UNKNOWN", a.model().typeAsString()) def test_coverage(self): from libcellml import Analyser @@ -149,6 +150,7 @@ def test_coverage(self): av = am.variable(3) self.assertEqual(AnalyserVariable.Type.CONSTANT, av.type()) + self.assertEqual("CONSTANT", av.typeAsString()) self.assertEqual(3, av.index()) self.assertIsNotNone(av.initialisingVariable()) self.assertIsNotNone(av.variable()) @@ -159,6 +161,7 @@ def test_coverage(self): ae = am.equation(3) self.assertEqual(AnalyserEquation.Type.RATE, ae.type()) + self.assertEqual("RATE", ae.typeAsString()) self.assertIsNotNone(ae.ast()) self.assertIsNotNone(ae.dependencies()) self.assertTrue(ae.isStateRateBased()) @@ -169,6 +172,7 @@ def test_coverage(self): aea = ae.ast() self.assertEqual(AnalyserEquationAst.Type.ASSIGNMENT, aea.type()) + self.assertEqual("ASSIGNMENT", aea.typeAsString()) self.assertEqual('', aea.value()) self.assertIsNone(aea.variable()) self.assertIsNone(aea.parent()) @@ -184,6 +188,7 @@ def test_coverage(self): aea.setRightChild(None) self.assertEqual(AnalyserEquationAst.Type.EQ, aea.type()) + self.assertEqual("EQ", aea.typeAsString()) self.assertEqual(AnalyserTestCase.VALUE, aea.value()) self.assertIsNotNone(aea.variable()) self.assertIsNotNone(aea.parent()) diff --git a/tests/coverage/coverage.cpp b/tests/coverage/coverage.cpp index 1a233a6680..ed79f93a62 100644 --- a/tests/coverage/coverage.cpp +++ b/tests/coverage/coverage.cpp @@ -279,6 +279,7 @@ TEST(Coverage, analyser) EXPECT_FALSE(analyserModel->isValid()); EXPECT_EQ(libcellml::AnalyserModel::Type::UNKNOWN, analyserModel->type()); + EXPECT_EQ("UNKNOWN", analyserModel->typeAsString()); EXPECT_EQ(nullptr, analyserModel->voi()); @@ -355,6 +356,16 @@ TEST(Coverage, analyserExternalVariable) EXPECT_EQ(false, externalVariable->removeDependency(model, "not_membrane", "Cm")); } +void checkAstTypeAsString(const libcellml::AnalyserEquationAstPtr &ast) +{ + if (ast != nullptr) { + ast->typeAsString(); + + checkAstTypeAsString(ast->leftChild()); + checkAstTypeAsString(ast->rightChild()); + } +} + TEST(Generator, coverage) { static const std::string EMPTY_STRING; @@ -373,6 +384,7 @@ TEST(Generator, coverage) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ODE, analyserModel->type()); + EXPECT_EQ("ODE", analyserModel->typeAsString()); EXPECT_EQ(size_t(1), analyserModel->stateCount()); EXPECT_EQ(size_t(203), analyserModel->variableCount()); @@ -389,6 +401,10 @@ TEST(Generator, coverage) EXPECT_NE(nullptr, analyserModel->equation(0)->variable()); EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); + for (const auto &equation : analyserModel->equations()) { + checkAstTypeAsString(equation->ast()); + } + auto generator = libcellml::Generator::create(); EXPECT_EQ(nullptr, analyserModel->voi()->initialisingVariable()); diff --git a/tests/generator/generator.cpp b/tests/generator/generator.cpp index 49325a628c..bbe4ba8073 100644 --- a/tests/generator/generator.cpp +++ b/tests/generator/generator.cpp @@ -56,6 +56,7 @@ TEST(Generator, algebraicEqnComputedVarOnRhs) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ALGEBRAIC, analyserModel->type()); + EXPECT_EQ("ALGEBRAIC", analyserModel->typeAsString()); EXPECT_EQ(size_t(0), analyserModel->stateCount()); EXPECT_EQ(size_t(2), analyserModel->variableCount()); @@ -68,6 +69,9 @@ TEST(Generator, algebraicEqnComputedVarOnRhs) EXPECT_NE(nullptr, analyserModel->equation(0)); EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); + EXPECT_EQ(libcellml::AnalyserEquation::Type::TRUE_CONSTANT, analyserModel->equation(0)->type()); + EXPECT_EQ("TRUE_CONSTANT", analyserModel->equation(0)->typeAsString()); + auto generator = libcellml::Generator::create(); generator->setModel(analyserModel); @@ -160,6 +164,15 @@ TEST(Generator, algebraicEqnConstVarOnRhs) EXPECT_NE(nullptr, analyserModel->equation(0)); EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); + EXPECT_EQ(libcellml::AnalyserVariable::Type::CONSTANT, analyserModel->variable(0)->type()); + EXPECT_EQ("CONSTANT", analyserModel->variable(0)->typeAsString()); + + EXPECT_EQ(libcellml::AnalyserVariable::Type::COMPUTED_CONSTANT, analyserModel->variable(1)->type()); + EXPECT_EQ("COMPUTED_CONSTANT", analyserModel->variable(1)->typeAsString()); + + EXPECT_EQ(libcellml::AnalyserEquation::Type::VARIABLE_BASED_CONSTANT, analyserModel->equation(0)->type()); + EXPECT_EQ("VARIABLE_BASED_CONSTANT", analyserModel->equation(0)->typeAsString()); + auto generator = libcellml::Generator::create(); generator->setModel(analyserModel); @@ -234,6 +247,7 @@ TEST(Generator, algebraicEqnDerivativeOnRhs) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ODE, analyserModel->type()); + EXPECT_EQ("ODE", analyserModel->typeAsString()); EXPECT_EQ(size_t(1), analyserModel->stateCount()); EXPECT_EQ(size_t(2), analyserModel->variableCount()); @@ -247,6 +261,21 @@ TEST(Generator, algebraicEqnDerivativeOnRhs) EXPECT_NE(nullptr, analyserModel->equation(0)); EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); + EXPECT_EQ(libcellml::AnalyserVariable::Type::VARIABLE_OF_INTEGRATION, analyserModel->voi()->type()); + EXPECT_EQ("VARIABLE_OF_INTEGRATION", analyserModel->voi()->typeAsString()); + + EXPECT_EQ(libcellml::AnalyserVariable::Type::STATE, analyserModel->state(0)->type()); + EXPECT_EQ("STATE", analyserModel->state(0)->typeAsString()); + + EXPECT_EQ(libcellml::AnalyserVariable::Type::ALGEBRAIC, analyserModel->variable(1)->type()); + EXPECT_EQ("ALGEBRAIC", analyserModel->variable(1)->typeAsString()); + + EXPECT_EQ(libcellml::AnalyserEquation::Type::RATE, analyserModel->equation(0)->type()); + EXPECT_EQ("RATE", analyserModel->equation(0)->typeAsString()); + + EXPECT_EQ(libcellml::AnalyserEquation::Type::ALGEBRAIC, analyserModel->equation(2)->type()); + EXPECT_EQ("ALGEBRAIC", analyserModel->equation(2)->typeAsString()); + auto generator = libcellml::Generator::create(); generator->setModel(analyserModel); @@ -1357,6 +1386,12 @@ TEST(Generator, cellGeometryModelWithExternalVariables) EXPECT_NE(nullptr, analyserModel->equation(0)); EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); + EXPECT_EQ(libcellml::AnalyserVariable::Type::EXTERNAL, analyserModel->variable(0)->type()); + EXPECT_EQ("EXTERNAL", analyserModel->variable(0)->typeAsString()); + + EXPECT_EQ(libcellml::AnalyserEquation::Type::EXTERNAL, analyserModel->equation(0)->type()); + EXPECT_EQ("EXTERNAL", analyserModel->equation(0)->typeAsString()); + auto generator = libcellml::Generator::create(); generator->setModel(analyserModel); From 572894803759b36e22dbae19e43d41471a79075a Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 21 Feb 2023 13:16:24 +1300 Subject: [PATCH 03/13] Cleaned up our use of some mappings. --- src/analyser.cpp | 1 + src/analyserexternalvariable.cpp | 3 +- src/annotator.cpp | 20 +------ src/enums.cpp | 34 ++++++------ src/generator.cpp | 1 + src/importer.cpp | 1 + src/issue.cpp | 11 ++-- src/printer.cpp | 1 + src/units.cpp | 90 +++++++++++++++++++++++--------- src/units_p.h | 67 +----------------------- src/utilities.cpp | 23 ++++++++ src/utilities.h | 26 --------- src/validator.cpp | 4 +- src/variable.cpp | 8 ++- 14 files changed, 123 insertions(+), 167 deletions(-) diff --git a/src/analyser.cpp b/src/analyser.cpp index 8971363e93..f3068ada32 100644 --- a/src/analyser.cpp +++ b/src/analyser.cpp @@ -34,6 +34,7 @@ limitations under the License. #include "analysermodel_p.h" #include "analyservariable_p.h" #include "anycellmlelement_p.h" +#include "commonutils.h" #include "generator_p.h" #include "issue_p.h" #include "logger_p.h" diff --git a/src/analyserexternalvariable.cpp b/src/analyserexternalvariable.cpp index 7af76a2b70..14db69a398 100644 --- a/src/analyserexternalvariable.cpp +++ b/src/analyserexternalvariable.cpp @@ -16,9 +16,8 @@ limitations under the License. #include "libcellml/analyserexternalvariable.h" -#include "libcellml/component.h" - #include "analyserexternalvariable_p.h" +#include "commonutils.h" #include "utilities.h" namespace libcellml { diff --git a/src/annotator.cpp b/src/annotator.cpp index 37ffd9f385..1f619186ed 100644 --- a/src/annotator.cpp +++ b/src/annotator.cpp @@ -23,40 +23,22 @@ limitations under the License. #include "libcellml/component.h" #include "libcellml/importsource.h" #include "libcellml/model.h" -#include "libcellml/namedentity.h" -#include "libcellml/printer.h" #include "libcellml/reset.h" #include "libcellml/types.h" #include "libcellml/units.h" #include "libcellml/variable.h" #include "anycellmlelement_p.h" +#include "commonutils.h" #include "internaltypes.h" #include "issue_p.h" #include "logger_p.h" -#include "namespaces.h" #include "utilities.h" namespace libcellml { using ItemList = std::multimap; -static const std::map typeToString = { - {CellmlElementType::COMPONENT, "component"}, - {CellmlElementType::COMPONENT_REF, "component_ref"}, - {CellmlElementType::CONNECTION, "connection"}, - {CellmlElementType::ENCAPSULATION, "encapsulation"}, - {CellmlElementType::IMPORT, "import"}, - {CellmlElementType::MAP_VARIABLES, "map_variables"}, - {CellmlElementType::MODEL, "model"}, - {CellmlElementType::RESET, "reset"}, - {CellmlElementType::RESET_VALUE, "reset_value"}, - {CellmlElementType::TEST_VALUE, "test_value"}, - {CellmlElementType::UNDEFINED, "undefined"}, - {CellmlElementType::UNIT, "unit"}, - {CellmlElementType::UNITS, "units"}, - {CellmlElementType::VARIABLE, "variable"}}; - /** * @brief The Annotator::AnnotatorImpl class. * diff --git a/src/enums.cpp b/src/enums.cpp index d55992ddb4..007ef106a7 100644 --- a/src/enums.cpp +++ b/src/enums.cpp @@ -20,25 +20,25 @@ limitations under the License. namespace libcellml { -static const std::map cellmlElementTypeToString = { - {CellmlElementType::COMPONENT, "component"}, - {CellmlElementType::COMPONENT_REF, "component_ref"}, - {CellmlElementType::CONNECTION, "connection"}, - {CellmlElementType::ENCAPSULATION, "encapsulation"}, - {CellmlElementType::IMPORT, "import"}, - {CellmlElementType::MATH, "math"}, - {CellmlElementType::MAP_VARIABLES, "map_variables"}, - {CellmlElementType::MODEL, "model"}, - {CellmlElementType::RESET, "reset"}, - {CellmlElementType::RESET_VALUE, "reset_value"}, - {CellmlElementType::TEST_VALUE, "test_value"}, - {CellmlElementType::UNDEFINED, "undefined"}, - {CellmlElementType::UNIT, "unit"}, - {CellmlElementType::UNITS, "units"}, - {CellmlElementType::VARIABLE, "variable"}}; - std::string cellmlElementTypeAsString(CellmlElementType value) { + static const std::map cellmlElementTypeToString = { + {CellmlElementType::COMPONENT, "component"}, + {CellmlElementType::COMPONENT_REF, "component_ref"}, + {CellmlElementType::CONNECTION, "connection"}, + {CellmlElementType::ENCAPSULATION, "encapsulation"}, + {CellmlElementType::IMPORT, "import"}, + {CellmlElementType::MATH, "math"}, + {CellmlElementType::MAP_VARIABLES, "map_variables"}, + {CellmlElementType::MODEL, "model"}, + {CellmlElementType::RESET, "reset"}, + {CellmlElementType::RESET_VALUE, "reset_value"}, + {CellmlElementType::TEST_VALUE, "test_value"}, + {CellmlElementType::UNDEFINED, "undefined"}, + {CellmlElementType::UNIT, "unit"}, + {CellmlElementType::UNITS, "units"}, + {CellmlElementType::VARIABLE, "variable"}}; + return cellmlElementTypeToString.at(value); } diff --git a/src/generator.cpp b/src/generator.cpp index e6df5039a2..198473da85 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -27,6 +27,7 @@ limitations under the License. #include "libcellml/units.h" #include "libcellml/version.h" +#include "commonutils.h" #include "generator_p.h" #include "generatorprofilesha1values.h" #include "generatorprofiletools.h" diff --git a/src/importer.cpp b/src/importer.cpp index 9bcb140da1..f85d53f0f1 100644 --- a/src/importer.cpp +++ b/src/importer.cpp @@ -32,6 +32,7 @@ limitations under the License. #include "libcellml/variable.h" #include "anycellmlelement_p.h" +#include "commonutils.h" #include "issue_p.h" #include "logger_p.h" #include "utilities.h" diff --git a/src/issue.cpp b/src/issue.cpp index f192e1dbd8..54c9133aa5 100644 --- a/src/issue.cpp +++ b/src/issue.cpp @@ -16,7 +16,6 @@ limitations under the License. #include "libcellml/issue.h" -#include "anycellmlelement_p.h" #include "issue_p.h" #include "utilities.h" @@ -201,18 +200,18 @@ static const std::map> ruleToInfo std::string Issue::referenceHeading() const { - return ruleToInformation.find(referenceRule())->second[1]; + return ruleToInformation.at(referenceRule())[1]; } std::string Issue::url() const { - auto search = ruleToInformation.find(referenceRule()); + auto search = ruleToInformation.at(referenceRule()); - if (search->second[1].empty()) { - return search->second[2] + "?issue=" + search->second[0]; + if (search[1].empty()) { + return search[2] + "?issue=" + search[0]; } - return search->second[2] + search->second[3] + ".html?issue=" + search->second[0]; + return search[2] + search[3] + ".html?issue=" + search[0]; } } // namespace libcellml diff --git a/src/printer.cpp b/src/printer.cpp index 76de3e5b19..905d0c498c 100644 --- a/src/printer.cpp +++ b/src/printer.cpp @@ -33,6 +33,7 @@ limitations under the License. #include "libcellml/variable.h" #include "anycellmlelement_p.h" +#include "commonutils.h" #include "internaltypes.h" #include "issue_p.h" #include "logger_p.h" diff --git a/src/units.cpp b/src/units.cpp index b88d42ea34..12bc7bad19 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -30,11 +30,67 @@ limitations under the License. #include #include +#include "commonutils.h" #include "units_p.h" #include "utilities.h" namespace libcellml { +static const std::map prefixToString = { + {Units::Prefix::ATTO, "atto"}, + {Units::Prefix::CENTI, "centi"}, + {Units::Prefix::DECA, "deca"}, + {Units::Prefix::DECI, "deci"}, + {Units::Prefix::EXA, "exa"}, + {Units::Prefix::FEMTO, "femto"}, + {Units::Prefix::GIGA, "giga"}, + {Units::Prefix::HECTO, "hecto"}, + {Units::Prefix::KILO, "kilo"}, + {Units::Prefix::MEGA, "mega"}, + {Units::Prefix::MICRO, "micro"}, + {Units::Prefix::MILLI, "milli"}, + {Units::Prefix::NANO, "nano"}, + {Units::Prefix::PETA, "peta"}, + {Units::Prefix::PICO, "pico"}, + {Units::Prefix::TERA, "tera"}, + {Units::Prefix::YOCTO, "yocto"}, + {Units::Prefix::YOTTA, "yotta"}, + {Units::Prefix::ZEPTO, "zepto"}, + {Units::Prefix::ZETTA, "zetta"}}; + +static const std::map standardUnitToString = { + {Units::StandardUnit::AMPERE, "ampere"}, + {Units::StandardUnit::BECQUEREL, "becquerel"}, + {Units::StandardUnit::CANDELA, "candela"}, + {Units::StandardUnit::COULOMB, "coulomb"}, + {Units::StandardUnit::DIMENSIONLESS, "dimensionless"}, + {Units::StandardUnit::FARAD, "farad"}, + {Units::StandardUnit::GRAM, "gram"}, + {Units::StandardUnit::GRAY, "gray"}, + {Units::StandardUnit::HENRY, "henry"}, + {Units::StandardUnit::HERTZ, "hertz"}, + {Units::StandardUnit::JOULE, "joule"}, + {Units::StandardUnit::KATAL, "katal"}, + {Units::StandardUnit::KELVIN, "kelvin"}, + {Units::StandardUnit::KILOGRAM, "kilogram"}, + {Units::StandardUnit::LITRE, "litre"}, + {Units::StandardUnit::LUMEN, "lumen"}, + {Units::StandardUnit::LUX, "lux"}, + {Units::StandardUnit::METRE, "metre"}, + {Units::StandardUnit::MOLE, "mole"}, + {Units::StandardUnit::NEWTON, "newton"}, + {Units::StandardUnit::OHM, "ohm"}, + {Units::StandardUnit::PASCAL, "pascal"}, + {Units::StandardUnit::RADIAN, "radian"}, + {Units::StandardUnit::SECOND, "second"}, + {Units::StandardUnit::SIEMENS, "siemens"}, + {Units::StandardUnit::SIEVERT, "sievert"}, + {Units::StandardUnit::STERADIAN, "steradian"}, + {Units::StandardUnit::TESLA, "tesla"}, + {Units::StandardUnit::VOLT, "volt"}, + {Units::StandardUnit::WATT, "watt"}, + {Units::StandardUnit::WEBER, "weber"}}; + std::vector::const_iterator Units::UnitsImpl::findUnit(const std::string &reference) const { return std::find_if(mUnitDefinitions.begin(), mUnitDefinitions.end(), @@ -326,16 +382,13 @@ void Units::addUnit(const std::string &reference, const std::string &prefix, dou void Units::addUnit(const std::string &reference, Prefix prefix, double exponent, double multiplier, const std::string &id) { - auto search = prefixToString.find(prefix); - const std::string prefixString = search->second; - addUnit(reference, prefixString, exponent, multiplier, id); + addUnit(reference, prefixToString.at(prefix), exponent, multiplier, id); } void Units::addUnit(const std::string &reference, int prefix, double exponent, double multiplier, const std::string &id) { - const std::string prefixString = convertToString(prefix); - addUnit(reference, prefixString, exponent, multiplier, id); + addUnit(reference, convertToString(prefix), exponent, multiplier, id); } void Units::addUnit(const std::string &reference, double exponent, const std::string &id) @@ -351,51 +404,41 @@ void Units::addUnit(const std::string &reference) void Units::addUnit(StandardUnit standardUnit, const std::string &prefix, double exponent, double multiplier, const std::string &id) { - const std::string reference = standardUnitToString.find(standardUnit)->second; - addUnit(reference, prefix, exponent, multiplier, id); + addUnit(standardUnitToString.at(standardUnit), prefix, exponent, multiplier, id); } void Units::addUnit(StandardUnit standardUnit, Prefix prefix, double exponent, double multiplier, const std::string &id) { - const std::string reference = standardUnitToString.find(standardUnit)->second; - const std::string prefixString = prefixToString.find(prefix)->second; - addUnit(reference, prefixString, exponent, multiplier, id); + addUnit(standardUnitToString.at(standardUnit), prefixToString.at(prefix), exponent, multiplier, id); } void Units::addUnit(StandardUnit standardUnit, int prefix, double exponent, double multiplier, const std::string &id) { - const std::string reference = standardUnitToString.find(standardUnit)->second; - const std::string prefixString = convertToString(prefix); - addUnit(reference, prefixString, exponent, multiplier, id); + addUnit(standardUnitToString.at(standardUnit), convertToString(prefix), exponent, multiplier, id); } void Units::addUnit(StandardUnit standardUnit, double exponent, const std::string &id) { - const std::string reference = standardUnitToString.find(standardUnit)->second; - addUnit(reference, "0", exponent, 1.0, id); + addUnit(standardUnitToString.at(standardUnit), "0", exponent, 1.0, id); } void Units::addUnit(StandardUnit standardUnit) { - const std::string reference = standardUnitToString.find(standardUnit)->second; - addUnit(reference, "0", 1.0, 1.0, ""); + addUnit(standardUnitToString.at(standardUnit), "0", 1.0, 1.0, ""); } void Units::unitAttributes(StandardUnit standardUnit, std::string &prefix, double &exponent, double &multiplier, std::string &id) const { std::string dummyReference; - const std::string reference = standardUnitToString.find(standardUnit)->second; - auto result = pFunc()->findUnit(reference); - unitAttributes(size_t(result - pFunc()->mUnitDefinitions.begin()), dummyReference, prefix, exponent, multiplier, id); + unitAttributes(size_t(pFunc()->findUnit(standardUnitToString.at(standardUnit)) - pFunc()->mUnitDefinitions.begin()), dummyReference, prefix, exponent, multiplier, id); } void Units::unitAttributes(const std::string &reference, std::string &prefix, double &exponent, double &multiplier, std::string &id) const { std::string dummyReference; - auto result = pFunc()->findUnit(reference); - unitAttributes(size_t(result - pFunc()->mUnitDefinitions.begin()), dummyReference, prefix, exponent, multiplier, id); + unitAttributes(size_t(pFunc()->findUnit(reference) - pFunc()->mUnitDefinitions.begin()), dummyReference, prefix, exponent, multiplier, id); } void Units::unitAttributes(size_t index, std::string &reference, std::string &prefix, double &exponent, double &multiplier, std::string &id) const @@ -543,8 +586,7 @@ using UnitsMap = std::map; void updateUnitsMapWithStandardUnit(const std::string &name, UnitsMap &unitsMap, double exp) { - auto unitsListIter = standardUnitsList.find(name); - for (const auto &baseUnitsComponent : unitsListIter->second) { + for (const auto &baseUnitsComponent : standardUnitsList.at(name)) { auto unitsMapIter = unitsMap.find(baseUnitsComponent.first); if (unitsMapIter == unitsMap.end()) { unitsMap.emplace(baseUnitsComponent.first, 0.0); diff --git a/src/units_p.h b/src/units_p.h index 45f5cf9e3b..b04917d41a 100644 --- a/src/units_p.h +++ b/src/units_p.h @@ -18,76 +18,11 @@ limitations under the License. #include "libcellml/units.h" +#include "internaltypes.h" #include "namedentity_p.h" -#include "utilities.h" namespace libcellml { -/** - * @brief Map Prefix to their string forms. - * - * An internal map used to convert a Prefix into its string form. - */ -static const std::map prefixToString = { - {Units::Prefix::ATTO, "atto"}, - {Units::Prefix::CENTI, "centi"}, - {Units::Prefix::DECA, "deca"}, - {Units::Prefix::DECI, "deci"}, - {Units::Prefix::EXA, "exa"}, - {Units::Prefix::FEMTO, "femto"}, - {Units::Prefix::GIGA, "giga"}, - {Units::Prefix::HECTO, "hecto"}, - {Units::Prefix::KILO, "kilo"}, - {Units::Prefix::MEGA, "mega"}, - {Units::Prefix::MICRO, "micro"}, - {Units::Prefix::MILLI, "milli"}, - {Units::Prefix::NANO, "nano"}, - {Units::Prefix::PETA, "peta"}, - {Units::Prefix::PICO, "pico"}, - {Units::Prefix::TERA, "tera"}, - {Units::Prefix::YOCTO, "yocto"}, - {Units::Prefix::YOTTA, "yotta"}, - {Units::Prefix::ZEPTO, "zepto"}, - {Units::Prefix::ZETTA, "zetta"}}; - -/** - * @brief Map StandardUnit to their string forms. - * - * An internal map used to convert a standard unit into its string form. - */ -static const std::map standardUnitToString = { - {Units::StandardUnit::AMPERE, "ampere"}, - {Units::StandardUnit::BECQUEREL, "becquerel"}, - {Units::StandardUnit::CANDELA, "candela"}, - {Units::StandardUnit::COULOMB, "coulomb"}, - {Units::StandardUnit::DIMENSIONLESS, "dimensionless"}, - {Units::StandardUnit::FARAD, "farad"}, - {Units::StandardUnit::GRAM, "gram"}, - {Units::StandardUnit::GRAY, "gray"}, - {Units::StandardUnit::HENRY, "henry"}, - {Units::StandardUnit::HERTZ, "hertz"}, - {Units::StandardUnit::JOULE, "joule"}, - {Units::StandardUnit::KATAL, "katal"}, - {Units::StandardUnit::KELVIN, "kelvin"}, - {Units::StandardUnit::KILOGRAM, "kilogram"}, - {Units::StandardUnit::LITRE, "litre"}, - {Units::StandardUnit::LUMEN, "lumen"}, - {Units::StandardUnit::LUX, "lux"}, - {Units::StandardUnit::METRE, "metre"}, - {Units::StandardUnit::MOLE, "mole"}, - {Units::StandardUnit::NEWTON, "newton"}, - {Units::StandardUnit::OHM, "ohm"}, - {Units::StandardUnit::PASCAL, "pascal"}, - {Units::StandardUnit::RADIAN, "radian"}, - {Units::StandardUnit::SECOND, "second"}, - {Units::StandardUnit::SIEMENS, "siemens"}, - {Units::StandardUnit::SIEVERT, "sievert"}, - {Units::StandardUnit::STERADIAN, "steradian"}, - {Units::StandardUnit::TESLA, "tesla"}, - {Units::StandardUnit::VOLT, "volt"}, - {Units::StandardUnit::WATT, "watt"}, - {Units::StandardUnit::WEBER, "weber"}}; - /** * @brief The UnitDefinition struct. * diff --git a/src/utilities.cpp b/src/utilities.cpp index b53ca2c501..d5949d3433 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -34,11 +34,34 @@ limitations under the License. #include "libcellml/units.h" #include "libcellml/variable.h" +#include "commonutils.h" #include "xmldoc.h" #include "xmlutils.h" namespace libcellml { +static const std::map standardPrefixList = { + {"yotta", 24}, + {"zetta", 21}, + {"exa", 18}, + {"peta", 15}, + {"tera", 12}, + {"giga", 9}, + {"mega", 6}, + {"kilo", 3}, + {"hecto", 2}, + {"deca", 1}, + {"deci", -1}, + {"centi", -2}, + {"milli", -3}, + {"micro", -6}, + {"nano", -9}, + {"pico", -12}, + {"femto", -15}, + {"atto", -18}, + {"zepto", -21}, + {"yocto", -24}}; + double convertToDouble(const std::string &in, bool *ok) { double out = 0.0; diff --git a/src/utilities.h b/src/utilities.h index 737adfe5a2..d08390e6d0 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -25,7 +25,6 @@ limitations under the License. #include "libcellml/types.h" #include "libcellml/variable.h" -#include "commonutils.h" #include "internaltypes.h" namespace libcellml { @@ -123,31 +122,6 @@ static const std::map standardMultiplierList = { {"watt", 0.0}, {"weber", 0.0}}; -/** - * Map connecting prefix strings to their exponent (eg: "kilo" -> 10^3). - */ -static const std::map standardPrefixList = { - {"yotta", 24}, - {"zetta", 21}, - {"exa", 18}, - {"peta", 15}, - {"tera", 12}, - {"giga", 9}, - {"mega", 6}, - {"kilo", 3}, - {"hecto", 2}, - {"deca", 1}, - {"deci", -1}, - {"centi", -2}, - {"milli", -3}, - {"micro", -6}, - {"nano", -9}, - {"pico", -12}, - {"femto", -15}, - {"atto", -18}, - {"zepto", -21}, - {"yocto", -24}}; - /** * List of MathML elements supported by CellML. */ diff --git a/src/validator.cpp b/src/validator.cpp index 9783e00b18..7d47465958 100644 --- a/src/validator.cpp +++ b/src/validator.cpp @@ -32,6 +32,7 @@ limitations under the License. #include "libcellml/variable.h" #include "anycellmlelement_p.h" +#include "commonutils.h" #include "issue_p.h" #include "logger_p.h" #include "namespaces.h" @@ -1662,8 +1663,7 @@ bool reachableEquivalence(const VariablePtr &variable1, const VariablePtr &varia bool interfaceTypeIsCompatible(Variable::InterfaceType interfaceTypeMinimumRequired, const std::string &interfaceTypeCompatibleWith) { - std::string interfaceTypeMinimumRequiredString = interfaceTypeToString.find(interfaceTypeMinimumRequired)->second; - return interfaceTypeCompatibleWith.find(interfaceTypeMinimumRequiredString) != std::string::npos; + return interfaceTypeCompatibleWith.find(interfaceTypeToString.at(interfaceTypeMinimumRequired)) != std::string::npos; } void Validator::ValidatorImpl::validateVariableInterface(const VariablePtr &variable, VariableMap &alreadyReported) diff --git a/src/variable.cpp b/src/variable.cpp index b51e962768..66c1dcee8e 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -360,9 +360,7 @@ void Variable::setInterfaceType(const std::string &interfaceType) void Variable::setInterfaceType(Variable::InterfaceType interfaceType) { - auto search = interfaceTypeToString.find(interfaceType); - const std::string interfaceTypeString = search->second; - setInterfaceType(interfaceTypeString); + setInterfaceType(interfaceTypeToString.at(interfaceType)); } std::string Variable::interfaceType() const @@ -380,12 +378,12 @@ bool Variable::hasInterfaceType(InterfaceType interfaceType) const if (interfaceType == Variable::InterfaceType::NONE && pFunc()->mInterfaceType.empty()) { return true; } - return pFunc()->mInterfaceType == interfaceTypeToString.find(interfaceType)->second; + return pFunc()->mInterfaceType == interfaceTypeToString.at(interfaceType); } bool Variable::permitsInterfaceType(InterfaceType interfaceType) const { - std::string testString = interfaceTypeToString.find(interfaceType)->second; + std::string testString = interfaceTypeToString.at(interfaceType); if (testString == "none") { return true; From 088ca988ef67fdd3a2f4c238f8760bb9dcc79338 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 21 Feb 2023 13:24:53 +1300 Subject: [PATCH 04/13] Analyser/generator: use std::map for our `xxxAsString()` methods. --- src/analyserequation.cpp | 27 +-- src/analyserequationast.cpp | 331 ++++++++---------------------------- src/analysermodel.cpp | 37 ++-- src/analyservariable.cpp | 32 +--- src/generatorprofile.cpp | 10 +- 5 files changed, 103 insertions(+), 334 deletions(-) diff --git a/src/analyserequation.cpp b/src/analyserequation.cpp index fbd0224d5e..288b291b8c 100644 --- a/src/analyserequation.cpp +++ b/src/analyserequation.cpp @@ -70,25 +70,14 @@ AnalyserEquation::Type AnalyserEquation::type() const std::string AnalyserEquation::typeAsString() const { - if (mPimpl->mType == Type::TRUE_CONSTANT) { - return "TRUE_CONSTANT"; - } - - if (mPimpl->mType == Type::VARIABLE_BASED_CONSTANT) { - return "VARIABLE_BASED_CONSTANT"; - } - - if (mPimpl->mType == Type::RATE) { - return "RATE"; - } - - if (mPimpl->mType == Type::ALGEBRAIC) { - return "ALGEBRAIC"; - } - - // mPimpl->mType == Type::EXTERNAL. - - return "EXTERNAL"; + static const std::map typeToString = { + {Type::TRUE_CONSTANT, "TRUE_CONSTANT"}, + {Type::VARIABLE_BASED_CONSTANT, "VARIABLE_BASED_CONSTANT"}, + {Type::RATE, "RATE"}, + {Type::ALGEBRAIC, "ALGEBRAIC"}, + {Type::EXTERNAL, "EXTERNAL"}}; + + return typeToString.at(mPimpl->mType); } AnalyserEquationAstPtr AnalyserEquation::ast() const diff --git a/src/analyserequationast.cpp b/src/analyserequationast.cpp index 5d135c45fb..21915337a4 100644 --- a/src/analyserequationast.cpp +++ b/src/analyserequationast.cpp @@ -18,6 +18,10 @@ limitations under the License. #include "analyserequationast_p.h" +#ifdef NAN +# undef NAN +#endif + namespace libcellml { void AnalyserEquationAst::AnalyserEquationAstImpl::populate(AnalyserEquationAst::Type type, @@ -67,265 +71,74 @@ AnalyserEquationAst::Type AnalyserEquationAst::type() const std::string AnalyserEquationAst::typeAsString() const { - if (mPimpl->mType == Type::ASSIGNMENT) { - return "ASSIGNMENT"; - } - - if (mPimpl->mType == Type::EQ) { - return "EQ"; - } - - if (mPimpl->mType == Type::NEQ) { - return "NEQ"; - } - - if (mPimpl->mType == Type::LT) { - return "LT"; - } - - if (mPimpl->mType == Type::LEQ) { - return "LEQ"; - } - - if (mPimpl->mType == Type::GT) { - return "GT"; - } - - if (mPimpl->mType == Type::GEQ) { - return "GEQ"; - } - - if (mPimpl->mType == Type::AND) { - return "AND"; - } - - if (mPimpl->mType == Type::OR) { - return "OR"; - } - - if (mPimpl->mType == Type::XOR) { - return "XOR"; - } - - if (mPimpl->mType == Type::NOT) { - return "NOT"; - } - - if (mPimpl->mType == Type::PLUS) { - return "PLUS"; - } - - if (mPimpl->mType == Type::MINUS) { - return "MINUS"; - } - - if (mPimpl->mType == Type::TIMES) { - return "TIMES"; - } - - if (mPimpl->mType == Type::DIVIDE) { - return "DIVIDE"; - } - - if (mPimpl->mType == Type::POWER) { - return "POWER"; - } - - if (mPimpl->mType == Type::ROOT) { - return "ROOT"; - } - - if (mPimpl->mType == Type::ABS) { - return "ABS"; - } - - if (mPimpl->mType == Type::EXP) { - return "EXP"; - } - - if (mPimpl->mType == Type::LN) { - return "LN"; - } - - if (mPimpl->mType == Type::LOG) { - return "LOG"; - } - - if (mPimpl->mType == Type::CEILING) { - return "CEILING"; - } - - if (mPimpl->mType == Type::FLOOR) { - return "FLOOR"; - } - - if (mPimpl->mType == Type::MIN) { - return "MIN"; - } - - if (mPimpl->mType == Type::MAX) { - return "MAX"; - } - - if (mPimpl->mType == Type::REM) { - return "REM"; - } - - if (mPimpl->mType == Type::DIFF) { - return "DIFF"; - } - - if (mPimpl->mType == Type::SIN) { - return "SIN"; - } - - if (mPimpl->mType == Type::COS) { - return "COS"; - } - - if (mPimpl->mType == Type::TAN) { - return "TAN"; - } - - if (mPimpl->mType == Type::SEC) { - return "SEC"; - } - - if (mPimpl->mType == Type::CSC) { - return "CSC"; - } - - if (mPimpl->mType == Type::COT) { - return "COT"; - } - - if (mPimpl->mType == Type::SINH) { - return "SINH"; - } - - if (mPimpl->mType == Type::COSH) { - return "COSH"; - } - - if (mPimpl->mType == Type::TANH) { - return "TANH"; - } - - if (mPimpl->mType == Type::SECH) { - return "SECH"; - } - - if (mPimpl->mType == Type::CSCH) { - return "CSCH"; - } - - if (mPimpl->mType == Type::COTH) { - return "COTH"; - } - - if (mPimpl->mType == Type::ASIN) { - return "ASIN"; - } - - if (mPimpl->mType == Type::ACOS) { - return "ACOS"; - } - - if (mPimpl->mType == Type::ATAN) { - return "ATAN"; - } - - if (mPimpl->mType == Type::ASEC) { - return "ASEC"; - } - - if (mPimpl->mType == Type::ACSC) { - return "ACSC"; - } - - if (mPimpl->mType == Type::ACOT) { - return "ACOT"; - } - - if (mPimpl->mType == Type::ASINH) { - return "ASINH"; - } - - if (mPimpl->mType == Type::ACOSH) { - return "ACOSH"; - } - - if (mPimpl->mType == Type::ATANH) { - return "ATANH"; - } - - if (mPimpl->mType == Type::ASECH) { - return "ASECH"; - } - - if (mPimpl->mType == Type::ACSCH) { - return "ACSCH"; - } - - if (mPimpl->mType == Type::ACOTH) { - return "ACOTH"; - } - - if (mPimpl->mType == Type::PIECEWISE) { - return "PIECEWISE"; - } - - if (mPimpl->mType == Type::PIECE) { - return "PIECE"; - } - - if (mPimpl->mType == Type::OTHERWISE) { - return "OTHERWISE"; - } - - if (mPimpl->mType == Type::CI) { - return "CI"; - } - - if (mPimpl->mType == Type::CN) { - return "CN"; - } - - if (mPimpl->mType == Type::DEGREE) { - return "DEGREE"; - } - - if (mPimpl->mType == Type::LOGBASE) { - return "LOGBASE"; - } - - if (mPimpl->mType == Type::BVAR) { - return "BVAR"; - } - - if (mPimpl->mType == Type::TRUE) { - return "TRUE"; - } - - if (mPimpl->mType == Type::FALSE) { - return "FALSE"; - } - - if (mPimpl->mType == Type::E) { - return "E"; - } - - if (mPimpl->mType == Type::PI) { - return "PI"; - } - - if (mPimpl->mType == Type::INF) { - return "INF"; - } - - // mPimpl->mType == Type::NAN: - - return "NAN"; + static const std::map typeToString = { + {Type::ASSIGNMENT, "ASSIGNMENT"}, + {Type::EQ, "EQ"}, + {Type::NEQ, "NEQ"}, + {Type::LT, "LT"}, + {Type::LEQ, "LEQ"}, + {Type::GT, "GT"}, + {Type::GEQ, "GEQ"}, + {Type::AND, "AND"}, + {Type::OR, "OR"}, + {Type::XOR, "XOR"}, + {Type::NOT, "NOT"}, + {Type::PLUS, "PLUS"}, + {Type::MINUS, "MINUS"}, + {Type::TIMES, "TIMES"}, + {Type::DIVIDE, "DIVIDE"}, + {Type::POWER, "POWER"}, + {Type::ROOT, "ROOT"}, + {Type::ABS, "ABS"}, + {Type::EXP, "EXP"}, + {Type::LN, "LN"}, + {Type::LOG, "LOG"}, + {Type::CEILING, "CEILING"}, + {Type::FLOOR, "FLOOR"}, + {Type::MIN, "MIN"}, + {Type::MAX, "MAX"}, + {Type::REM, "REM"}, + {Type::DIFF, "DIFF"}, + {Type::SIN, "SIN"}, + {Type::COS, "COS"}, + {Type::TAN, "TAN"}, + {Type::SEC, "SEC"}, + {Type::CSC, "CSC"}, + {Type::COT, "COT"}, + {Type::SINH, "SINH"}, + {Type::COSH, "COSH"}, + {Type::TANH, "TANH"}, + {Type::SECH, "SECH"}, + {Type::CSCH, "CSCH"}, + {Type::COTH, "COTH"}, + {Type::ASIN, "ASIN"}, + {Type::ACOS, "ACOS"}, + {Type::ATAN, "ATAN"}, + {Type::ASEC, "ASEC"}, + {Type::ACSC, "ACSC"}, + {Type::ACOT, "ACOT"}, + {Type::ASINH, "ASINH"}, + {Type::ACOSH, "ACOSH"}, + {Type::ATANH, "ATANH"}, + {Type::ASECH, "ASECH"}, + {Type::ACSCH, "ACSCH"}, + {Type::ACOTH, "ACOTH"}, + {Type::PIECEWISE, "PIECEWISE"}, + {Type::PIECE, "PIECE"}, + {Type::OTHERWISE, "OTHERWISE"}, + {Type::CI, "CI"}, + {Type::CN, "CN"}, + {Type::DEGREE, "DEGREE"}, + {Type::LOGBASE, "LOGBASE"}, + {Type::BVAR, "BVAR"}, + {Type::TRUE, "TRUE"}, + {Type::FALSE, "FALSE"}, + {Type::E, "E"}, + {Type::PI, "PI"}, + {Type::INF, "INF"}, + {Type::NAN, "NAN"}}; + + return typeToString.at(mPimpl->mType); } void AnalyserEquationAst::setType(Type type) diff --git a/src/analysermodel.cpp b/src/analysermodel.cpp index 194ec13b61..d824c76440 100644 --- a/src/analysermodel.cpp +++ b/src/analysermodel.cpp @@ -49,33 +49,16 @@ AnalyserModel::Type AnalyserModel::type() const std::string AnalyserModel::typeAsString() const { - if (mPimpl->mType == Type::UNKNOWN) { - return "UNKNOWN"; - } - - if (mPimpl->mType == Type::ALGEBRAIC) { - return "ALGEBRAIC"; - } - - if (mPimpl->mType == Type::ODE) { - return "ODE"; - } - - if (mPimpl->mType == Type::INVALID) { - return "INVALID"; - } - - if (mPimpl->mType == Type::UNDERCONSTRAINED) { - return "UNDERCONSTRAINED"; - } - - if (mPimpl->mType == Type::OVERCONSTRAINED) { - return "OVERCONSTRAINED"; - } - - // mPimpl->mType == Type::UNSUITABLY_CONSTRAINED. - - return "UNSUITABLY_CONSTRAINED"; + static const std::map typeToString = { + {Type::UNKNOWN, "UNKNOWN"}, + {Type::ALGEBRAIC, "ALGEBRAIC"}, + {Type::ODE, "ODE"}, + {Type::INVALID, "INVALID"}, + {Type::UNDERCONSTRAINED, "UNDERCONSTRAINED"}, + {Type::OVERCONSTRAINED, "OVERCONSTRAINED"}, + {Type::UNSUITABLY_CONSTRAINED, "UNSUITABLY_CONSTRAINED"}}; + + return typeToString.at(mPimpl->mType); } bool AnalyserModel::hasExternalVariables() const diff --git a/src/analyservariable.cpp b/src/analyservariable.cpp index 24b00335a8..9330f46167 100644 --- a/src/analyservariable.cpp +++ b/src/analyservariable.cpp @@ -55,29 +55,15 @@ AnalyserVariable::Type AnalyserVariable::type() const std::string AnalyserVariable::typeAsString() const { - if (mPimpl->mType == Type::VARIABLE_OF_INTEGRATION) { - return "VARIABLE_OF_INTEGRATION"; - } - - if (mPimpl->mType == Type::STATE) { - return "STATE"; - } - - if (mPimpl->mType == Type::CONSTANT) { - return "CONSTANT"; - } - - if (mPimpl->mType == Type::COMPUTED_CONSTANT) { - return "COMPUTED_CONSTANT"; - } - - if (mPimpl->mType == Type::ALGEBRAIC) { - return "ALGEBRAIC"; - } - - // mPimpl->mType == Type::EXTERNAL. - - return "EXTERNAL"; + static const std::map typeToString = { + {Type::VARIABLE_OF_INTEGRATION, "VARIABLE_OF_INTEGRATION"}, + {Type::STATE, "STATE"}, + {Type::CONSTANT, "CONSTANT"}, + {Type::COMPUTED_CONSTANT, "COMPUTED_CONSTANT"}, + {Type::ALGEBRAIC, "ALGEBRAIC"}, + {Type::EXTERNAL, "EXTERNAL"}}; + + return typeToString.at(mPimpl->mType); } size_t AnalyserVariable::index() const diff --git a/src/generatorprofile.cpp b/src/generatorprofile.cpp index 9161f6def2..d2d6f7a59c 100644 --- a/src/generatorprofile.cpp +++ b/src/generatorprofile.cpp @@ -1040,13 +1040,11 @@ GeneratorProfile::Profile GeneratorProfile::profile() const std::string GeneratorProfile::profileAsString() const { - if (mPimpl->mProfile == Profile::C) { - return "C"; - } - - // mPimpl->mProfile == Profile::PYTHON. + static const std::map profileToString = { + {Profile::C, "C"}, + {Profile::PYTHON, "PYTHON"}}; - return "PYTHON"; + return profileToString.at(mPimpl->mProfile); } void GeneratorProfile::setProfile(Profile profile) From 467f25ff9f465a75c045323a063a82a3d53062b3 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 21 Feb 2023 14:35:27 +1300 Subject: [PATCH 05/13] Analyser/generator: replaced our `xxxAsString()` methods with static ones. --- src/analyserequation.cpp | 4 +-- src/analyserequationast.cpp | 4 +-- src/analysermodel.cpp | 4 +-- src/analyservariable.cpp | 4 +-- src/api/libcellml/analyserequation.h | 10 ++++--- src/api/libcellml/analyserequationast.h | 10 ++++--- src/api/libcellml/analysermodel.h | 10 ++++--- src/api/libcellml/analyservariable.h | 10 ++++--- src/api/libcellml/generatorprofile.h | 10 ++++--- src/bindings/javascript/analyserequation.cpp | 2 +- .../javascript/analyserequationast.cpp | 2 +- src/bindings/javascript/analysermodel.cpp | 2 +- src/bindings/javascript/analyservariable.cpp | 2 +- src/bindings/javascript/generatorprofile.cpp | 2 +- src/generatorprofile.cpp | 4 +-- tests/analyser/analyser.cpp | 8 +++--- .../javascript/analyserequation.test.js | 2 +- .../javascript/analyserequationast.test.js | 4 +-- .../bindings/javascript/analysermodel.test.js | 2 +- .../javascript/analyservariable.test.js | 2 +- .../javascript/generatorprofile.test.js | 4 +-- tests/bindings/python/test_analyser.py | 10 +++---- .../bindings/python/test_generator_profile.py | 4 +-- tests/coverage/coverage.cpp | 6 ++--- tests/generator/generator.cpp | 26 +++++++++---------- tests/generator/generatorprofile.cpp | 4 +-- 26 files changed, 81 insertions(+), 71 deletions(-) diff --git a/src/analyserequation.cpp b/src/analyserequation.cpp index 288b291b8c..a3d70c1cae 100644 --- a/src/analyserequation.cpp +++ b/src/analyserequation.cpp @@ -68,7 +68,7 @@ AnalyserEquation::Type AnalyserEquation::type() const return mPimpl->mType; } -std::string AnalyserEquation::typeAsString() const +std::string AnalyserEquation::typeAsString(Type type) { static const std::map typeToString = { {Type::TRUE_CONSTANT, "TRUE_CONSTANT"}, @@ -77,7 +77,7 @@ std::string AnalyserEquation::typeAsString() const {Type::ALGEBRAIC, "ALGEBRAIC"}, {Type::EXTERNAL, "EXTERNAL"}}; - return typeToString.at(mPimpl->mType); + return typeToString.at(type); } AnalyserEquationAstPtr AnalyserEquation::ast() const diff --git a/src/analyserequationast.cpp b/src/analyserequationast.cpp index 21915337a4..d0bb4bc3dd 100644 --- a/src/analyserequationast.cpp +++ b/src/analyserequationast.cpp @@ -69,7 +69,7 @@ AnalyserEquationAst::Type AnalyserEquationAst::type() const return mPimpl->mType; } -std::string AnalyserEquationAst::typeAsString() const +std::string AnalyserEquationAst::typeAsString(Type type) { static const std::map typeToString = { {Type::ASSIGNMENT, "ASSIGNMENT"}, @@ -138,7 +138,7 @@ std::string AnalyserEquationAst::typeAsString() const {Type::INF, "INF"}, {Type::NAN, "NAN"}}; - return typeToString.at(mPimpl->mType); + return typeToString.at(type); } void AnalyserEquationAst::setType(Type type) diff --git a/src/analysermodel.cpp b/src/analysermodel.cpp index d824c76440..2ddd2c9300 100644 --- a/src/analysermodel.cpp +++ b/src/analysermodel.cpp @@ -47,7 +47,7 @@ AnalyserModel::Type AnalyserModel::type() const return mPimpl->mType; } -std::string AnalyserModel::typeAsString() const +std::string AnalyserModel::typeAsString(Type type) { static const std::map typeToString = { {Type::UNKNOWN, "UNKNOWN"}, @@ -58,7 +58,7 @@ std::string AnalyserModel::typeAsString() const {Type::OVERCONSTRAINED, "OVERCONSTRAINED"}, {Type::UNSUITABLY_CONSTRAINED, "UNSUITABLY_CONSTRAINED"}}; - return typeToString.at(mPimpl->mType); + return typeToString.at(type); } bool AnalyserModel::hasExternalVariables() const diff --git a/src/analyservariable.cpp b/src/analyservariable.cpp index 9330f46167..8423636ea0 100644 --- a/src/analyservariable.cpp +++ b/src/analyservariable.cpp @@ -53,7 +53,7 @@ AnalyserVariable::Type AnalyserVariable::type() const return mPimpl->mType; } -std::string AnalyserVariable::typeAsString() const +std::string AnalyserVariable::typeAsString(Type type) { static const std::map typeToString = { {Type::VARIABLE_OF_INTEGRATION, "VARIABLE_OF_INTEGRATION"}, @@ -63,7 +63,7 @@ std::string AnalyserVariable::typeAsString() const {Type::ALGEBRAIC, "ALGEBRAIC"}, {Type::EXTERNAL, "EXTERNAL"}}; - return typeToString.at(mPimpl->mType); + return typeToString.at(type); } size_t AnalyserVariable::index() const diff --git a/src/api/libcellml/analyserequation.h b/src/api/libcellml/analyserequation.h index d59e7660ed..fad5ac47d7 100644 --- a/src/api/libcellml/analyserequation.h +++ b/src/api/libcellml/analyserequation.h @@ -62,13 +62,15 @@ class LIBCELLML_EXPORT AnalyserEquation Type type() const; /** - * @brief Get the @c Type as a string of this @c AnalyserEquation. + * @brief Get the string version of a @c Type. * - * Return the @c Type as a string of this @c AnalyserEquation. + * Return the string version of a @c Type. * - * @return The @c Type as a string. + * @param type The type for which we want the string version. + * + * @return The string version of the @c Type. */ - std::string typeAsString() const; + static std::string typeAsString(Type type); /** * @brief Get the @c AnalyserEquationAst for this @c AnalyserEquation. diff --git a/src/api/libcellml/analyserequationast.h b/src/api/libcellml/analyserequationast.h index ba65e25363..922d49dfc5 100644 --- a/src/api/libcellml/analyserequationast.h +++ b/src/api/libcellml/analyserequationast.h @@ -167,13 +167,15 @@ class LIBCELLML_EXPORT AnalyserEquationAst Type type() const; /** - * @brief Get the @c Type as a string of this @ref AnalyserEquationAst. + * @brief Get the string version of a @c Type. * - * Return the @c Type as a string of this @ref AnalyserEquationAst. + * Return the string version of a @c Type. * - * @return The @c Type as a string. + * @param type The type for which we want the string version. + * + * @return The string version of the @c Type. */ - std::string typeAsString() const; + static std::string typeAsString(Type type); /** * @brief Set the type of this @ref AnalyserEquationAst. diff --git a/src/api/libcellml/analysermodel.h b/src/api/libcellml/analysermodel.h index 0256613efc..8ae4ae499f 100644 --- a/src/api/libcellml/analysermodel.h +++ b/src/api/libcellml/analysermodel.h @@ -76,13 +76,15 @@ class LIBCELLML_EXPORT AnalyserModel Type type() const; /** - * @brief Get the @c Type as a string of the @c AnalyserModel. + * @brief Get the string version of a @c Type. * - * Return the @c Type as a string of the @c AnalyserModel. + * Return the string version of a @c Type. * - * @return The @c Type as a string. + * @param type The type for which we want the string version. + * + * @return The string version of the @c Type. */ - std::string typeAsString() const; + static std::string typeAsString(Type type); /** * @brief Test to determine if this @c AnalyserModel has external variables. diff --git a/src/api/libcellml/analyservariable.h b/src/api/libcellml/analyservariable.h index e25ce95159..ce9fe197ca 100644 --- a/src/api/libcellml/analyservariable.h +++ b/src/api/libcellml/analyservariable.h @@ -64,13 +64,15 @@ class LIBCELLML_EXPORT AnalyserVariable Type type() const; /** - * @brief Get the @c Type as a string of this @c AnalyserVariable. + * @brief Get the string version of a @c Type. * - * Return the @c Type as a string of this @c AnalyserVariable. + * Return the string version of a @c Type. * - * @return The @c Type as a string. + * @param type The type for which we want the string version. + * + * @return The string version of the @c Type. */ - std::string typeAsString() const; + static std::string typeAsString(Type type); /** * @brief Get the index of this @c AnalyserVariable. diff --git a/src/api/libcellml/generatorprofile.h b/src/api/libcellml/generatorprofile.h index 32575e8928..1369f8e372 100644 --- a/src/api/libcellml/generatorprofile.h +++ b/src/api/libcellml/generatorprofile.h @@ -73,13 +73,15 @@ class LIBCELLML_EXPORT GeneratorProfile Profile profile() const; /** - * @brief Get the @c Profile as a string for this @c GeneratorProfile. + * @brief Get the string version of a @c Profile. * - * Return the @c Profile as a string for this @c GeneratorProfile. + * Return the string version of a @c Profile. * - * @return The @c Profile as a string for this @c GeneratorProfile. + * @param profile The profile for which we want the string version. + * + * @return The string version of the @c Profile. */ - std::string profileAsString() const; + static std::string profileAsString(Profile profile); /** * @brief Set the @c Profile. diff --git a/src/bindings/javascript/analyserequation.cpp b/src/bindings/javascript/analyserequation.cpp index ffc32e756e..e4a9537f9c 100644 --- a/src/bindings/javascript/analyserequation.cpp +++ b/src/bindings/javascript/analyserequation.cpp @@ -34,7 +34,7 @@ EMSCRIPTEN_BINDINGS(libcellml_analyserequation) class_("AnalyserEquation") .smart_ptr>("AnalyserEquation") .function("type", &libcellml::AnalyserEquation::type) - .function("typeAsString", &libcellml::AnalyserEquation::typeAsString) + .class_function("typeAsString", &libcellml::AnalyserEquation::typeAsString) .function("ast", &libcellml::AnalyserEquation::ast) .function("dependencies", &libcellml::AnalyserEquation::dependencies) .function("isStateRateBased", &libcellml::AnalyserEquation::isStateRateBased) diff --git a/src/bindings/javascript/analyserequationast.cpp b/src/bindings/javascript/analyserequationast.cpp index 7ddb54b75a..51aae2040d 100644 --- a/src/bindings/javascript/analyserequationast.cpp +++ b/src/bindings/javascript/analyserequationast.cpp @@ -94,7 +94,7 @@ EMSCRIPTEN_BINDINGS(libcellml_analyserequationast) class_("AnalyserEquationAst") .smart_ptr_constructor("AnalyserEquationAst", &libcellml::AnalyserEquationAst::create) .function("type", &libcellml::AnalyserEquationAst::type) - .function("typeAsString", &libcellml::AnalyserEquationAst::typeAsString) + .class_function("typeAsString", &libcellml::AnalyserEquationAst::typeAsString) .function("setType", &libcellml::AnalyserEquationAst::setType) .function("value", &libcellml::AnalyserEquationAst::value) .function("setValue", &libcellml::AnalyserEquationAst::setValue) diff --git a/src/bindings/javascript/analysermodel.cpp b/src/bindings/javascript/analysermodel.cpp index d0591ec908..1b3501e386 100644 --- a/src/bindings/javascript/analysermodel.cpp +++ b/src/bindings/javascript/analysermodel.cpp @@ -37,7 +37,7 @@ EMSCRIPTEN_BINDINGS(libcellml_analysermodel) .smart_ptr>("AnalyserModel") .function("isValid", &libcellml::AnalyserModel::isValid) .function("type", &libcellml::AnalyserModel::type) - .function("typeAsString", &libcellml::AnalyserModel::typeAsString) + .class_function("typeAsString", &libcellml::AnalyserModel::typeAsString) .function("hasExternalVariables", &libcellml::AnalyserModel::hasExternalVariables) .function("voi", &libcellml::AnalyserModel::voi) .function("stateCount", &libcellml::AnalyserModel::stateCount) diff --git a/src/bindings/javascript/analyservariable.cpp b/src/bindings/javascript/analyservariable.cpp index 052781ee32..222be42b9d 100644 --- a/src/bindings/javascript/analyservariable.cpp +++ b/src/bindings/javascript/analyservariable.cpp @@ -35,7 +35,7 @@ EMSCRIPTEN_BINDINGS(libcellml_analyservariable) class_("AnalyserVariable") .smart_ptr>("AnalyserVariable") .function("type", &libcellml::AnalyserVariable::type) - .function("typeAsString", &libcellml::AnalyserVariable::typeAsString) + .class_function("typeAsString", &libcellml::AnalyserVariable::typeAsString) .function("index", &libcellml::AnalyserVariable::index) .function("initialisingVariable", &libcellml::AnalyserVariable::initialisingVariable) .function("variable", &libcellml::AnalyserVariable::variable) diff --git a/src/bindings/javascript/generatorprofile.cpp b/src/bindings/javascript/generatorprofile.cpp index ed95c84d16..c642470e3a 100644 --- a/src/bindings/javascript/generatorprofile.cpp +++ b/src/bindings/javascript/generatorprofile.cpp @@ -31,7 +31,7 @@ EMSCRIPTEN_BINDINGS(libcellml_generatorprofile) class_("GeneratorProfile") .smart_ptr_constructor("GeneratorProfile", &libcellml::GeneratorProfile::create) .function("profile", &libcellml::GeneratorProfile::profile) - .function("profileAsString", &libcellml::GeneratorProfile::profileAsString) + .class_function("profileAsString", &libcellml::GeneratorProfile::profileAsString) .function("setProfile", &libcellml::GeneratorProfile::setProfile) .function("hasInterface", &libcellml::GeneratorProfile::hasInterface) .function("setHasInterface", &libcellml::GeneratorProfile::setHasInterface) diff --git a/src/generatorprofile.cpp b/src/generatorprofile.cpp index d2d6f7a59c..b480bc8822 100644 --- a/src/generatorprofile.cpp +++ b/src/generatorprofile.cpp @@ -1038,13 +1038,13 @@ GeneratorProfile::Profile GeneratorProfile::profile() const return mPimpl->mProfile; } -std::string GeneratorProfile::profileAsString() const +std::string GeneratorProfile::profileAsString(Profile profile) { static const std::map profileToString = { {Profile::C, "C"}, {Profile::PYTHON, "PYTHON"}}; - return profileToString.at(mPimpl->mProfile); + return profileToString.at(profile); } void GeneratorProfile::setProfile(Profile profile) diff --git a/tests/analyser/analyser.cpp b/tests/analyser/analyser.cpp index 4043aa62c2..10b2b6094f 100644 --- a/tests/analyser/analyser.cpp +++ b/tests/analyser/analyser.cpp @@ -81,7 +81,7 @@ TEST(Analyser, initialisedVariableOfIntegration) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::INVALID, analyser->model()->type()); - EXPECT_EQ("INVALID", analyser->model()->typeAsString()); + EXPECT_EQ("INVALID", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); } TEST(Analyser, initialisedVariableOfIntegrationInNonFirstComponent) @@ -287,7 +287,7 @@ TEST(Analyser, nonInitialisedState) EXPECT_EQ(expectedVariableName, analyser->issue(0)->item()->variable()->name()); EXPECT_EQ(libcellml::AnalyserModel::Type::UNDERCONSTRAINED, analyser->model()->type()); - EXPECT_EQ("UNDERCONSTRAINED", analyser->model()->typeAsString()); + EXPECT_EQ("UNDERCONSTRAINED", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); } TEST(Analyser, underconstrained) @@ -338,7 +338,7 @@ TEST(Analyser, overconstrainedOneVariable) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::OVERCONSTRAINED, analyser->model()->type()); - EXPECT_EQ("OVERCONSTRAINED", analyser->model()->typeAsString()); + EXPECT_EQ("OVERCONSTRAINED", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); } TEST(Analyser, overconstrainedTwoVariables) @@ -426,7 +426,7 @@ TEST(Analyser, unsuitablyConstrained) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::UNSUITABLY_CONSTRAINED, analyser->model()->type()); - EXPECT_EQ("UNSUITABLY_CONSTRAINED", analyser->model()->typeAsString()); + EXPECT_EQ("UNSUITABLY_CONSTRAINED", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); } TEST(Analyser, addSameExternalVariable) diff --git a/tests/bindings/javascript/analyserequation.test.js b/tests/bindings/javascript/analyserequation.test.js index 384ae985eb..f91eb79957 100644 --- a/tests/bindings/javascript/analyserequation.test.js +++ b/tests/bindings/javascript/analyserequation.test.js @@ -44,7 +44,7 @@ describe("Analyser Equation tests", () => { }); test('Checking Analyser Equation type.', () => { expect(eqn.type().value).toBe(libcellml.AnalyserEquation.Type.RATE.value) - expect(eqn.typeAsString()).toBe("RATE") + expect(libcellml.AnalyserEquation.typeAsString(eqn.type())).toBe("RATE") }); test('Checking Analyser Equation isStateRateBased.', () => { expect(eqn.isStateRateBased()).toBe(false) diff --git a/tests/bindings/javascript/analyserequationast.test.js b/tests/bindings/javascript/analyserequationast.test.js index 1de433d0ed..c09aeaf832 100644 --- a/tests/bindings/javascript/analyserequationast.test.js +++ b/tests/bindings/javascript/analyserequationast.test.js @@ -26,14 +26,14 @@ describe("Analyser Equation AST tests", () => { const aea = new libcellml.AnalyserEquationAst() expect(aea.type().value).toBe(libcellml.AnalyserEquationAst.Type.ASSIGNMENT.value) - expect(aea.typeAsString()).toBe("ASSIGNMENT") + expect(libcellml.AnalyserEquationAst.typeAsString(aea.type())).toBe("ASSIGNMENT") expect(aea.type()).toStrictEqual(libcellml.AnalyserEquationAst.Type.ASSIGNMENT) expect(aea.type()).not.toStrictEqual(libcellml.AnalyserEquationAst.Type.OTHERWISE) aea.setType(libcellml.AnalyserEquationAst.Type.OTHERWISE) expect(aea.type().value).toBe(libcellml.AnalyserEquationAst.Type.OTHERWISE.value) - expect(aea.typeAsString()).toBe("OTHERWISE") + expect(libcellml.AnalyserEquationAst.typeAsString(aea.type())).toBe("OTHERWISE") }); test('Checking Analyser Equation AST value.', () => { const aea = new libcellml.AnalyserEquationAst() diff --git a/tests/bindings/javascript/analysermodel.test.js b/tests/bindings/javascript/analysermodel.test.js index 67dfebbffb..278ccc7e68 100644 --- a/tests/bindings/javascript/analysermodel.test.js +++ b/tests/bindings/javascript/analysermodel.test.js @@ -39,7 +39,7 @@ describe("Analyser Model tests", () => { }); test('Checking Analyser Model type.', () => { expect(am.type().value).toBe(libcellml.AnalyserModel.Type.ODE.value) - expect(am.typeAsString()).toBe("ODE") + expect(libcellml.AnalyserModel.typeAsString(am.type())).toBe("ODE") }); test('Checking Analyser Model isValid.', () => { expect(am.isValid()).toBe(true) diff --git a/tests/bindings/javascript/analyservariable.test.js b/tests/bindings/javascript/analyservariable.test.js index 5acba5a325..cdf473c3b0 100644 --- a/tests/bindings/javascript/analyservariable.test.js +++ b/tests/bindings/javascript/analyservariable.test.js @@ -42,7 +42,7 @@ describe("Analyser Variable tests", () => { test('Checking Analyser Variable type.', () => { const av = am.variable(5) expect(av.type().value).toBe(libcellml.AnalyserVariable.Type.ALGEBRAIC.value) - expect(av.typeAsString()).toBe("ALGEBRAIC") + expect(libcellml.AnalyserVariable.typeAsString(av.type())).toBe("ALGEBRAIC") }); test('Checking Analyser Variable index.', () => { const av = am.variable(7) diff --git a/tests/bindings/javascript/generatorprofile.test.js b/tests/bindings/javascript/generatorprofile.test.js index d530c2e289..7db8e3388f 100644 --- a/tests/bindings/javascript/generatorprofile.test.js +++ b/tests/bindings/javascript/generatorprofile.test.js @@ -24,11 +24,11 @@ describe("GeneratorProfile tests", () => { test("Checking GeneratorProfile.profile.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) expect(x.profile()).toBe(libcellml.GeneratorProfile.Profile.C) - expect(x.profileAsString()).toBe("C") + expect(libcellml.GeneratorProfile.profileAsString(x.profile())).toBe("C") x.setProfile(libcellml.GeneratorProfile.Profile.PYTHON) expect(x.profile()).toBe(libcellml.GeneratorProfile.Profile.PYTHON) - expect(x.profileAsString()).toBe("PYTHON") + expect(libcellml.GeneratorProfile.profileAsString(x.profile())).toBe("PYTHON") }); test("Checking GeneratorProfile.hasInterface.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) diff --git a/tests/bindings/python/test_analyser.py b/tests/bindings/python/test_analyser.py index a3f4b3d3f4..8328fc4eec 100644 --- a/tests/bindings/python/test_analyser.py +++ b/tests/bindings/python/test_analyser.py @@ -40,7 +40,7 @@ def test_analyse_model(self): self.assertEqual(0, a.errorCount()) self.assertEqual(AnalyserModel.Type.UNKNOWN, a.model().type()) - self.assertEqual("UNKNOWN", a.model().typeAsString()) + self.assertEqual("UNKNOWN", AnalyserModel.typeAsString(a.model().type())) def test_coverage(self): from libcellml import Analyser @@ -150,7 +150,7 @@ def test_coverage(self): av = am.variable(3) self.assertEqual(AnalyserVariable.Type.CONSTANT, av.type()) - self.assertEqual("CONSTANT", av.typeAsString()) + self.assertEqual("CONSTANT", AnalyserVariable.typeAsString(av.type())) self.assertEqual(3, av.index()) self.assertIsNotNone(av.initialisingVariable()) self.assertIsNotNone(av.variable()) @@ -161,7 +161,7 @@ def test_coverage(self): ae = am.equation(3) self.assertEqual(AnalyserEquation.Type.RATE, ae.type()) - self.assertEqual("RATE", ae.typeAsString()) + self.assertEqual("RATE", AnalyserEquation.typeAsString(ae.type())) self.assertIsNotNone(ae.ast()) self.assertIsNotNone(ae.dependencies()) self.assertTrue(ae.isStateRateBased()) @@ -172,7 +172,7 @@ def test_coverage(self): aea = ae.ast() self.assertEqual(AnalyserEquationAst.Type.ASSIGNMENT, aea.type()) - self.assertEqual("ASSIGNMENT", aea.typeAsString()) + self.assertEqual("ASSIGNMENT", AnalyserEquationAst.typeAsString(aea.type())) self.assertEqual('', aea.value()) self.assertIsNone(aea.variable()) self.assertIsNone(aea.parent()) @@ -188,7 +188,7 @@ def test_coverage(self): aea.setRightChild(None) self.assertEqual(AnalyserEquationAst.Type.EQ, aea.type()) - self.assertEqual("EQ", aea.typeAsString()) + self.assertEqual("EQ", AnalyserEquationAst.typeAsString(aea.type())) self.assertEqual(AnalyserTestCase.VALUE, aea.value()) self.assertIsNotNone(aea.variable()) self.assertIsNotNone(aea.parent()) diff --git a/tests/bindings/python/test_generator_profile.py b/tests/bindings/python/test_generator_profile.py index eb993666b1..c6219f1cc8 100644 --- a/tests/bindings/python/test_generator_profile.py +++ b/tests/bindings/python/test_generator_profile.py @@ -19,12 +19,12 @@ def test_generator_profile(self): # Create a default, i.e. C, profile. p = GeneratorProfile() self.assertEqual(GeneratorProfile.Profile.C, p.profile()) - self.assertEqual("C", p.profileAsString()) + self.assertEqual("C", GeneratorProfile.profileAsString(p.profile())) # Make the profile a Python profile. p.setProfile(GeneratorProfile.Profile.PYTHON) self.assertEqual(GeneratorProfile.Profile.PYTHON, p.profile()) - self.assertEqual("PYTHON", p.profileAsString()) + self.assertEqual("PYTHON", GeneratorProfile.profileAsString(p.profile())) # Create a Python profile. pp = GeneratorProfile(GeneratorProfile.Profile.PYTHON) diff --git a/tests/coverage/coverage.cpp b/tests/coverage/coverage.cpp index ed79f93a62..f0ae9f0182 100644 --- a/tests/coverage/coverage.cpp +++ b/tests/coverage/coverage.cpp @@ -279,7 +279,7 @@ TEST(Coverage, analyser) EXPECT_FALSE(analyserModel->isValid()); EXPECT_EQ(libcellml::AnalyserModel::Type::UNKNOWN, analyserModel->type()); - EXPECT_EQ("UNKNOWN", analyserModel->typeAsString()); + EXPECT_EQ("UNKNOWN", libcellml::AnalyserModel::typeAsString(analyserModel->type())); EXPECT_EQ(nullptr, analyserModel->voi()); @@ -359,7 +359,7 @@ TEST(Coverage, analyserExternalVariable) void checkAstTypeAsString(const libcellml::AnalyserEquationAstPtr &ast) { if (ast != nullptr) { - ast->typeAsString(); + libcellml::AnalyserEquationAst::typeAsString(ast->type()); checkAstTypeAsString(ast->leftChild()); checkAstTypeAsString(ast->rightChild()); @@ -384,7 +384,7 @@ TEST(Generator, coverage) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ODE, analyserModel->type()); - EXPECT_EQ("ODE", analyserModel->typeAsString()); + EXPECT_EQ("ODE", libcellml::AnalyserModel::typeAsString(analyserModel->type())); EXPECT_EQ(size_t(1), analyserModel->stateCount()); EXPECT_EQ(size_t(203), analyserModel->variableCount()); diff --git a/tests/generator/generator.cpp b/tests/generator/generator.cpp index bbe4ba8073..7e0f440f4e 100644 --- a/tests/generator/generator.cpp +++ b/tests/generator/generator.cpp @@ -56,7 +56,7 @@ TEST(Generator, algebraicEqnComputedVarOnRhs) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ALGEBRAIC, analyserModel->type()); - EXPECT_EQ("ALGEBRAIC", analyserModel->typeAsString()); + EXPECT_EQ("ALGEBRAIC", libcellml::AnalyserModel::typeAsString(analyserModel->type())); EXPECT_EQ(size_t(0), analyserModel->stateCount()); EXPECT_EQ(size_t(2), analyserModel->variableCount()); @@ -70,7 +70,7 @@ TEST(Generator, algebraicEqnComputedVarOnRhs) EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); EXPECT_EQ(libcellml::AnalyserEquation::Type::TRUE_CONSTANT, analyserModel->equation(0)->type()); - EXPECT_EQ("TRUE_CONSTANT", analyserModel->equation(0)->typeAsString()); + EXPECT_EQ("TRUE_CONSTANT", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); auto generator = libcellml::Generator::create(); @@ -165,13 +165,13 @@ TEST(Generator, algebraicEqnConstVarOnRhs) EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); EXPECT_EQ(libcellml::AnalyserVariable::Type::CONSTANT, analyserModel->variable(0)->type()); - EXPECT_EQ("CONSTANT", analyserModel->variable(0)->typeAsString()); + EXPECT_EQ("CONSTANT", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(0)->type())); EXPECT_EQ(libcellml::AnalyserVariable::Type::COMPUTED_CONSTANT, analyserModel->variable(1)->type()); - EXPECT_EQ("COMPUTED_CONSTANT", analyserModel->variable(1)->typeAsString()); + EXPECT_EQ("COMPUTED_CONSTANT", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(1)->type())); EXPECT_EQ(libcellml::AnalyserEquation::Type::VARIABLE_BASED_CONSTANT, analyserModel->equation(0)->type()); - EXPECT_EQ("VARIABLE_BASED_CONSTANT", analyserModel->equation(0)->typeAsString()); + EXPECT_EQ("VARIABLE_BASED_CONSTANT", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); auto generator = libcellml::Generator::create(); @@ -247,7 +247,7 @@ TEST(Generator, algebraicEqnDerivativeOnRhs) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ODE, analyserModel->type()); - EXPECT_EQ("ODE", analyserModel->typeAsString()); + EXPECT_EQ("ODE", libcellml::AnalyserModel::typeAsString(analyserModel->type())); EXPECT_EQ(size_t(1), analyserModel->stateCount()); EXPECT_EQ(size_t(2), analyserModel->variableCount()); @@ -262,19 +262,19 @@ TEST(Generator, algebraicEqnDerivativeOnRhs) EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); EXPECT_EQ(libcellml::AnalyserVariable::Type::VARIABLE_OF_INTEGRATION, analyserModel->voi()->type()); - EXPECT_EQ("VARIABLE_OF_INTEGRATION", analyserModel->voi()->typeAsString()); + EXPECT_EQ("VARIABLE_OF_INTEGRATION", libcellml::AnalyserVariable::typeAsString(analyserModel->voi()->type())); EXPECT_EQ(libcellml::AnalyserVariable::Type::STATE, analyserModel->state(0)->type()); - EXPECT_EQ("STATE", analyserModel->state(0)->typeAsString()); + EXPECT_EQ("STATE", libcellml::AnalyserVariable::typeAsString(analyserModel->state(0)->type())); EXPECT_EQ(libcellml::AnalyserVariable::Type::ALGEBRAIC, analyserModel->variable(1)->type()); - EXPECT_EQ("ALGEBRAIC", analyserModel->variable(1)->typeAsString()); + EXPECT_EQ("ALGEBRAIC", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(1)->type())); EXPECT_EQ(libcellml::AnalyserEquation::Type::RATE, analyserModel->equation(0)->type()); - EXPECT_EQ("RATE", analyserModel->equation(0)->typeAsString()); + EXPECT_EQ("RATE", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); EXPECT_EQ(libcellml::AnalyserEquation::Type::ALGEBRAIC, analyserModel->equation(2)->type()); - EXPECT_EQ("ALGEBRAIC", analyserModel->equation(2)->typeAsString()); + EXPECT_EQ("ALGEBRAIC", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(2)->type())); auto generator = libcellml::Generator::create(); @@ -1387,10 +1387,10 @@ TEST(Generator, cellGeometryModelWithExternalVariables) EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); EXPECT_EQ(libcellml::AnalyserVariable::Type::EXTERNAL, analyserModel->variable(0)->type()); - EXPECT_EQ("EXTERNAL", analyserModel->variable(0)->typeAsString()); + EXPECT_EQ("EXTERNAL", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(0)->type())); EXPECT_EQ(libcellml::AnalyserEquation::Type::EXTERNAL, analyserModel->equation(0)->type()); - EXPECT_EQ("EXTERNAL", analyserModel->equation(0)->typeAsString()); + EXPECT_EQ("EXTERNAL", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); auto generator = libcellml::Generator::create(); diff --git a/tests/generator/generatorprofile.cpp b/tests/generator/generatorprofile.cpp index dd872fb446..b965deaf0e 100644 --- a/tests/generator/generatorprofile.cpp +++ b/tests/generator/generatorprofile.cpp @@ -38,7 +38,7 @@ TEST(GeneratorProfile, defaultGeneralValues) libcellml::GeneratorProfilePtr generatorProfile = libcellml::GeneratorProfile::create(); EXPECT_EQ(libcellml::GeneratorProfile::Profile::C, generatorProfile->profile()); - EXPECT_EQ("C", generatorProfile->profileAsString()); + EXPECT_EQ("C", libcellml::GeneratorProfile::profileAsString(generatorProfile->profile())); EXPECT_EQ(true, generatorProfile->hasInterface()); } @@ -498,7 +498,7 @@ TEST(GeneratorProfile, generalSettings) generatorProfile->setHasInterface(falseValue); EXPECT_EQ(profile, generatorProfile->profile()); - EXPECT_EQ("PYTHON", generatorProfile->profileAsString()); + EXPECT_EQ("PYTHON", libcellml::GeneratorProfile::profileAsString(generatorProfile->profile())); EXPECT_EQ(falseValue, generatorProfile->hasInterface()); } From 15ebc22e497ce33da1f2df4e6226a7d4d8af0a61 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 21 Feb 2023 15:49:58 +1300 Subject: [PATCH 06/13] Analyser/generator: use lower case string for our class enum mappings. --- src/analyserequation.cpp | 10 +- src/analyserequationast.cpp | 130 +++++++++--------- src/analysermodel.cpp | 14 +- src/analyservariable.cpp | 12 +- src/generatorprofile.cpp | 4 +- tests/analyser/analyser.cpp | 8 +- .../javascript/analyserequation.test.js | 2 +- .../javascript/analyserequationast.test.js | 4 +- .../bindings/javascript/analysermodel.test.js | 2 +- .../javascript/analyservariable.test.js | 2 +- .../javascript/generatorprofile.test.js | 4 +- tests/bindings/python/test_analyser.py | 10 +- .../bindings/python/test_generator_profile.py | 4 +- tests/coverage/coverage.cpp | 4 +- tests/generator/generator.cpp | 26 ++-- tests/generator/generatorprofile.cpp | 4 +- 16 files changed, 120 insertions(+), 120 deletions(-) diff --git a/src/analyserequation.cpp b/src/analyserequation.cpp index a3d70c1cae..40d884d187 100644 --- a/src/analyserequation.cpp +++ b/src/analyserequation.cpp @@ -71,11 +71,11 @@ AnalyserEquation::Type AnalyserEquation::type() const std::string AnalyserEquation::typeAsString(Type type) { static const std::map typeToString = { - {Type::TRUE_CONSTANT, "TRUE_CONSTANT"}, - {Type::VARIABLE_BASED_CONSTANT, "VARIABLE_BASED_CONSTANT"}, - {Type::RATE, "RATE"}, - {Type::ALGEBRAIC, "ALGEBRAIC"}, - {Type::EXTERNAL, "EXTERNAL"}}; + {Type::TRUE_CONSTANT, "true_constant"}, + {Type::VARIABLE_BASED_CONSTANT, "variable_based_constant"}, + {Type::RATE, "rate"}, + {Type::ALGEBRAIC, "algebraic"}, + {Type::EXTERNAL, "external"}}; return typeToString.at(type); } diff --git a/src/analyserequationast.cpp b/src/analyserequationast.cpp index d0bb4bc3dd..21d70cc111 100644 --- a/src/analyserequationast.cpp +++ b/src/analyserequationast.cpp @@ -72,71 +72,71 @@ AnalyserEquationAst::Type AnalyserEquationAst::type() const std::string AnalyserEquationAst::typeAsString(Type type) { static const std::map typeToString = { - {Type::ASSIGNMENT, "ASSIGNMENT"}, - {Type::EQ, "EQ"}, - {Type::NEQ, "NEQ"}, - {Type::LT, "LT"}, - {Type::LEQ, "LEQ"}, - {Type::GT, "GT"}, - {Type::GEQ, "GEQ"}, - {Type::AND, "AND"}, - {Type::OR, "OR"}, - {Type::XOR, "XOR"}, - {Type::NOT, "NOT"}, - {Type::PLUS, "PLUS"}, - {Type::MINUS, "MINUS"}, - {Type::TIMES, "TIMES"}, - {Type::DIVIDE, "DIVIDE"}, - {Type::POWER, "POWER"}, - {Type::ROOT, "ROOT"}, - {Type::ABS, "ABS"}, - {Type::EXP, "EXP"}, - {Type::LN, "LN"}, - {Type::LOG, "LOG"}, - {Type::CEILING, "CEILING"}, - {Type::FLOOR, "FLOOR"}, - {Type::MIN, "MIN"}, - {Type::MAX, "MAX"}, - {Type::REM, "REM"}, - {Type::DIFF, "DIFF"}, - {Type::SIN, "SIN"}, - {Type::COS, "COS"}, - {Type::TAN, "TAN"}, - {Type::SEC, "SEC"}, - {Type::CSC, "CSC"}, - {Type::COT, "COT"}, - {Type::SINH, "SINH"}, - {Type::COSH, "COSH"}, - {Type::TANH, "TANH"}, - {Type::SECH, "SECH"}, - {Type::CSCH, "CSCH"}, - {Type::COTH, "COTH"}, - {Type::ASIN, "ASIN"}, - {Type::ACOS, "ACOS"}, - {Type::ATAN, "ATAN"}, - {Type::ASEC, "ASEC"}, - {Type::ACSC, "ACSC"}, - {Type::ACOT, "ACOT"}, - {Type::ASINH, "ASINH"}, - {Type::ACOSH, "ACOSH"}, - {Type::ATANH, "ATANH"}, - {Type::ASECH, "ASECH"}, - {Type::ACSCH, "ACSCH"}, - {Type::ACOTH, "ACOTH"}, - {Type::PIECEWISE, "PIECEWISE"}, - {Type::PIECE, "PIECE"}, - {Type::OTHERWISE, "OTHERWISE"}, - {Type::CI, "CI"}, - {Type::CN, "CN"}, - {Type::DEGREE, "DEGREE"}, - {Type::LOGBASE, "LOGBASE"}, - {Type::BVAR, "BVAR"}, - {Type::TRUE, "TRUE"}, - {Type::FALSE, "FALSE"}, - {Type::E, "E"}, - {Type::PI, "PI"}, - {Type::INF, "INF"}, - {Type::NAN, "NAN"}}; + {Type::ASSIGNMENT, "assignment"}, + {Type::EQ, "eq"}, + {Type::NEQ, "neq"}, + {Type::LT, "lt"}, + {Type::LEQ, "leq"}, + {Type::GT, "gt"}, + {Type::GEQ, "geq"}, + {Type::AND, "and"}, + {Type::OR, "or"}, + {Type::XOR, "xor"}, + {Type::NOT, "not"}, + {Type::PLUS, "plus"}, + {Type::MINUS, "minus"}, + {Type::TIMES, "times"}, + {Type::DIVIDE, "divide"}, + {Type::POWER, "power"}, + {Type::ROOT, "root"}, + {Type::ABS, "abs"}, + {Type::EXP, "exp"}, + {Type::LN, "ln"}, + {Type::LOG, "log"}, + {Type::CEILING, "ceiling"}, + {Type::FLOOR, "floor"}, + {Type::MIN, "min"}, + {Type::MAX, "max"}, + {Type::REM, "rem"}, + {Type::DIFF, "diff"}, + {Type::SIN, "sin"}, + {Type::COS, "cos"}, + {Type::TAN, "tan"}, + {Type::SEC, "sec"}, + {Type::CSC, "csc"}, + {Type::COT, "cot"}, + {Type::SINH, "sinh"}, + {Type::COSH, "cosh"}, + {Type::TANH, "tanh"}, + {Type::SECH, "sech"}, + {Type::CSCH, "csch"}, + {Type::COTH, "coth"}, + {Type::ASIN, "asin"}, + {Type::ACOS, "acos"}, + {Type::ATAN, "atan"}, + {Type::ASEC, "asec"}, + {Type::ACSC, "acsc"}, + {Type::ACOT, "acot"}, + {Type::ASINH, "asinh"}, + {Type::ACOSH, "acosh"}, + {Type::ATANH, "atanh"}, + {Type::ASECH, "asech"}, + {Type::ACSCH, "acsch"}, + {Type::ACOTH, "acoth"}, + {Type::PIECEWISE, "piecewise"}, + {Type::PIECE, "piece"}, + {Type::OTHERWISE, "otherwise"}, + {Type::CI, "ci"}, + {Type::CN, "cn"}, + {Type::DEGREE, "degree"}, + {Type::LOGBASE, "logbase"}, + {Type::BVAR, "bvar"}, + {Type::TRUE, "true"}, + {Type::FALSE, "false"}, + {Type::E, "e"}, + {Type::PI, "pi"}, + {Type::INF, "inf"}, + {Type::NAN, "nan"}}; return typeToString.at(type); } diff --git a/src/analysermodel.cpp b/src/analysermodel.cpp index 2ddd2c9300..c76047e532 100644 --- a/src/analysermodel.cpp +++ b/src/analysermodel.cpp @@ -50,13 +50,13 @@ AnalyserModel::Type AnalyserModel::type() const std::string AnalyserModel::typeAsString(Type type) { static const std::map typeToString = { - {Type::UNKNOWN, "UNKNOWN"}, - {Type::ALGEBRAIC, "ALGEBRAIC"}, - {Type::ODE, "ODE"}, - {Type::INVALID, "INVALID"}, - {Type::UNDERCONSTRAINED, "UNDERCONSTRAINED"}, - {Type::OVERCONSTRAINED, "OVERCONSTRAINED"}, - {Type::UNSUITABLY_CONSTRAINED, "UNSUITABLY_CONSTRAINED"}}; + {Type::UNKNOWN, "unknown"}, + {Type::ALGEBRAIC, "algebraic"}, + {Type::ODE, "ode"}, + {Type::INVALID, "invalid"}, + {Type::UNDERCONSTRAINED, "underconstrained"}, + {Type::OVERCONSTRAINED, "overconstrained"}, + {Type::UNSUITABLY_CONSTRAINED, "unsuitably_constrained"}}; return typeToString.at(type); } diff --git a/src/analyservariable.cpp b/src/analyservariable.cpp index 8423636ea0..34ec18e6ff 100644 --- a/src/analyservariable.cpp +++ b/src/analyservariable.cpp @@ -56,12 +56,12 @@ AnalyserVariable::Type AnalyserVariable::type() const std::string AnalyserVariable::typeAsString(Type type) { static const std::map typeToString = { - {Type::VARIABLE_OF_INTEGRATION, "VARIABLE_OF_INTEGRATION"}, - {Type::STATE, "STATE"}, - {Type::CONSTANT, "CONSTANT"}, - {Type::COMPUTED_CONSTANT, "COMPUTED_CONSTANT"}, - {Type::ALGEBRAIC, "ALGEBRAIC"}, - {Type::EXTERNAL, "EXTERNAL"}}; + {Type::VARIABLE_OF_INTEGRATION, "variable_of_integration"}, + {Type::STATE, "state"}, + {Type::CONSTANT, "constant"}, + {Type::COMPUTED_CONSTANT, "computed_constant"}, + {Type::ALGEBRAIC, "algebraic"}, + {Type::EXTERNAL, "external"}}; return typeToString.at(type); } diff --git a/src/generatorprofile.cpp b/src/generatorprofile.cpp index b480bc8822..39673039e4 100644 --- a/src/generatorprofile.cpp +++ b/src/generatorprofile.cpp @@ -1041,8 +1041,8 @@ GeneratorProfile::Profile GeneratorProfile::profile() const std::string GeneratorProfile::profileAsString(Profile profile) { static const std::map profileToString = { - {Profile::C, "C"}, - {Profile::PYTHON, "PYTHON"}}; + {Profile::C, "c"}, + {Profile::PYTHON, "python"}}; return profileToString.at(profile); } diff --git a/tests/analyser/analyser.cpp b/tests/analyser/analyser.cpp index 10b2b6094f..8563e47ef7 100644 --- a/tests/analyser/analyser.cpp +++ b/tests/analyser/analyser.cpp @@ -81,7 +81,7 @@ TEST(Analyser, initialisedVariableOfIntegration) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::INVALID, analyser->model()->type()); - EXPECT_EQ("INVALID", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); + EXPECT_EQ("invalid", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); } TEST(Analyser, initialisedVariableOfIntegrationInNonFirstComponent) @@ -287,7 +287,7 @@ TEST(Analyser, nonInitialisedState) EXPECT_EQ(expectedVariableName, analyser->issue(0)->item()->variable()->name()); EXPECT_EQ(libcellml::AnalyserModel::Type::UNDERCONSTRAINED, analyser->model()->type()); - EXPECT_EQ("UNDERCONSTRAINED", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); + EXPECT_EQ("underconstrained", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); } TEST(Analyser, underconstrained) @@ -338,7 +338,7 @@ TEST(Analyser, overconstrainedOneVariable) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::OVERCONSTRAINED, analyser->model()->type()); - EXPECT_EQ("OVERCONSTRAINED", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); + EXPECT_EQ("overconstrained", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); } TEST(Analyser, overconstrainedTwoVariables) @@ -426,7 +426,7 @@ TEST(Analyser, unsuitablyConstrained) analyser); EXPECT_EQ(libcellml::AnalyserModel::Type::UNSUITABLY_CONSTRAINED, analyser->model()->type()); - EXPECT_EQ("UNSUITABLY_CONSTRAINED", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); + EXPECT_EQ("unsuitably_constrained", libcellml::AnalyserModel::typeAsString(analyser->model()->type())); } TEST(Analyser, addSameExternalVariable) diff --git a/tests/bindings/javascript/analyserequation.test.js b/tests/bindings/javascript/analyserequation.test.js index f91eb79957..c3733a3c6e 100644 --- a/tests/bindings/javascript/analyserequation.test.js +++ b/tests/bindings/javascript/analyserequation.test.js @@ -44,7 +44,7 @@ describe("Analyser Equation tests", () => { }); test('Checking Analyser Equation type.', () => { expect(eqn.type().value).toBe(libcellml.AnalyserEquation.Type.RATE.value) - expect(libcellml.AnalyserEquation.typeAsString(eqn.type())).toBe("RATE") + expect(libcellml.AnalyserEquation.typeAsString(eqn.type())).toBe("rate") }); test('Checking Analyser Equation isStateRateBased.', () => { expect(eqn.isStateRateBased()).toBe(false) diff --git a/tests/bindings/javascript/analyserequationast.test.js b/tests/bindings/javascript/analyserequationast.test.js index c09aeaf832..6eb1a1f2be 100644 --- a/tests/bindings/javascript/analyserequationast.test.js +++ b/tests/bindings/javascript/analyserequationast.test.js @@ -26,14 +26,14 @@ describe("Analyser Equation AST tests", () => { const aea = new libcellml.AnalyserEquationAst() expect(aea.type().value).toBe(libcellml.AnalyserEquationAst.Type.ASSIGNMENT.value) - expect(libcellml.AnalyserEquationAst.typeAsString(aea.type())).toBe("ASSIGNMENT") + expect(libcellml.AnalyserEquationAst.typeAsString(aea.type())).toBe("assignment") expect(aea.type()).toStrictEqual(libcellml.AnalyserEquationAst.Type.ASSIGNMENT) expect(aea.type()).not.toStrictEqual(libcellml.AnalyserEquationAst.Type.OTHERWISE) aea.setType(libcellml.AnalyserEquationAst.Type.OTHERWISE) expect(aea.type().value).toBe(libcellml.AnalyserEquationAst.Type.OTHERWISE.value) - expect(libcellml.AnalyserEquationAst.typeAsString(aea.type())).toBe("OTHERWISE") + expect(libcellml.AnalyserEquationAst.typeAsString(aea.type())).toBe("otherwise") }); test('Checking Analyser Equation AST value.', () => { const aea = new libcellml.AnalyserEquationAst() diff --git a/tests/bindings/javascript/analysermodel.test.js b/tests/bindings/javascript/analysermodel.test.js index 278ccc7e68..62e1c6b082 100644 --- a/tests/bindings/javascript/analysermodel.test.js +++ b/tests/bindings/javascript/analysermodel.test.js @@ -39,7 +39,7 @@ describe("Analyser Model tests", () => { }); test('Checking Analyser Model type.', () => { expect(am.type().value).toBe(libcellml.AnalyserModel.Type.ODE.value) - expect(libcellml.AnalyserModel.typeAsString(am.type())).toBe("ODE") + expect(libcellml.AnalyserModel.typeAsString(am.type())).toBe("ode") }); test('Checking Analyser Model isValid.', () => { expect(am.isValid()).toBe(true) diff --git a/tests/bindings/javascript/analyservariable.test.js b/tests/bindings/javascript/analyservariable.test.js index cdf473c3b0..330667e158 100644 --- a/tests/bindings/javascript/analyservariable.test.js +++ b/tests/bindings/javascript/analyservariable.test.js @@ -42,7 +42,7 @@ describe("Analyser Variable tests", () => { test('Checking Analyser Variable type.', () => { const av = am.variable(5) expect(av.type().value).toBe(libcellml.AnalyserVariable.Type.ALGEBRAIC.value) - expect(libcellml.AnalyserVariable.typeAsString(av.type())).toBe("ALGEBRAIC") + expect(libcellml.AnalyserVariable.typeAsString(av.type())).toBe("algebraic") }); test('Checking Analyser Variable index.', () => { const av = am.variable(7) diff --git a/tests/bindings/javascript/generatorprofile.test.js b/tests/bindings/javascript/generatorprofile.test.js index 7db8e3388f..3e40b16f23 100644 --- a/tests/bindings/javascript/generatorprofile.test.js +++ b/tests/bindings/javascript/generatorprofile.test.js @@ -24,11 +24,11 @@ describe("GeneratorProfile tests", () => { test("Checking GeneratorProfile.profile.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) expect(x.profile()).toBe(libcellml.GeneratorProfile.Profile.C) - expect(libcellml.GeneratorProfile.profileAsString(x.profile())).toBe("C") + expect(libcellml.GeneratorProfile.profileAsString(x.profile())).toBe("c") x.setProfile(libcellml.GeneratorProfile.Profile.PYTHON) expect(x.profile()).toBe(libcellml.GeneratorProfile.Profile.PYTHON) - expect(libcellml.GeneratorProfile.profileAsString(x.profile())).toBe("PYTHON") + expect(libcellml.GeneratorProfile.profileAsString(x.profile())).toBe("python") }); test("Checking GeneratorProfile.hasInterface.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) diff --git a/tests/bindings/python/test_analyser.py b/tests/bindings/python/test_analyser.py index 8328fc4eec..68c11a6f60 100644 --- a/tests/bindings/python/test_analyser.py +++ b/tests/bindings/python/test_analyser.py @@ -40,7 +40,7 @@ def test_analyse_model(self): self.assertEqual(0, a.errorCount()) self.assertEqual(AnalyserModel.Type.UNKNOWN, a.model().type()) - self.assertEqual("UNKNOWN", AnalyserModel.typeAsString(a.model().type())) + self.assertEqual("unknown", AnalyserModel.typeAsString(a.model().type())) def test_coverage(self): from libcellml import Analyser @@ -150,7 +150,7 @@ def test_coverage(self): av = am.variable(3) self.assertEqual(AnalyserVariable.Type.CONSTANT, av.type()) - self.assertEqual("CONSTANT", AnalyserVariable.typeAsString(av.type())) + self.assertEqual("constant", AnalyserVariable.typeAsString(av.type())) self.assertEqual(3, av.index()) self.assertIsNotNone(av.initialisingVariable()) self.assertIsNotNone(av.variable()) @@ -161,7 +161,7 @@ def test_coverage(self): ae = am.equation(3) self.assertEqual(AnalyserEquation.Type.RATE, ae.type()) - self.assertEqual("RATE", AnalyserEquation.typeAsString(ae.type())) + self.assertEqual("rate", AnalyserEquation.typeAsString(ae.type())) self.assertIsNotNone(ae.ast()) self.assertIsNotNone(ae.dependencies()) self.assertTrue(ae.isStateRateBased()) @@ -172,7 +172,7 @@ def test_coverage(self): aea = ae.ast() self.assertEqual(AnalyserEquationAst.Type.ASSIGNMENT, aea.type()) - self.assertEqual("ASSIGNMENT", AnalyserEquationAst.typeAsString(aea.type())) + self.assertEqual("assignment", AnalyserEquationAst.typeAsString(aea.type())) self.assertEqual('', aea.value()) self.assertIsNone(aea.variable()) self.assertIsNone(aea.parent()) @@ -188,7 +188,7 @@ def test_coverage(self): aea.setRightChild(None) self.assertEqual(AnalyserEquationAst.Type.EQ, aea.type()) - self.assertEqual("EQ", AnalyserEquationAst.typeAsString(aea.type())) + self.assertEqual("eq", AnalyserEquationAst.typeAsString(aea.type())) self.assertEqual(AnalyserTestCase.VALUE, aea.value()) self.assertIsNotNone(aea.variable()) self.assertIsNotNone(aea.parent()) diff --git a/tests/bindings/python/test_generator_profile.py b/tests/bindings/python/test_generator_profile.py index c6219f1cc8..9b63976bcc 100644 --- a/tests/bindings/python/test_generator_profile.py +++ b/tests/bindings/python/test_generator_profile.py @@ -19,12 +19,12 @@ def test_generator_profile(self): # Create a default, i.e. C, profile. p = GeneratorProfile() self.assertEqual(GeneratorProfile.Profile.C, p.profile()) - self.assertEqual("C", GeneratorProfile.profileAsString(p.profile())) + self.assertEqual("c", GeneratorProfile.profileAsString(p.profile())) # Make the profile a Python profile. p.setProfile(GeneratorProfile.Profile.PYTHON) self.assertEqual(GeneratorProfile.Profile.PYTHON, p.profile()) - self.assertEqual("PYTHON", GeneratorProfile.profileAsString(p.profile())) + self.assertEqual("python", GeneratorProfile.profileAsString(p.profile())) # Create a Python profile. pp = GeneratorProfile(GeneratorProfile.Profile.PYTHON) diff --git a/tests/coverage/coverage.cpp b/tests/coverage/coverage.cpp index f0ae9f0182..679b43c3ba 100644 --- a/tests/coverage/coverage.cpp +++ b/tests/coverage/coverage.cpp @@ -279,7 +279,7 @@ TEST(Coverage, analyser) EXPECT_FALSE(analyserModel->isValid()); EXPECT_EQ(libcellml::AnalyserModel::Type::UNKNOWN, analyserModel->type()); - EXPECT_EQ("UNKNOWN", libcellml::AnalyserModel::typeAsString(analyserModel->type())); + EXPECT_EQ("unknown", libcellml::AnalyserModel::typeAsString(analyserModel->type())); EXPECT_EQ(nullptr, analyserModel->voi()); @@ -384,7 +384,7 @@ TEST(Generator, coverage) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ODE, analyserModel->type()); - EXPECT_EQ("ODE", libcellml::AnalyserModel::typeAsString(analyserModel->type())); + EXPECT_EQ("ode", libcellml::AnalyserModel::typeAsString(analyserModel->type())); EXPECT_EQ(size_t(1), analyserModel->stateCount()); EXPECT_EQ(size_t(203), analyserModel->variableCount()); diff --git a/tests/generator/generator.cpp b/tests/generator/generator.cpp index 7e0f440f4e..4b940f9fcc 100644 --- a/tests/generator/generator.cpp +++ b/tests/generator/generator.cpp @@ -56,7 +56,7 @@ TEST(Generator, algebraicEqnComputedVarOnRhs) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ALGEBRAIC, analyserModel->type()); - EXPECT_EQ("ALGEBRAIC", libcellml::AnalyserModel::typeAsString(analyserModel->type())); + EXPECT_EQ("algebraic", libcellml::AnalyserModel::typeAsString(analyserModel->type())); EXPECT_EQ(size_t(0), analyserModel->stateCount()); EXPECT_EQ(size_t(2), analyserModel->variableCount()); @@ -70,7 +70,7 @@ TEST(Generator, algebraicEqnComputedVarOnRhs) EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); EXPECT_EQ(libcellml::AnalyserEquation::Type::TRUE_CONSTANT, analyserModel->equation(0)->type()); - EXPECT_EQ("TRUE_CONSTANT", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); + EXPECT_EQ("true_constant", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); auto generator = libcellml::Generator::create(); @@ -165,13 +165,13 @@ TEST(Generator, algebraicEqnConstVarOnRhs) EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); EXPECT_EQ(libcellml::AnalyserVariable::Type::CONSTANT, analyserModel->variable(0)->type()); - EXPECT_EQ("CONSTANT", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(0)->type())); + EXPECT_EQ("constant", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(0)->type())); EXPECT_EQ(libcellml::AnalyserVariable::Type::COMPUTED_CONSTANT, analyserModel->variable(1)->type()); - EXPECT_EQ("COMPUTED_CONSTANT", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(1)->type())); + EXPECT_EQ("computed_constant", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(1)->type())); EXPECT_EQ(libcellml::AnalyserEquation::Type::VARIABLE_BASED_CONSTANT, analyserModel->equation(0)->type()); - EXPECT_EQ("VARIABLE_BASED_CONSTANT", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); + EXPECT_EQ("variable_based_constant", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); auto generator = libcellml::Generator::create(); @@ -247,7 +247,7 @@ TEST(Generator, algebraicEqnDerivativeOnRhs) auto analyserModel = analyser->model(); EXPECT_EQ(libcellml::AnalyserModel::Type::ODE, analyserModel->type()); - EXPECT_EQ("ODE", libcellml::AnalyserModel::typeAsString(analyserModel->type())); + EXPECT_EQ("ode", libcellml::AnalyserModel::typeAsString(analyserModel->type())); EXPECT_EQ(size_t(1), analyserModel->stateCount()); EXPECT_EQ(size_t(2), analyserModel->variableCount()); @@ -262,19 +262,19 @@ TEST(Generator, algebraicEqnDerivativeOnRhs) EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); EXPECT_EQ(libcellml::AnalyserVariable::Type::VARIABLE_OF_INTEGRATION, analyserModel->voi()->type()); - EXPECT_EQ("VARIABLE_OF_INTEGRATION", libcellml::AnalyserVariable::typeAsString(analyserModel->voi()->type())); + EXPECT_EQ("variable_of_integration", libcellml::AnalyserVariable::typeAsString(analyserModel->voi()->type())); EXPECT_EQ(libcellml::AnalyserVariable::Type::STATE, analyserModel->state(0)->type()); - EXPECT_EQ("STATE", libcellml::AnalyserVariable::typeAsString(analyserModel->state(0)->type())); + EXPECT_EQ("state", libcellml::AnalyserVariable::typeAsString(analyserModel->state(0)->type())); EXPECT_EQ(libcellml::AnalyserVariable::Type::ALGEBRAIC, analyserModel->variable(1)->type()); - EXPECT_EQ("ALGEBRAIC", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(1)->type())); + EXPECT_EQ("algebraic", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(1)->type())); EXPECT_EQ(libcellml::AnalyserEquation::Type::RATE, analyserModel->equation(0)->type()); - EXPECT_EQ("RATE", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); + EXPECT_EQ("rate", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); EXPECT_EQ(libcellml::AnalyserEquation::Type::ALGEBRAIC, analyserModel->equation(2)->type()); - EXPECT_EQ("ALGEBRAIC", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(2)->type())); + EXPECT_EQ("algebraic", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(2)->type())); auto generator = libcellml::Generator::create(); @@ -1387,10 +1387,10 @@ TEST(Generator, cellGeometryModelWithExternalVariables) EXPECT_EQ(nullptr, analyserModel->equation(analyserModel->equationCount())); EXPECT_EQ(libcellml::AnalyserVariable::Type::EXTERNAL, analyserModel->variable(0)->type()); - EXPECT_EQ("EXTERNAL", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(0)->type())); + EXPECT_EQ("external", libcellml::AnalyserVariable::typeAsString(analyserModel->variable(0)->type())); EXPECT_EQ(libcellml::AnalyserEquation::Type::EXTERNAL, analyserModel->equation(0)->type()); - EXPECT_EQ("EXTERNAL", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); + EXPECT_EQ("external", libcellml::AnalyserEquation::typeAsString(analyserModel->equation(0)->type())); auto generator = libcellml::Generator::create(); diff --git a/tests/generator/generatorprofile.cpp b/tests/generator/generatorprofile.cpp index b965deaf0e..5f6462e74c 100644 --- a/tests/generator/generatorprofile.cpp +++ b/tests/generator/generatorprofile.cpp @@ -38,7 +38,7 @@ TEST(GeneratorProfile, defaultGeneralValues) libcellml::GeneratorProfilePtr generatorProfile = libcellml::GeneratorProfile::create(); EXPECT_EQ(libcellml::GeneratorProfile::Profile::C, generatorProfile->profile()); - EXPECT_EQ("C", libcellml::GeneratorProfile::profileAsString(generatorProfile->profile())); + EXPECT_EQ("c", libcellml::GeneratorProfile::profileAsString(generatorProfile->profile())); EXPECT_EQ(true, generatorProfile->hasInterface()); } @@ -498,7 +498,7 @@ TEST(GeneratorProfile, generalSettings) generatorProfile->setHasInterface(falseValue); EXPECT_EQ(profile, generatorProfile->profile()); - EXPECT_EQ("PYTHON", libcellml::GeneratorProfile::profileAsString(generatorProfile->profile())); + EXPECT_EQ("python", libcellml::GeneratorProfile::profileAsString(generatorProfile->profile())); EXPECT_EQ(falseValue, generatorProfile->hasInterface()); } From 7f1ddb6ef98dc695d1ad1fdc316587c56e8662e9 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 21 Feb 2023 16:38:01 +1300 Subject: [PATCH 07/13] Analyser/generator: ensure Python coverage. --- tests/bindings/python/test_analyser.py | 9 +++++++++ tests/bindings/python/test_generator_profile.py | 3 +++ 2 files changed, 12 insertions(+) diff --git a/tests/bindings/python/test_analyser.py b/tests/bindings/python/test_analyser.py index 68c11a6f60..dfbcb8dc5e 100644 --- a/tests/bindings/python/test_analyser.py +++ b/tests/bindings/python/test_analyser.py @@ -29,6 +29,7 @@ def test_analyse_model(self): from libcellml import Analyser from libcellml import AnalyserModel from libcellml import Model + from libcellml.analysermodel import AnalyserModel_typeAsString # Analyse an empty model and make sure that we get no errors and an # UNKNOWN type for the analyser model. @@ -41,6 +42,7 @@ def test_analyse_model(self): self.assertEqual(0, a.errorCount()) self.assertEqual(AnalyserModel.Type.UNKNOWN, a.model().type()) self.assertEqual("unknown", AnalyserModel.typeAsString(a.model().type())) + self.assertEqual("unknown", AnalyserModel_typeAsString(a.model().type())) def test_coverage(self): from libcellml import Analyser @@ -51,6 +53,9 @@ def test_coverage(self): from libcellml import AnalyserVariable from libcellml import Model from libcellml import Parser + from libcellml.analyserequation import AnalyserEquation_typeAsString + from libcellml.analyserequationast import AnalyserEquationAst_typeAsString + from libcellml.analyservariable import AnalyserVariable_typeAsString from test_resources import file_contents # Try to create an analyser equation/model/variable, something that is not allowed. @@ -151,6 +156,7 @@ def test_coverage(self): self.assertEqual(AnalyserVariable.Type.CONSTANT, av.type()) self.assertEqual("constant", AnalyserVariable.typeAsString(av.type())) + self.assertEqual("constant", AnalyserVariable_typeAsString(av.type())) self.assertEqual(3, av.index()) self.assertIsNotNone(av.initialisingVariable()) self.assertIsNotNone(av.variable()) @@ -162,6 +168,7 @@ def test_coverage(self): self.assertEqual(AnalyserEquation.Type.RATE, ae.type()) self.assertEqual("rate", AnalyserEquation.typeAsString(ae.type())) + self.assertEqual("rate", AnalyserEquation_typeAsString(ae.type())) self.assertIsNotNone(ae.ast()) self.assertIsNotNone(ae.dependencies()) self.assertTrue(ae.isStateRateBased()) @@ -173,6 +180,7 @@ def test_coverage(self): self.assertEqual(AnalyserEquationAst.Type.ASSIGNMENT, aea.type()) self.assertEqual("assignment", AnalyserEquationAst.typeAsString(aea.type())) + self.assertEqual("assignment", AnalyserEquationAst_typeAsString(aea.type())) self.assertEqual('', aea.value()) self.assertIsNone(aea.variable()) self.assertIsNone(aea.parent()) @@ -189,6 +197,7 @@ def test_coverage(self): self.assertEqual(AnalyserEquationAst.Type.EQ, aea.type()) self.assertEqual("eq", AnalyserEquationAst.typeAsString(aea.type())) + self.assertEqual("eq", AnalyserEquationAst_typeAsString(aea.type())) self.assertEqual(AnalyserTestCase.VALUE, aea.value()) self.assertIsNotNone(aea.variable()) self.assertIsNotNone(aea.parent()) diff --git a/tests/bindings/python/test_generator_profile.py b/tests/bindings/python/test_generator_profile.py index 9b63976bcc..eee5004a12 100644 --- a/tests/bindings/python/test_generator_profile.py +++ b/tests/bindings/python/test_generator_profile.py @@ -15,16 +15,19 @@ def test_create_destroy(self): def test_generator_profile(self): from libcellml import GeneratorProfile + from libcellml.generatorprofile import GeneratorProfile_profileAsString # Create a default, i.e. C, profile. p = GeneratorProfile() self.assertEqual(GeneratorProfile.Profile.C, p.profile()) self.assertEqual("c", GeneratorProfile.profileAsString(p.profile())) + self.assertEqual("c", GeneratorProfile_profileAsString(p.profile())) # Make the profile a Python profile. p.setProfile(GeneratorProfile.Profile.PYTHON) self.assertEqual(GeneratorProfile.Profile.PYTHON, p.profile()) self.assertEqual("python", GeneratorProfile.profileAsString(p.profile())) + self.assertEqual("python", GeneratorProfile_profileAsString(p.profile())) # Create a Python profile. pp = GeneratorProfile(GeneratorProfile.Profile.PYTHON) From 97dd8177bf109660e6de2799fffb429b3433e8e4 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 21 Feb 2023 16:47:57 +1300 Subject: [PATCH 08/13] Allow gcov to get 100% coverage. GCov coverage is clearly not as good as LLVM coverage...? --- src/analyserequation.cpp | 14 ++-- src/analyserequationast.cpp | 134 ++++++++++++++++++------------------ src/analysermodel.cpp | 18 ++--- src/analyservariable.cpp | 16 ++--- src/enums.cpp | 34 ++++----- src/generatorprofile.cpp | 8 +-- 6 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/analyserequation.cpp b/src/analyserequation.cpp index 40d884d187..4b7cb03e52 100644 --- a/src/analyserequation.cpp +++ b/src/analyserequation.cpp @@ -68,15 +68,15 @@ AnalyserEquation::Type AnalyserEquation::type() const return mPimpl->mType; } +static const std::map typeToString = { + {AnalyserEquation::Type::TRUE_CONSTANT, "true_constant"}, + {AnalyserEquation::Type::VARIABLE_BASED_CONSTANT, "variable_based_constant"}, + {AnalyserEquation::Type::RATE, "rate"}, + {AnalyserEquation::Type::ALGEBRAIC, "algebraic"}, + {AnalyserEquation::Type::EXTERNAL, "external"}}; + std::string AnalyserEquation::typeAsString(Type type) { - static const std::map typeToString = { - {Type::TRUE_CONSTANT, "true_constant"}, - {Type::VARIABLE_BASED_CONSTANT, "variable_based_constant"}, - {Type::RATE, "rate"}, - {Type::ALGEBRAIC, "algebraic"}, - {Type::EXTERNAL, "external"}}; - return typeToString.at(type); } diff --git a/src/analyserequationast.cpp b/src/analyserequationast.cpp index 21d70cc111..6eddcbf5d4 100644 --- a/src/analyserequationast.cpp +++ b/src/analyserequationast.cpp @@ -69,75 +69,75 @@ AnalyserEquationAst::Type AnalyserEquationAst::type() const return mPimpl->mType; } +static const std::map typeToString = { + {AnalyserEquationAst::Type::ASSIGNMENT, "assignment"}, + {AnalyserEquationAst::Type::EQ, "eq"}, + {AnalyserEquationAst::Type::NEQ, "neq"}, + {AnalyserEquationAst::Type::LT, "lt"}, + {AnalyserEquationAst::Type::LEQ, "leq"}, + {AnalyserEquationAst::Type::GT, "gt"}, + {AnalyserEquationAst::Type::GEQ, "geq"}, + {AnalyserEquationAst::Type::AND, "and"}, + {AnalyserEquationAst::Type::OR, "or"}, + {AnalyserEquationAst::Type::XOR, "xor"}, + {AnalyserEquationAst::Type::NOT, "not"}, + {AnalyserEquationAst::Type::PLUS, "plus"}, + {AnalyserEquationAst::Type::MINUS, "minus"}, + {AnalyserEquationAst::Type::TIMES, "times"}, + {AnalyserEquationAst::Type::DIVIDE, "divide"}, + {AnalyserEquationAst::Type::POWER, "power"}, + {AnalyserEquationAst::Type::ROOT, "root"}, + {AnalyserEquationAst::Type::ABS, "abs"}, + {AnalyserEquationAst::Type::EXP, "exp"}, + {AnalyserEquationAst::Type::LN, "ln"}, + {AnalyserEquationAst::Type::LOG, "log"}, + {AnalyserEquationAst::Type::CEILING, "ceiling"}, + {AnalyserEquationAst::Type::FLOOR, "floor"}, + {AnalyserEquationAst::Type::MIN, "min"}, + {AnalyserEquationAst::Type::MAX, "max"}, + {AnalyserEquationAst::Type::REM, "rem"}, + {AnalyserEquationAst::Type::DIFF, "diff"}, + {AnalyserEquationAst::Type::SIN, "sin"}, + {AnalyserEquationAst::Type::COS, "cos"}, + {AnalyserEquationAst::Type::TAN, "tan"}, + {AnalyserEquationAst::Type::SEC, "sec"}, + {AnalyserEquationAst::Type::CSC, "csc"}, + {AnalyserEquationAst::Type::COT, "cot"}, + {AnalyserEquationAst::Type::SINH, "sinh"}, + {AnalyserEquationAst::Type::COSH, "cosh"}, + {AnalyserEquationAst::Type::TANH, "tanh"}, + {AnalyserEquationAst::Type::SECH, "sech"}, + {AnalyserEquationAst::Type::CSCH, "csch"}, + {AnalyserEquationAst::Type::COTH, "coth"}, + {AnalyserEquationAst::Type::ASIN, "asin"}, + {AnalyserEquationAst::Type::ACOS, "acos"}, + {AnalyserEquationAst::Type::ATAN, "atan"}, + {AnalyserEquationAst::Type::ASEC, "asec"}, + {AnalyserEquationAst::Type::ACSC, "acsc"}, + {AnalyserEquationAst::Type::ACOT, "acot"}, + {AnalyserEquationAst::Type::ASINH, "asinh"}, + {AnalyserEquationAst::Type::ACOSH, "acosh"}, + {AnalyserEquationAst::Type::ATANH, "atanh"}, + {AnalyserEquationAst::Type::ASECH, "asech"}, + {AnalyserEquationAst::Type::ACSCH, "acsch"}, + {AnalyserEquationAst::Type::ACOTH, "acoth"}, + {AnalyserEquationAst::Type::PIECEWISE, "piecewise"}, + {AnalyserEquationAst::Type::PIECE, "piece"}, + {AnalyserEquationAst::Type::OTHERWISE, "otherwise"}, + {AnalyserEquationAst::Type::CI, "ci"}, + {AnalyserEquationAst::Type::CN, "cn"}, + {AnalyserEquationAst::Type::DEGREE, "degree"}, + {AnalyserEquationAst::Type::LOGBASE, "logbase"}, + {AnalyserEquationAst::Type::BVAR, "bvar"}, + {AnalyserEquationAst::Type::TRUE, "true"}, + {AnalyserEquationAst::Type::FALSE, "false"}, + {AnalyserEquationAst::Type::E, "e"}, + {AnalyserEquationAst::Type::PI, "pi"}, + {AnalyserEquationAst::Type::INF, "inf"}, + {AnalyserEquationAst::Type::NAN, "nan"}}; + std::string AnalyserEquationAst::typeAsString(Type type) { - static const std::map typeToString = { - {Type::ASSIGNMENT, "assignment"}, - {Type::EQ, "eq"}, - {Type::NEQ, "neq"}, - {Type::LT, "lt"}, - {Type::LEQ, "leq"}, - {Type::GT, "gt"}, - {Type::GEQ, "geq"}, - {Type::AND, "and"}, - {Type::OR, "or"}, - {Type::XOR, "xor"}, - {Type::NOT, "not"}, - {Type::PLUS, "plus"}, - {Type::MINUS, "minus"}, - {Type::TIMES, "times"}, - {Type::DIVIDE, "divide"}, - {Type::POWER, "power"}, - {Type::ROOT, "root"}, - {Type::ABS, "abs"}, - {Type::EXP, "exp"}, - {Type::LN, "ln"}, - {Type::LOG, "log"}, - {Type::CEILING, "ceiling"}, - {Type::FLOOR, "floor"}, - {Type::MIN, "min"}, - {Type::MAX, "max"}, - {Type::REM, "rem"}, - {Type::DIFF, "diff"}, - {Type::SIN, "sin"}, - {Type::COS, "cos"}, - {Type::TAN, "tan"}, - {Type::SEC, "sec"}, - {Type::CSC, "csc"}, - {Type::COT, "cot"}, - {Type::SINH, "sinh"}, - {Type::COSH, "cosh"}, - {Type::TANH, "tanh"}, - {Type::SECH, "sech"}, - {Type::CSCH, "csch"}, - {Type::COTH, "coth"}, - {Type::ASIN, "asin"}, - {Type::ACOS, "acos"}, - {Type::ATAN, "atan"}, - {Type::ASEC, "asec"}, - {Type::ACSC, "acsc"}, - {Type::ACOT, "acot"}, - {Type::ASINH, "asinh"}, - {Type::ACOSH, "acosh"}, - {Type::ATANH, "atanh"}, - {Type::ASECH, "asech"}, - {Type::ACSCH, "acsch"}, - {Type::ACOTH, "acoth"}, - {Type::PIECEWISE, "piecewise"}, - {Type::PIECE, "piece"}, - {Type::OTHERWISE, "otherwise"}, - {Type::CI, "ci"}, - {Type::CN, "cn"}, - {Type::DEGREE, "degree"}, - {Type::LOGBASE, "logbase"}, - {Type::BVAR, "bvar"}, - {Type::TRUE, "true"}, - {Type::FALSE, "false"}, - {Type::E, "e"}, - {Type::PI, "pi"}, - {Type::INF, "inf"}, - {Type::NAN, "nan"}}; - return typeToString.at(type); } diff --git a/src/analysermodel.cpp b/src/analysermodel.cpp index c76047e532..0a4e38f71e 100644 --- a/src/analysermodel.cpp +++ b/src/analysermodel.cpp @@ -47,17 +47,17 @@ AnalyserModel::Type AnalyserModel::type() const return mPimpl->mType; } +static const std::map typeToString = { + {AnalyserModel::Type::UNKNOWN, "unknown"}, + {AnalyserModel::Type::ALGEBRAIC, "algebraic"}, + {AnalyserModel::Type::ODE, "ode"}, + {AnalyserModel::Type::INVALID, "invalid"}, + {AnalyserModel::Type::UNDERCONSTRAINED, "underconstrained"}, + {AnalyserModel::Type::OVERCONSTRAINED, "overconstrained"}, + {AnalyserModel::Type::UNSUITABLY_CONSTRAINED, "unsuitably_constrained"}}; + std::string AnalyserModel::typeAsString(Type type) { - static const std::map typeToString = { - {Type::UNKNOWN, "unknown"}, - {Type::ALGEBRAIC, "algebraic"}, - {Type::ODE, "ode"}, - {Type::INVALID, "invalid"}, - {Type::UNDERCONSTRAINED, "underconstrained"}, - {Type::OVERCONSTRAINED, "overconstrained"}, - {Type::UNSUITABLY_CONSTRAINED, "unsuitably_constrained"}}; - return typeToString.at(type); } diff --git a/src/analyservariable.cpp b/src/analyservariable.cpp index 34ec18e6ff..c875acf664 100644 --- a/src/analyservariable.cpp +++ b/src/analyservariable.cpp @@ -53,16 +53,16 @@ AnalyserVariable::Type AnalyserVariable::type() const return mPimpl->mType; } +static const std::map typeToString = { + {AnalyserVariable::Type::VARIABLE_OF_INTEGRATION, "variable_of_integration"}, + {AnalyserVariable::Type::STATE, "state"}, + {AnalyserVariable::Type::CONSTANT, "constant"}, + {AnalyserVariable::Type::COMPUTED_CONSTANT, "computed_constant"}, + {AnalyserVariable::Type::ALGEBRAIC, "algebraic"}, + {AnalyserVariable::Type::EXTERNAL, "external"}}; + std::string AnalyserVariable::typeAsString(Type type) { - static const std::map typeToString = { - {Type::VARIABLE_OF_INTEGRATION, "variable_of_integration"}, - {Type::STATE, "state"}, - {Type::CONSTANT, "constant"}, - {Type::COMPUTED_CONSTANT, "computed_constant"}, - {Type::ALGEBRAIC, "algebraic"}, - {Type::EXTERNAL, "external"}}; - return typeToString.at(type); } diff --git a/src/enums.cpp b/src/enums.cpp index 007ef106a7..d55992ddb4 100644 --- a/src/enums.cpp +++ b/src/enums.cpp @@ -20,25 +20,25 @@ limitations under the License. namespace libcellml { +static const std::map cellmlElementTypeToString = { + {CellmlElementType::COMPONENT, "component"}, + {CellmlElementType::COMPONENT_REF, "component_ref"}, + {CellmlElementType::CONNECTION, "connection"}, + {CellmlElementType::ENCAPSULATION, "encapsulation"}, + {CellmlElementType::IMPORT, "import"}, + {CellmlElementType::MATH, "math"}, + {CellmlElementType::MAP_VARIABLES, "map_variables"}, + {CellmlElementType::MODEL, "model"}, + {CellmlElementType::RESET, "reset"}, + {CellmlElementType::RESET_VALUE, "reset_value"}, + {CellmlElementType::TEST_VALUE, "test_value"}, + {CellmlElementType::UNDEFINED, "undefined"}, + {CellmlElementType::UNIT, "unit"}, + {CellmlElementType::UNITS, "units"}, + {CellmlElementType::VARIABLE, "variable"}}; + std::string cellmlElementTypeAsString(CellmlElementType value) { - static const std::map cellmlElementTypeToString = { - {CellmlElementType::COMPONENT, "component"}, - {CellmlElementType::COMPONENT_REF, "component_ref"}, - {CellmlElementType::CONNECTION, "connection"}, - {CellmlElementType::ENCAPSULATION, "encapsulation"}, - {CellmlElementType::IMPORT, "import"}, - {CellmlElementType::MATH, "math"}, - {CellmlElementType::MAP_VARIABLES, "map_variables"}, - {CellmlElementType::MODEL, "model"}, - {CellmlElementType::RESET, "reset"}, - {CellmlElementType::RESET_VALUE, "reset_value"}, - {CellmlElementType::TEST_VALUE, "test_value"}, - {CellmlElementType::UNDEFINED, "undefined"}, - {CellmlElementType::UNIT, "unit"}, - {CellmlElementType::UNITS, "units"}, - {CellmlElementType::VARIABLE, "variable"}}; - return cellmlElementTypeToString.at(value); } diff --git a/src/generatorprofile.cpp b/src/generatorprofile.cpp index 39673039e4..5ab3e588b4 100644 --- a/src/generatorprofile.cpp +++ b/src/generatorprofile.cpp @@ -1038,12 +1038,12 @@ GeneratorProfile::Profile GeneratorProfile::profile() const return mPimpl->mProfile; } +static const std::map profileToString = { + {GeneratorProfile::Profile::C, "c"}, + {GeneratorProfile::Profile::PYTHON, "python"}}; + std::string GeneratorProfile::profileAsString(Profile profile) { - static const std::map profileToString = { - {Profile::C, "c"}, - {Profile::PYTHON, "python"}}; - return profileToString.at(profile); } From a9b35637e022382636927549cd8440d9783f96e3 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Fri, 31 Mar 2023 00:23:43 +1300 Subject: [PATCH 09/13] Fixed a merging issue. --- src/model.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/model.cpp b/src/model.cpp index 3ce5cd6072..be471ce3dc 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -30,6 +30,7 @@ limitations under the License. #include "libcellml/units.h" #include "libcellml/variable.h" +#include "commonutils.h" #include "component_p.h" #include "componententity_p.h" #include "internaltypes.h" From 3bc6873a7b5b005a5ab78d3b74fa6be514515d58 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Mon, 17 Apr 2023 11:55:41 +1200 Subject: [PATCH 10/13] Python bindings: make sure that analyser-related types are valid. --- src/bindings/interface/types.i | 36 +++++++++++++++++++++++++++++++++ src/bindings/python/__init__.py | 2 ++ 2 files changed, 38 insertions(+) diff --git a/src/bindings/interface/types.i b/src/bindings/interface/types.i index f1f4609724..70e67297eb 100644 --- a/src/bindings/interface/types.i +++ b/src/bindings/interface/types.i @@ -116,6 +116,18 @@ Provides support for shared pointers declared in types.h. // Shared typemaps +%typemap(in) libcellml::AnalyserEquation::Type (int val, int ecode) { + ecode = SWIG_AsVal(int)($input, &val); + if (!SWIG_IsOK(ecode)) { + %argument_fail(ecode, "$type", $symname, $argnum); + } else { + if (val < %static_cast($type::TRUE_CONSTANT, int) || %static_cast($type::EXTERNAL, int) < val) { + %argument_fail(ecode, "$type is not a valid value for the enumeration.", $symname, $argnum); + } + $1 = %static_cast(val, $basetype); + } +} + %typemap(in) libcellml::AnalyserEquationAst::Type (int val, int ecode) { ecode = SWIG_AsVal(int)($input, &val); if (!SWIG_IsOK(ecode)) { @@ -128,6 +140,30 @@ Provides support for shared pointers declared in types.h. } } +%typemap(in) libcellml::AnalyserModel::Type (int val, int ecode) { + ecode = SWIG_AsVal(int)($input, &val); + if (!SWIG_IsOK(ecode)) { + %argument_fail(ecode, "$type", $symname, $argnum); + } else { + if (val < %static_cast($type::UNKNOWN, int) || %static_cast($type::UNSUITABLY_CONSTRAINED, int) < val) { + %argument_fail(ecode, "$type is not a valid value for the enumeration.", $symname, $argnum); + } + $1 = %static_cast(val, $basetype); + } +} + +%typemap(in) libcellml::AnalyserVariable::Type (int val, int ecode) { + ecode = SWIG_AsVal(int)($input, &val); + if (!SWIG_IsOK(ecode)) { + %argument_fail(ecode, "$type", $symname, $argnum); + } else { + if (val < %static_cast($type::VARIABLE_OF_INTEGRATION, int) || %static_cast($type::EXTERNAL, int) < val) { + %argument_fail(ecode, "$type is not a valid value for the enumeration.", $symname, $argnum); + } + $1 = %static_cast(val, $basetype); + } +} + %typemap(in) libcellml::GeneratorProfile::Profile (int val, int ecode) { ecode = SWIG_AsVal(int)($input, &val); if (!SWIG_IsOK(ecode)) { diff --git a/src/bindings/python/__init__.py b/src/bindings/python/__init__.py index 86a91c061b..f7cb9f2a22 100644 --- a/src/bindings/python/__init__.py +++ b/src/bindings/python/__init__.py @@ -59,6 +59,7 @@ class Object: 'VARIABLE_BASED_CONSTANT', 'RATE', 'ALGEBRAIC', + 'EXTERNAL', ]) convert(AnalyserEquationAst, 'Type', [ 'ASSIGNMENT', @@ -166,6 +167,7 @@ class Object: 'CONSTANT', 'COMPUTED_CONSTANT', 'ALGEBRAIC', + 'EXTERNAL', ]) convert(GeneratorProfile, 'Profile', [ 'C', From 6d0561c85bf4bf3d161ad89f5b23cb920662d293 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 25 Apr 2023 12:38:01 -0700 Subject: [PATCH 11/13] Python: make sure that xxxAsString() doesn't work with invalid values. Note that we don't need to test this in JavaScript since its behaviour is the same as in C++ (we need to pass an enum class value, not an integer value as in Python). --- tests/bindings/python/test_analyser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/bindings/python/test_analyser.py b/tests/bindings/python/test_analyser.py index dfbcb8dc5e..f33855b82a 100644 --- a/tests/bindings/python/test_analyser.py +++ b/tests/bindings/python/test_analyser.py @@ -174,6 +174,13 @@ def test_coverage(self): self.assertTrue(ae.isStateRateBased()) self.assertIsNotNone(ae.variable()) + # Check Analyser Equation type with invalid values. + + self.assertRaises(RuntimeError, AnalyserEquation.typeAsString, -1) + self.assertRaises(RuntimeError, AnalyserEquation_typeAsString, -1) + self.assertRaises(RuntimeError, AnalyserEquation.typeAsString, 999) + self.assertRaises(RuntimeError, AnalyserEquation_typeAsString, 999) + # Ensure coverage for AnalyserEquationAst. aea = ae.ast() From 80e3236831bd1c22c8067452c145de1c0d94dffb Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 25 Apr 2023 17:36:52 -0700 Subject: [PATCH 12/13] Units: improved casting. --- src/units.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/units.cpp b/src/units.cpp index f8f7263e99..9cbf9c0b7f 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -427,13 +427,13 @@ void Units::addUnit(StandardUnit standardUnit) void Units::unitAttributes(StandardUnit standardUnit, std::string &prefix, double &exponent, double &multiplier, std::string &id) const { std::string dummyReference; - unitAttributes(size_t(pFunc()->findUnit(standardUnitToString.at(standardUnit)) - pFunc()->mUnitDefinitions.begin()), dummyReference, prefix, exponent, multiplier, id); + unitAttributes(static_cast(pFunc()->findUnit(standardUnitToString.at(standardUnit)) - pFunc()->mUnitDefinitions.begin()), dummyReference, prefix, exponent, multiplier, id); } void Units::unitAttributes(const std::string &reference, std::string &prefix, double &exponent, double &multiplier, std::string &id) const { std::string dummyReference; - unitAttributes(size_t(pFunc()->findUnit(reference) - pFunc()->mUnitDefinitions.begin()), dummyReference, prefix, exponent, multiplier, id); + unitAttributes(static_cast(pFunc()->findUnit(reference) - pFunc()->mUnitDefinitions.begin()), dummyReference, prefix, exponent, multiplier, id); } void Units::unitAttributes(size_t index, std::string &reference, std::string &prefix, double &exponent, double &multiplier, std::string &id) const From ada4cb584a54d3f2fd22d8ee04ecf20ab2193045 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 25 Apr 2023 21:33:32 -0700 Subject: [PATCH 13/13] Documentation: use @ref rather than @c wherever possible in our analyser/generator documentation. --- src/api/libcellml/analyser.h | 32 +-- src/api/libcellml/analyserequation.h | 38 ++-- src/api/libcellml/analyserequationast.h | 22 +- src/api/libcellml/analyserexternalvariable.h | 38 ++-- src/api/libcellml/analysermodel.h | 200 +++++++++---------- src/api/libcellml/analyservariable.h | 42 ++-- src/api/libcellml/generator.h | 42 ++-- src/api/libcellml/generatorprofile.h | 180 ++++++++--------- 8 files changed, 297 insertions(+), 297 deletions(-) diff --git a/src/api/libcellml/analyser.h b/src/api/libcellml/analyser.h index 79439f31a1..765c4a9946 100644 --- a/src/api/libcellml/analyser.h +++ b/src/api/libcellml/analyser.h @@ -50,11 +50,11 @@ class LIBCELLML_EXPORT Analyser: public Logger static AnalyserPtr create() noexcept; /** - * @brief Analyse the @c Model. + * @brief Analyse the @ref Model. * - * Analyse the @c Model using this @ref Analyser. + * Analyse the @ref Model using this @ref Analyser. * - * @param model The @c Model to analyse. + * @param model The @ref Model to analyse. */ void analyseModel(const ModelPtr &model); @@ -87,16 +87,16 @@ class LIBCELLML_EXPORT Analyser: public Logger * @overload * * @brief Remove the @ref AnalyserExternalVariable with the given - * @p variableName in the @c Component with the given @p componentName in + * @p variableName in the @ref Component with the given @p componentName in * the given @p model. * * Remove the @ref AnalyserExternalVariable found that matches the given - * @p variableName in the @c Component with the given @p componentName in + * @p variableName in the @ref Component with the given @p componentName in * the given @p model. * - * @param model The pointer to the @c Model which contains the + * @param model The pointer to the @ref Model which contains the * @ref AnalyserExternalVariable to remove. - * @param componentName The name of the @c Component which contains the + * @param componentName The name of the @ref Component which contains the * @ref AnalyserExternalVariable to remove. * @param variableName The name of the @ref AnalyserExternalVariable to * remove. @@ -134,18 +134,18 @@ class LIBCELLML_EXPORT Analyser: public Logger /** * @brief Test to see if the @ref AnalyserExternalVariable with the given - * @p variableName in the @c Component with the given @p componentName in + * @p variableName in the @ref Component with the given @p componentName in * the given @p model is contained within this @ref Analyser. * * Test to see if the @ref AnalyserExternalVariable with the the given - * @p variableName in the @c Component with the given @p componentName in + * @p variableName in the @ref Component with the given @p componentName in * the given @p model is contained within this @ref Analyser. Return @c true * if the @ref AnalyserExternalVariable is in the @ref Analyser and @c false * otherwise. * - * @param model The pointer to the @c Model which contains the + * @param model The pointer to the @ref Model which contains the * @ref AnalyserExternalVariable to test. - * @param componentName The name of the @c Component which contains the + * @param componentName The name of the @ref Component which contains the * @ref AnalyserExternalVariable to test. * @param variableName The name of the @ref AnalyserExternalVariable to test. * @@ -192,19 +192,19 @@ class LIBCELLML_EXPORT Analyser: public Logger * @brief Get the @ref AnalyserExternalVariable with the given @p name. * * Return the @ref AnalyserExternalVariable with the given @p variableName in - * the @c Component with the given @p componentName in the given @p model. + * the @ref Component with the given @p componentName in the given @p model. * If no such @ref AnalyserExternalVariable is contained within the * @ref Analyser, a @c nullptr is returned. * - * @param model The pointer to the @c Model which contains the + * @param model The pointer to the @ref Model which contains the * @ref AnalyserExternalVariable to retrieve. - * @param componentName The name of the @c Component which contains the + * @param componentName The name of the @ref Component which contains the * @ref AnalyserExternalVariable to retrieve. * @param variableName The name of the @ref AnalyserExternalVariable to * retrieve. * * @return The @ref AnalyserExternalVariable with the given @p variableName in - * the @c Component with the given @p componentName in the given @p model on + * the @ref Component with the given @p componentName in the given @p model on * success, @c nullptr on failure. */ AnalyserExternalVariablePtr externalVariable(const ModelPtr &model, @@ -230,7 +230,7 @@ class LIBCELLML_EXPORT Analyser: public Logger * variable of integration, states, variables, equations, and whether it * needs some specific mathematical functions. * - * @return The analysed model for the @c Model analysed by this @ref Analyser. + * @return The analysed model for the @ref Model analysed by this @ref Analyser. */ AnalyserModelPtr model() const; diff --git a/src/api/libcellml/analyserequation.h b/src/api/libcellml/analyserequation.h index fad5ac47d7..0f2bd95f9e 100644 --- a/src/api/libcellml/analyserequation.h +++ b/src/api/libcellml/analyserequation.h @@ -53,62 +53,62 @@ class LIBCELLML_EXPORT AnalyserEquation AnalyserEquation &operator=(AnalyserEquation rhs) = delete; /**< Assignment operator, @private. */ /** - * @brief Get the @c Type of this @c AnalyserEquation. + * @brief Get the @ref Type of this @ref AnalyserEquation. * - * Return the @c Type of this @c AnalyserEquation. + * Return the @ref Type of this @ref AnalyserEquation. * - * @return The @c Type. + * @return The @ref Type. */ Type type() const; /** - * @brief Get the string version of a @c Type. + * @brief Get the string version of a @ref Type. * - * Return the string version of a @c Type. + * Return the string version of a @ref Type. * * @param type The type for which we want the string version. * - * @return The string version of the @c Type. + * @return The string version of the @ref Type. */ static std::string typeAsString(Type type); /** - * @brief Get the @c AnalyserEquationAst for this @c AnalyserEquation. + * @brief Get the @ref AnalyserEquationAst for this @ref AnalyserEquation. * - * Return the @c AnalyserEquationAst for this @c AnalyserEquation. + * Return the @ref AnalyserEquationAst for this @ref AnalyserEquation. * - * @return The @c AnalyserEquationAst. + * @return The @ref AnalyserEquationAst. */ AnalyserEquationAstPtr ast() const; /** - * @brief Get the list of @c AnalyserEquation dependencies. + * @brief Get the list of @ref AnalyserEquation dependencies. * - * Return the list of @c AnalyserEquation items which correspond to the - * equations on which this @c AnalyserEquation depends. + * Return the list of @ref AnalyserEquation items which correspond to the + * equations on which this @ref AnalyserEquation depends. * - * @return The list of @c AnalyserEquation dependencies. + * @return The list of @ref AnalyserEquation dependencies. */ std::vector dependencies() const; /** - * @brief Test to determine if this @c AnalyserEquation relies on states + * @brief Test to determine if this @ref AnalyserEquation relies on states * and/or rates. * - * Test to determine if this @c AnalyserEquation relies on states and/or + * Test to determine if this @ref AnalyserEquation relies on states and/or * rates, return @c true if it does and @c false otherwise. * - * @return @c true if this @c AnalyserEquation relies on states and/or + * @return @c true if this @ref AnalyserEquation relies on states and/or * rates, @c false otherwise. */ bool isStateRateBased() const; /** - * @brief Get the @c AnalyserVariable for this @c AnalyserEquation. + * @brief Get the @ref AnalyserVariable for this @ref AnalyserEquation. * - * Return the @c AnalyserVariable for this @c AnalyserEquation. + * Return the @ref AnalyserVariable for this @ref AnalyserEquation. * - * @return The @c AnalyserVariable. + * @return The @ref AnalyserVariable. */ AnalyserVariablePtr variable() const; diff --git a/src/api/libcellml/analyserequationast.h b/src/api/libcellml/analyserequationast.h index 922d49dfc5..cffb23a5ca 100644 --- a/src/api/libcellml/analyserequationast.h +++ b/src/api/libcellml/analyserequationast.h @@ -158,22 +158,22 @@ class LIBCELLML_EXPORT AnalyserEquationAst static AnalyserEquationAstPtr create() noexcept; /** - * @brief Get the @c Type of this @ref AnalyserEquationAst. + * @brief Get the @ref Type of this @ref AnalyserEquationAst. * - * Return the @c Type of this @ref AnalyserEquationAst. + * Return the @ref Type of this @ref AnalyserEquationAst. * - * @return The @c Type. + * @return The @ref Type. */ Type type() const; /** - * @brief Get the string version of a @c Type. + * @brief Get the string version of a @ref Type. * - * Return the string version of a @c Type. + * Return the string version of a @ref Type. * * @param type The type for which we want the string version. * - * @return The string version of the @c Type. + * @return The string version of the @ref Type. */ static std::string typeAsString(Type type); @@ -206,20 +206,20 @@ class LIBCELLML_EXPORT AnalyserEquationAst void setValue(const std::string &value); /** - * @brief Get the @c Variable for this @ref AnalyserEquationAst. + * @brief Get the @ref Variable for this @ref AnalyserEquationAst. * - * Return the @c Variable for this @ref AnalyserEquationAst. + * Return the @ref Variable for this @ref AnalyserEquationAst. * * @return The variable. */ VariablePtr variable() const; /** - * @brief Set the @c Variable for this @ref AnalyserEquationAst. + * @brief Set the @ref Variable for this @ref AnalyserEquationAst. * - * Set the @c Variable for this @ref AnalyserEquationAst. + * Set the @ref Variable for this @ref AnalyserEquationAst. * - * @param variable The @c Variable to be set as the variable for this + * @param variable The @ref Variable to be set as the variable for this * @ref AnalyserEquationAst. */ void setVariable(const VariablePtr &variable); diff --git a/src/api/libcellml/analyserexternalvariable.h b/src/api/libcellml/analyserexternalvariable.h index 131e07c46f..c51f0fe2ee 100644 --- a/src/api/libcellml/analyserexternalvariable.h +++ b/src/api/libcellml/analyserexternalvariable.h @@ -40,31 +40,31 @@ class LIBCELLML_EXPORT AnalyserExternalVariable AnalyserExternalVariable &operator=(AnalyserExternalVariable rhs) = delete; /**< Assignment operator, @private. */ /** - * @brief Create an @c AnalyserExternalVariable object. + * @brief Create an @ref AnalyserExternalVariable object. * - * Factory method to create an @c AnalyserExternalVariable. Create an + * Factory method to create an @ref AnalyserExternalVariable. Create an * analyser external variable with:: * * auto variable = libcellml::Variable::create(); * auto analyserExternalVariable = libcellml::AnalyserExternalVariable::create(variable); * - * @return A smart pointer to a @c AnalyserExternalVariable object. + * @return A smart pointer to a @ref AnalyserExternalVariable object. */ static AnalyserExternalVariablePtr create(const VariablePtr &variable) noexcept; /** * @brief Get the @ref Variable associated with this - * @c AnalyserExternalVariable. + * @ref AnalyserExternalVariable. * * Return a reference to the @ref Variable associated with this - * @c AnalyserExternalVariable. + * @ref AnalyserExternalVariable. * * @return The @ref Variable associated with this @ref AnalyserExternalVariable. */ VariablePtr variable() const; /** - * @brief Add a dependency to this @c AnalyserExternalVariable. + * @brief Add a dependency to this @ref AnalyserExternalVariable. * * Add the given @ref Variable as a dependency of this * @ref AnalyserExternalVariable, but only if the given @ref Variable or its @@ -92,14 +92,14 @@ class LIBCELLML_EXPORT AnalyserExternalVariable * @overload * * @brief Remove the dependency with the given @p variableName in the - * @c Component with the given @p componentName in the given @p model. + * @ref Component with the given @p componentName in the given @p model. * * Remove the dependency found that matches the given @p variableName in the - * @c Component with the given @p componentName in the given @p model. + * @ref Component with the given @p componentName in the given @p model. * - * @param model The pointer to the @c Model which contains the dependency to + * @param model The pointer to the @ref Model which contains the dependency to * remove. - * @param componentName The name of the @c Component which contains the + * @param componentName The name of the @ref Component which contains the * dependency to remove. * @param variableName The name of the dependency to remove. * @@ -132,18 +132,18 @@ class LIBCELLML_EXPORT AnalyserExternalVariable /** * @brief Test to see if the dependency with the given @p variableName in - * the @c Component with the given @p componentName in the given @p model is + * the @ref Component with the given @p componentName in the given @p model is * contained within this @ref AnalyserExternalVariable's list of dependencies. * * Test to see if the dependency with the the given @p variableName in the - * @c Component with the given @p componentName in the given @p model is + * @ref Component with the given @p componentName in the given @p model is * contained within this @ref AnalyserExternalVariable's list of dependencies. * Return @c true if the dependency is in this @ref AnalyserExternalVariable's * list of dependencies and @c false otherwise. * - * @param model The pointer to the @c Model which contains the dependency to + * @param model The pointer to the @ref Model which contains the dependency to * test. - * @param componentName The name of the @c Component which contains the + * @param componentName The name of the @ref Component which contains the * dependency to test. * @param variableName The name of the dependency to test. * @@ -190,18 +190,18 @@ class LIBCELLML_EXPORT AnalyserExternalVariable * * @brief Get the dependency with the given @p name. * - * Return the dependency with the given @p variableName in the @c Component + * Return the dependency with the given @p variableName in the @ref Component * with the given @p componentName in the given @p model. If no such * dependency is contained within the @ref AnalyserExternalVariable, a * @c nullptr is returned. * - * @param model The pointer to the @c Model which contains the dependency to + * @param model The pointer to the @ref Model which contains the dependency to * retrieve. - * @param componentName The name of the @c Component which contains the + * @param componentName The name of the @ref Component which contains the * dependency to retrieve. * @param variableName The name of the dependency to retrieve. * - * @return The dependency with the given @p variableName in the @c Component + * @return The dependency with the given @p variableName in the @ref Component * with the given @p componentName in the given @p model on success, * @c nullptr on failure. */ @@ -213,7 +213,7 @@ class LIBCELLML_EXPORT AnalyserExternalVariable * @brief Get the list of @ref Variable dependencies. * * Return the list of @ref Variable items on which this - * @c AnalyserExternalVariable depends. + * @ref AnalyserExternalVariable depends. * * @return The list of @ref Variable dependencies. */ diff --git a/src/api/libcellml/analysermodel.h b/src/api/libcellml/analysermodel.h index 8ae4ae499f..45f15cd6a4 100644 --- a/src/api/libcellml/analysermodel.h +++ b/src/api/libcellml/analysermodel.h @@ -56,54 +56,54 @@ class LIBCELLML_EXPORT AnalyserModel AnalyserModel &operator=(AnalyserModel rhs) = delete; /**< Assignment operator, @private. */ /** - * @brief Test to determine if @c AnalyserModel is a valid model. + * @brief Test to determine if @ref AnalyserModel is a valid model. * - * Test to determine if @c AnalyserModel is a valid model, return @c true if + * Test to determine if @ref AnalyserModel is a valid model, return @c true if * it is a valid model (i.e. either an algebraic or an ODE model) and * @c false otherwise. * - * @return @c true if @c AnalyserModel is a valid model, @c false otherwise. + * @return @c true if @ref AnalyserModel is a valid model, @c false otherwise. */ bool isValid() const; /** - * @brief Get the @c Type of the @c AnalyserModel. + * @brief Get the @ref Type of the @ref AnalyserModel. * - * Return the @c Type of the @c AnalyserModel. + * Return the @ref Type of the @ref AnalyserModel. * - * @return The @c Type. + * @return The @ref Type. */ Type type() const; /** - * @brief Get the string version of a @c Type. + * @brief Get the string version of a @ref Type. * - * Return the string version of a @c Type. + * Return the string version of a @ref Type. * * @param type The type for which we want the string version. * - * @return The string version of the @c Type. + * @return The string version of the @ref Type. */ static std::string typeAsString(Type type); /** - * @brief Test to determine if this @c AnalyserModel has external variables. + * @brief Test to determine if this @ref AnalyserModel has external variables. * - * Test to determine if this @c AnalyserModel has external variables, return + * Test to determine if this @ref AnalyserModel has external variables, return * @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel has external variables, @c false + * @return @c true if @ref AnalyserModel has external variables, @c false * otherwise. */ bool hasExternalVariables() const; /** - * @brief Get the @c Variable of integration. + * @brief Get the @ref Variable of integration. * - * Return the @c Variable of integration of the @c AnalyserModel, in the + * Return the @ref Variable of integration of the @ref AnalyserModel, in the * case of an ODE model, @c nullptr otherwise. * - * @return The @c Variable of integration, if an ODE model, @c nullptr + * @return The @ref Variable of integration, if an ODE model, @c nullptr * otherwise. */ AnalyserVariablePtr voi() const; @@ -111,7 +111,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the number of states. * - * Return the number of states in the @c AnalyserModel. + * Return the number of states in the @ref AnalyserModel. * * @return The number of states. */ @@ -120,7 +120,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the states. * - * Return the states in the @c AnalyserModel. + * Return the states in the @ref AnalyserModel. * * @return The states as a @c std::vector. */ @@ -129,7 +129,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the state at @p index. * - * Return the state at the index @p index for the @c AnalyserModel. + * Return the state at the index @p index for the @ref AnalyserModel. * * @param index The index of the state to return. * @@ -141,7 +141,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the number of variables. * - * Return the number of variables in the @c AnalyserModel. + * Return the number of variables in the @ref AnalyserModel. * * @return The number of variables. */ @@ -150,7 +150,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the variables. * - * Return the variables in the @c AnalyserModel. + * Return the variables in the @ref AnalyserModel. * * @return The variables as a @c std::vector. */ @@ -159,7 +159,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the variable at @p index. * - * Return the variable at the index @p index for the @c AnalyserModel. + * Return the variable at the index @p index for the @ref AnalyserModel. * * @param index The index of the variable to return. * @@ -171,7 +171,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the number of equations. * - * Return the number of equations in the @c AnalyserModel. + * Return the number of equations in the @ref AnalyserModel. * * @return The number of equations. */ @@ -180,7 +180,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the equations. * - * Return the equations in the @c AnalyserModel. + * Return the equations in the @ref AnalyserModel. * * @return The equations as a @c std::vector. */ @@ -189,7 +189,7 @@ class LIBCELLML_EXPORT AnalyserModel /** * @brief Get the equation at @p index. * - * Return the equation at the index @p index for the @c AnalyserModel. + * Return the equation at the index @p index for the @ref AnalyserModel. * * @param index The index of the equation to return. * @@ -199,282 +199,282 @@ class LIBCELLML_EXPORT AnalyserModel AnalyserEquationPtr equation(size_t index) const; /** - * @brief Test to determine if @c AnalyserModel needs an "equal to" + * @brief Test to determine if @ref AnalyserModel needs an "equal to" * function. * - * Test to determine if @c AnalyserModel needs an "equal to" function, + * Test to determine if @ref AnalyserModel needs an "equal to" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "equal to" function, + * @return @c true if @ref AnalyserModel needs an "equal to" function, * @c false otherwise. */ bool needEqFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "not equal to" + * @brief Test to determine if @ref AnalyserModel needs a "not equal to" * function. * - * Test to determine if @c AnalyserModel needs a "not equal to" function, + * Test to determine if @ref AnalyserModel needs a "not equal to" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "not equal to" function, + * @return @c true if @ref AnalyserModel needs a "not equal to" function, * @c false otherwise. */ bool needNeqFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "less than" + * @brief Test to determine if @ref AnalyserModel needs a "less than" * function. * - * Test to determine if @c AnalyserModel needs a "less than" function, + * Test to determine if @ref AnalyserModel needs a "less than" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "less than" function, + * @return @c true if @ref AnalyserModel needs a "less than" function, * @c false otherwise. */ bool needLtFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "less than or equal + * @brief Test to determine if @ref AnalyserModel needs a "less than or equal * to" function. * - * Test to determine if @c AnalyserModel needs a "less than or equal to" + * Test to determine if @ref AnalyserModel needs a "less than or equal to" * function, return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "less than or equal to" + * @return @c true if @ref AnalyserModel needs a "less than or equal to" * function, @c false otherwise. */ bool needLeqFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "greater than" + * @brief Test to determine if @ref AnalyserModel needs a "greater than" * function. * - * Test to determine if @c AnalyserModel needs a "greater than" function, + * Test to determine if @ref AnalyserModel needs a "greater than" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "greater than" function, + * @return @c true if @ref AnalyserModel needs a "greater than" function, * @c false otherwise. */ bool needGtFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "greater than or + * @brief Test to determine if @ref AnalyserModel needs a "greater than or * equal to" function. * - * Test to determine if @c AnalyserModel needs a "greater than or equal to" + * Test to determine if @ref AnalyserModel needs a "greater than or equal to" * function, return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "greater than or equal to" + * @return @c true if @ref AnalyserModel needs a "greater than or equal to" * function, @c false otherwise. */ bool needGeqFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs an "and" function. + * @brief Test to determine if @ref AnalyserModel needs an "and" function. * - * Test to determine if @c AnalyserModel needs an "and" function, return + * Test to determine if @ref AnalyserModel needs an "and" function, return * @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "and" function, @c false + * @return @c true if @ref AnalyserModel needs an "and" function, @c false * otherwise. */ bool needAndFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs an "or" function. + * @brief Test to determine if @ref AnalyserModel needs an "or" function. * - * Test to determine if @c AnalyserModel needs an "or" function, return + * Test to determine if @ref AnalyserModel needs an "or" function, return * @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "or" function, @c false + * @return @c true if @ref AnalyserModel needs an "or" function, @c false * otherwise. */ bool needOrFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "exclusive or" + * @brief Test to determine if @ref AnalyserModel needs a "exclusive or" * function. * - * Test to determine if @c AnalyserModel needs a "exclusive or" function, + * Test to determine if @ref AnalyserModel needs a "exclusive or" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "exclusive or" function, + * @return @c true if @ref AnalyserModel needs a "exclusive or" function, * @c false otherwise. */ bool needXorFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "not" function. + * @brief Test to determine if @ref AnalyserModel needs a "not" function. * - * Test to determine if @c AnalyserModel needs a "not" function, return + * Test to determine if @ref AnalyserModel needs a "not" function, return * @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "not" function, @c false + * @return @c true if @ref AnalyserModel needs a "not" function, @c false * otherwise. */ bool needNotFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "minimum" function. + * @brief Test to determine if @ref AnalyserModel needs a "minimum" function. * - * Test to determine if @c AnalyserModel needs a "minimum" function, return + * Test to determine if @ref AnalyserModel needs a "minimum" function, return * @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "minimum" function, @c false + * @return @c true if @ref AnalyserModel needs a "minimum" function, @c false * otherwise. */ bool needMinFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "maximum" function. + * @brief Test to determine if @ref AnalyserModel needs a "maximum" function. * - * Test to determine if @c AnalyserModel needs a "maximum" function, return + * Test to determine if @ref AnalyserModel needs a "maximum" function, return * @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "maximum" function, @c false + * @return @c true if @ref AnalyserModel needs a "maximum" function, @c false * otherwise. */ bool needMaxFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "secant" function. + * @brief Test to determine if @ref AnalyserModel needs a "secant" function. * - * Test to determine if @c AnalyserModel needs a "secant" function, return + * Test to determine if @ref AnalyserModel needs a "secant" function, return * @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "secant" function, @c false + * @return @c true if @ref AnalyserModel needs a "secant" function, @c false * otherwise. */ bool needSecFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "cosecant" function. + * @brief Test to determine if @ref AnalyserModel needs a "cosecant" function. * - * Test to determine if @c AnalyserModel needs a "cosecant" function, return + * Test to determine if @ref AnalyserModel needs a "cosecant" function, return * @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "cosecant" function, @c false + * @return @c true if @ref AnalyserModel needs a "cosecant" function, @c false * otherwise. */ bool needCscFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "cotangent" + * @brief Test to determine if @ref AnalyserModel needs a "cotangent" * function. * - * Test to determine if @c AnalyserModel needs a "cotangent" function, + * Test to determine if @ref AnalyserModel needs a "cotangent" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "cotangent" function, + * @return @c true if @ref AnalyserModel needs a "cotangent" function, * @c false otherwise. */ bool needCotFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "hyperbolic secant" + * @brief Test to determine if @ref AnalyserModel needs a "hyperbolic secant" * function. * - * Test to determine if @c AnalyserModel needs a "hyperbolic secant" + * Test to determine if @ref AnalyserModel needs a "hyperbolic secant" * function, return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "hyperbolic secant" function, + * @return @c true if @ref AnalyserModel needs a "hyperbolic secant" function, * @c false otherwise. */ bool needSechFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "hyperbolic + * @brief Test to determine if @ref AnalyserModel needs a "hyperbolic * cosecant" function. * - * Test to determine if @c AnalyserModel needs a "hyperbolic cosecant" + * Test to determine if @ref AnalyserModel needs a "hyperbolic cosecant" * function, return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "hyperbolic cosecant" + * @return @c true if @ref AnalyserModel needs a "hyperbolic cosecant" * function, @c false otherwise. */ bool needCschFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs a "hyperbolic + * @brief Test to determine if @ref AnalyserModel needs a "hyperbolic * cotangent" function. * - * Test to determine if @c AnalyserModel needs a "hyperbolic cotangent" + * Test to determine if @ref AnalyserModel needs a "hyperbolic cotangent" * function, return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs a "hyperbolic cotangent" + * @return @c true if @ref AnalyserModel needs a "hyperbolic cotangent" * function, @c false otherwise. */ bool needCothFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs an "arc secant" + * @brief Test to determine if @ref AnalyserModel needs an "arc secant" * function. * - * Test to determine if @c AnalyserModel needs an "arc secant" function, + * Test to determine if @ref AnalyserModel needs an "arc secant" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "arc secant" function, + * @return @c true if @ref AnalyserModel needs an "arc secant" function, * @c false otherwise. */ bool needAsecFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs an "arc cosecant" + * @brief Test to determine if @ref AnalyserModel needs an "arc cosecant" * function. * - * Test to determine if @c AnalyserModel needs an "arc cosecant" function, + * Test to determine if @ref AnalyserModel needs an "arc cosecant" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "arc cosecant" function, + * @return @c true if @ref AnalyserModel needs an "arc cosecant" function, * @c false otherwise. */ bool needAcscFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs an "arc cotangent" + * @brief Test to determine if @ref AnalyserModel needs an "arc cotangent" * function. * - * Test to determine if @c AnalyserModel needs an "arc cotangent" function, + * Test to determine if @ref AnalyserModel needs an "arc cotangent" function, * return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "arc cotangent" function, + * @return @c true if @ref AnalyserModel needs an "arc cotangent" function, * @c false otherwise. */ bool needAcotFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs an "arc hyperbolic + * @brief Test to determine if @ref AnalyserModel needs an "arc hyperbolic * secant" function. * - * Test to determine if @c AnalyserModel needs an "arc hyperbolic secant" + * Test to determine if @ref AnalyserModel needs an "arc hyperbolic secant" * function, return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "arc hyperbolic secant" + * @return @c true if @ref AnalyserModel needs an "arc hyperbolic secant" * function, @c false otherwise. */ bool needAsechFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs an "arc hyperbolic + * @brief Test to determine if @ref AnalyserModel needs an "arc hyperbolic * cosecant" function. * - * Test to determine if @c AnalyserModel needs an "arc hyperbolic cosecant" + * Test to determine if @ref AnalyserModel needs an "arc hyperbolic cosecant" * function, return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "arc hyperbolic cosecant" + * @return @c true if @ref AnalyserModel needs an "arc hyperbolic cosecant" * function, @c false otherwise. */ bool needAcschFunction() const; /** - * @brief Test to determine if @c AnalyserModel needs an "arc hyperbolic + * @brief Test to determine if @ref AnalyserModel needs an "arc hyperbolic * cotangent" function. * - * Test to determine if @c AnalyserModel needs an "arc hyperbolic + * Test to determine if @ref AnalyserModel needs an "arc hyperbolic * cotangent" function, return @c true if it does and @c false otherwise. * - * @return @c true if @c AnalyserModel needs an "arc hyperbolic cotangent" + * @return @c true if @ref AnalyserModel needs an "arc hyperbolic cotangent" * function, @c false otherwise. */ bool needAcothFunction() const; @@ -491,13 +491,13 @@ class LIBCELLML_EXPORT AnalyserModel * and their result cached. So, if you test two variables that were tested * during the analysis then the cached result will be returned otherwise the * two variables will be properly tested and their result cached. This works - * because an @c AnalyserModel always refers to a static version of a - * @c Model. However, this might break if a @c Model is modified after it + * because an @ref AnalyserModel always refers to a static version of a + * @ref Model. However, this might break if a @ref Model is modified after it * has been analysed. * - * @param variable1 The @c Variable to test if it is equivalent to + * @param variable1 The @ref Variable to test if it is equivalent to * @p variable2. - * @param variable2 The @c Variable that is potentially equivalent to + * @param variable2 The @ref Variable that is potentially equivalent to * @p variable1. * * @return @c true if @p variable1 is equivalent to @p variable2 and diff --git a/src/api/libcellml/analyservariable.h b/src/api/libcellml/analyservariable.h index ce9fe197ca..28f3273159 100644 --- a/src/api/libcellml/analyservariable.h +++ b/src/api/libcellml/analyservariable.h @@ -55,40 +55,40 @@ class LIBCELLML_EXPORT AnalyserVariable AnalyserVariable &operator=(AnalyserVariable rhs) = delete; /**< Assignment operator, @private. */ /** - * @brief Get the @c Type of this @c AnalyserVariable. + * @brief Get the @ref Type of this @ref AnalyserVariable. * - * Return the @c Type of this @c AnalyserVariable. + * Return the @ref Type of this @ref AnalyserVariable. * - * @return The @c Type. + * @return The @ref Type. */ Type type() const; /** - * @brief Get the string version of a @c Type. + * @brief Get the string version of a @ref Type. * - * Return the string version of a @c Type. + * Return the string version of a @ref Type. * * @param type The type for which we want the string version. * - * @return The string version of the @c Type. + * @return The string version of the @ref Type. */ static std::string typeAsString(Type type); /** - * @brief Get the index of this @c AnalyserVariable. + * @brief Get the index of this @ref AnalyserVariable. * - * Return the index of this @c AnalyserVariable. + * Return the index of this @ref AnalyserVariable. * * @return The index. */ size_t index() const; /** - * @brief Get the initialising @c Variable for this @c AnalyserVariable. + * @brief Get the initialising @ref Variable for this @ref AnalyserVariable. * - * Return the initialising @c Variable for this @c AnalyserVariable. It is - * used to retrieve the initial value of the @c Variable, if there is one. - * It may or may not be the same @c Variable as the one returned by + * Return the initialising @ref Variable for this @ref AnalyserVariable. It is + * used to retrieve the initial value of the @ref Variable, if there is one. + * It may or may not be the same @ref Variable as the one returned by * @sa variable. If it is not the same (e.g., a state variable is * initialised in one component and computed in another) then the initial * value retrieved from this variable may have to be scaled to account for @@ -99,33 +99,33 @@ class LIBCELLML_EXPORT AnalyserVariable * @sa variable * @sa scalingFactor * - * @return The initialising @c Variable, if there is one, or @c nullptr. + * @return The initialising @ref Variable, if there is one, or @c nullptr. */ VariablePtr initialisingVariable() const; /** - * @brief Get the (primary) @c Variable for this @c AnalyserVariable. + * @brief Get the (primary) @ref Variable for this @ref AnalyserVariable. * - * Return the (primary) @c Variable for this @c AnalyserVariable. Its - * @c Component is the one in which the @c Variable is first defined (in the + * Return the (primary) @ref Variable for this @ref AnalyserVariable. Its + * @ref Component is the one in which the @ref Variable is first defined (in the * case of the variable of integration), initialised (in the case of a * constant) or computed (in the case of a state, computed constant or - * algebraic variable). It may or may not be the same @c Variable as the one + * algebraic variable). It may or may not be the same @ref Variable as the one * returned by @sa initialisingVariable (e.g., a state variable is * initialised in one component and computed in another). * * @sa initialisingVariable * - * @return The @c Variable. + * @return The @ref Variable. */ VariablePtr variable() const; /** - * @brief Get the @c AnalyserEquation for this @c AnalyserVariable. + * @brief Get the @ref AnalyserEquation for this @ref AnalyserVariable. * - * Return the @c AnalyserEquation for this @c AnalyserVariable. + * Return the @ref AnalyserEquation for this @ref AnalyserVariable. * - * @return The @c AnalyserEquation. + * @return The @ref AnalyserEquation. */ AnalyserEquationPtr equation() const; diff --git a/src/api/libcellml/generator.h b/src/api/libcellml/generator.h index 7177efe7d8..704cd00f4d 100644 --- a/src/api/libcellml/generator.h +++ b/src/api/libcellml/generator.h @@ -39,69 +39,69 @@ class LIBCELLML_EXPORT Generator Generator &operator=(Generator rhs) = delete; /**< Assignment operator, @private. */ /** - * @brief Create a @c Generator object. + * @brief Create a @ref Generator object. * - * Factory method to create a @c Generator. Create a generator with:: + * Factory method to create a @ref Generator. Create a generator with:: * * @code * auto generator = libcellml::Generator::create(); * @endcode * - * @return A smart pointer to a @c Generator object. + * @return A smart pointer to a @ref Generator object. */ static GeneratorPtr create() noexcept; /** - * @brief Get the @c GeneratorProfile. + * @brief Get the @ref GeneratorProfile. * - * Get the @c GeneratorProfile used by this @c Generator. + * Get the @ref GeneratorProfile used by this @ref Generator. * - * @return The @c GeneratorProfile used. + * @return The @ref GeneratorProfile used. */ GeneratorProfilePtr profile(); /** - * @brief Set the @c GeneratorProfile. + * @brief Set the @ref GeneratorProfile. * - * Set the @c GeneratorProfile to be used by this @c Generator. + * Set the @ref GeneratorProfile to be used by this @ref Generator. * - * @param profile The @c GeneratorProfile to set. + * @param profile The @ref GeneratorProfile to set. */ void setProfile(const GeneratorProfilePtr &profile); /** - * @brief Get the @c AnalyserModel. + * @brief Get the @ref AnalyserModel. * - * Get the @c AnalyserModel used by this @c Generator. + * Get the @ref AnalyserModel used by this @ref Generator. * - * @return The @c AnalyserModel used. + * @return The @ref AnalyserModel used. */ AnalyserModelPtr model(); /** - * @brief Set the @c AnalyserModel. + * @brief Set the @ref AnalyserModel. * - * Set the @c AnalyserModel to be used by this @c Generator. + * Set the @ref AnalyserModel to be used by this @ref Generator. * - * @param model The @c AnalyserModel to set. + * @param model The @ref AnalyserModel to set. */ void setModel(const AnalyserModelPtr &model); /** - * @brief Get the interface code for the @c AnalyserModel. + * @brief Get the interface code for the @ref AnalyserModel. * - * Return the interface code for the @c AnalyserModel, using the - * @c GeneratorProfile. + * Return the interface code for the @ref AnalyserModel, using the + * @ref GeneratorProfile. * * @return The interface code as a @c std::string. */ std::string interfaceCode() const; /** - * @brief Get the implementation code for the @c AnalyserModel. + * @brief Get the implementation code for the @ref AnalyserModel. * - * Return the implementation code for the @c AnalyserModel, using the - * @c GeneratorProfile. + * Return the implementation code for the @ref AnalyserModel, using the + * @ref GeneratorProfile. * * @return The implementation code as a @c std::string. */ diff --git a/src/api/libcellml/generatorprofile.h b/src/api/libcellml/generatorprofile.h index 1369f8e372..99a4448ffa 100644 --- a/src/api/libcellml/generatorprofile.h +++ b/src/api/libcellml/generatorprofile.h @@ -50,72 +50,72 @@ class LIBCELLML_EXPORT GeneratorProfile GeneratorProfile &operator=(GeneratorProfile rhs) = delete; /**< Assignment operator, @private. */ /** - * @brief Create a @c GeneratorProfile object. + * @brief Create a @ref GeneratorProfile object. * - * Factory method to create a @c GeneratorProfile. Create a + * Factory method to create a @ref GeneratorProfile. Create a * generator profile with:: * * GeneratorProfilePtr generatorProfile = libcellml::GeneratorProfile::create(); * - * @return A smart pointer to a @c GeneratorProfile object. + * @return A smart pointer to a @ref GeneratorProfile object. */ static GeneratorProfilePtr create(Profile profile = Profile::C) noexcept; // Whether the profile is official. /** - * @brief Get the @c Profile for this @c GeneratorProfile. + * @brief Get the @ref Profile for this @ref GeneratorProfile. * - * Return the @c Profile for this @c GeneratorProfile. + * Return the @ref Profile for this @ref GeneratorProfile. * - * @return The @c Profile for this @c GeneratorProfile. + * @return The @ref Profile for this @ref GeneratorProfile. */ Profile profile() const; /** - * @brief Get the string version of a @c Profile. + * @brief Get the string version of a @ref Profile. * - * Return the string version of a @c Profile. + * Return the string version of a @ref Profile. * * @param profile The profile for which we want the string version. * - * @return The string version of the @c Profile. + * @return The string version of the @ref Profile. */ static std::string profileAsString(Profile profile); /** - * @brief Set the @c Profile. + * @brief Set the @ref Profile. * - * Set this @c GeneratorProfile to the given @c Profile . + * Set this @ref GeneratorProfile to the given @ref Profile . * - * @param profile The @c Profile to use. + * @param profile The @ref Profile to use. */ void setProfile(Profile profile); // Whether the profile requires an interface to be generated. /** - * @brief Test if this @c GeneratorProfile requires an interface to be + * @brief Test if this @ref GeneratorProfile requires an interface to be * generated. * - * Test if this @c GeneratorProfile has an requires an interface to be + * Test if this @ref GeneratorProfile has an requires an interface to be * generated. * - * @return @c true if the @c GeneratorProfile has an requires an interface + * @return @c true if the @ref GeneratorProfile has an requires an interface * to be generated, * @c false otherwise. */ bool hasInterface() const; /** - * @brief Set whether this @c GeneratorProfile has an requires an interface + * @brief Set whether this @ref GeneratorProfile has an requires an interface * to be generated. * - * Set whether this @c GeneratorProfile has an requires an interface to be + * Set whether this @ref GeneratorProfile has an requires an interface to be * generated. * * @param hasInterface A @c bool to determine whether this - * @c GeneratorProfile has an requires an interface to be generated. + * @ref GeneratorProfile has an requires an interface to be generated. */ void setHasInterface(bool hasInterface); @@ -361,213 +361,213 @@ class LIBCELLML_EXPORT GeneratorProfile void setNotString(const std::string ¬String); /** - * @brief Test if this @c GeneratorProfile has an "equal to" operator. + * @brief Test if this @ref GeneratorProfile has an "equal to" operator. * - * Test if this @c GeneratorProfile has an "equal to" operator. + * Test if this @ref GeneratorProfile has an "equal to" operator. * - * @return @c true if the @c GeneratorProfile has an "equal to" operator, + * @return @c true if the @ref GeneratorProfile has an "equal to" operator, * @c false otherwise. */ bool hasEqOperator() const; /** - * @brief Set whether this @c GeneratorProfile has an "equal to" operator. + * @brief Set whether this @ref GeneratorProfile has an "equal to" operator. * - * Set whether this @c GeneratorProfile has an "equal to" operator. + * Set whether this @ref GeneratorProfile has an "equal to" operator. * * @param hasEqOperator A @c bool to determine whether this - * @c GeneratorProfile has an "equal to" operator. + * @ref GeneratorProfile has an "equal to" operator. */ void setHasEqOperator(bool hasEqOperator); /** - * @brief Test if this @c GeneratorProfile has a "not equal to" operator. + * @brief Test if this @ref GeneratorProfile has a "not equal to" operator. * - * Test if this @c GeneratorProfile has a "not equal to" operator. + * Test if this @ref GeneratorProfile has a "not equal to" operator. * - * @return @c true if the @c GeneratorProfile has a "not equal to" + * @return @c true if the @ref GeneratorProfile has a "not equal to" * operator, @c false otherwise. */ bool hasNeqOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "not equal to" + * @brief Set whether this @ref GeneratorProfile has a "not equal to" * operator. * - * Set whether this @c GeneratorProfile has a "not equal to" operator. + * Set whether this @ref GeneratorProfile has a "not equal to" operator. * * @param hasNeqOperator A @c bool to determine whether this - * @c GeneratorProfile has a "not equal to" operator. + * @ref GeneratorProfile has a "not equal to" operator. */ void setHasNeqOperator(bool hasNeqOperator); /** - * @brief Test if this @c GeneratorProfile has a "less than" operator. + * @brief Test if this @ref GeneratorProfile has a "less than" operator. * - * Test if this @c GeneratorProfile has a "less than" operator. + * Test if this @ref GeneratorProfile has a "less than" operator. * - * @return @c true if the @c GeneratorProfile has a "less than" operator, + * @return @c true if the @ref GeneratorProfile has a "less than" operator, * @c false otherwise. */ bool hasLtOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "less than" operator. + * @brief Set whether this @ref GeneratorProfile has a "less than" operator. * - * Set whether this @c GeneratorProfile has a "less than" operator. + * Set whether this @ref GeneratorProfile has a "less than" operator. * * @param hasLtOperator A @c bool to determine whether this - * @c GeneratorProfile has a "less than" operator. + * @ref GeneratorProfile has a "less than" operator. */ void setHasLtOperator(bool hasLtOperator); /** - * @brief Test if this @c GeneratorProfile has a "less than or equal to" + * @brief Test if this @ref GeneratorProfile has a "less than or equal to" * operator. * - * Test if this @c GeneratorProfile has a "less than or equal to" operator. + * Test if this @ref GeneratorProfile has a "less than or equal to" operator. * - * @return @c true if the @c GeneratorProfile has a "less than or equal to" + * @return @c true if the @ref GeneratorProfile has a "less than or equal to" * operator, * @c false otherwise. */ bool hasLeqOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "less than or equal to" + * @brief Set whether this @ref GeneratorProfile has a "less than or equal to" * operator. * - * Set whether this @c GeneratorProfile has a "less than or equal to" + * Set whether this @ref GeneratorProfile has a "less than or equal to" * operator. * * @param hasLeqOperator A @c bool to determine whether this - * @c GeneratorProfile has a "less than or equal to" operator. + * @ref GeneratorProfile has a "less than or equal to" operator. */ void setHasLeqOperator(bool hasLeqOperator); /** - * @brief Test if this @c GeneratorProfile has a "greater than" operator. + * @brief Test if this @ref GeneratorProfile has a "greater than" operator. * - * Test if this @c GeneratorProfile has a "greater than" operator. + * Test if this @ref GeneratorProfile has a "greater than" operator. * - * @return @c true if the @c GeneratorProfile has a "greater than" operator, + * @return @c true if the @ref GeneratorProfile has a "greater than" operator, * @c false otherwise. */ bool hasGtOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "greater than" + * @brief Set whether this @ref GeneratorProfile has a "greater than" * operator. * - * Set whether this @c GeneratorProfile has a "greater than" operator. + * Set whether this @ref GeneratorProfile has a "greater than" operator. * * @param hasGtOperator A @c bool to determine whether this - * @c GeneratorProfile has a "greater than" operator. + * @ref GeneratorProfile has a "greater than" operator. */ void setHasGtOperator(bool hasGtOperator); /** - * @brief Test if this @c GeneratorProfile has a "greater than or equal to" + * @brief Test if this @ref GeneratorProfile has a "greater than or equal to" * operator. * - * Test if this @c GeneratorProfile has a "greater than or equal to" operator. + * Test if this @ref GeneratorProfile has a "greater than or equal to" operator. * - * @return @c true if the @c GeneratorProfile has a "greater than or equal + * @return @c true if the @ref GeneratorProfile has a "greater than or equal * to" operator, * @c false otherwise. */ bool hasGeqOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "greater than or equal + * @brief Set whether this @ref GeneratorProfile has a "greater than or equal * to" operator. * - * Set whether this @c GeneratorProfile has a "greater than or equal to" + * Set whether this @ref GeneratorProfile has a "greater than or equal to" * operator. * * @param hasGeqOperator A @c bool to determine whether this - * @c GeneratorProfile has a "greater than or equal to" operator. + * @ref GeneratorProfile has a "greater than or equal to" operator. */ void setHasGeqOperator(bool hasGeqOperator); /** - * @brief Test if this @c GeneratorProfile has an "and" operator. + * @brief Test if this @ref GeneratorProfile has an "and" operator. * - * Test if this @c GeneratorProfile has an "and" operator. + * Test if this @ref GeneratorProfile has an "and" operator. * - * @return @c true if the @c GeneratorProfile has an "and" operator, + * @return @c true if the @ref GeneratorProfile has an "and" operator, * @c false otherwise. */ bool hasAndOperator() const; /** - * @brief Set whether this @c GeneratorProfile has an "and" operator. + * @brief Set whether this @ref GeneratorProfile has an "and" operator. * - * Set whether this @c GeneratorProfile has an "and" operator. + * Set whether this @ref GeneratorProfile has an "and" operator. * * @param hasAndOperator A @c bool to determine whether this - * @c GeneratorProfile has an "and" operator. + * @ref GeneratorProfile has an "and" operator. */ void setHasAndOperator(bool hasAndOperator); /** - * @brief Test if this @c GeneratorProfile has an "or" operator. + * @brief Test if this @ref GeneratorProfile has an "or" operator. * - * Test if this @c GeneratorProfile has an "or" operator. + * Test if this @ref GeneratorProfile has an "or" operator. * - * @return @c true if the @c GeneratorProfile has an "or" operator, + * @return @c true if the @ref GeneratorProfile has an "or" operator, * @c false otherwise. */ bool hasOrOperator() const; /** - * @brief Set whether this @c GeneratorProfile has an "or" operator. + * @brief Set whether this @ref GeneratorProfile has an "or" operator. * - * Set whether this @c GeneratorProfile has an "or" operator. + * Set whether this @ref GeneratorProfile has an "or" operator. * * @param hasOrOperator A @c bool to determine whether this - * @c GeneratorProfile has an "or" operator. + * @ref GeneratorProfile has an "or" operator. */ void setHasOrOperator(bool hasOrOperator); /** - * @brief Test if this @c GeneratorProfile has a "exclusive or" operator. + * @brief Test if this @ref GeneratorProfile has a "exclusive or" operator. * - * Test if this @c GeneratorProfile has a "exclusive or" operator. + * Test if this @ref GeneratorProfile has a "exclusive or" operator. * - * @return @c true if the @c GeneratorProfile has a "exclusive or" operator, + * @return @c true if the @ref GeneratorProfile has a "exclusive or" operator, * @c false otherwise. */ bool hasXorOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "exclusive or" + * @brief Set whether this @ref GeneratorProfile has a "exclusive or" * operator. * - * Set whether this @c GeneratorProfile has a "exclusive or" operator. + * Set whether this @ref GeneratorProfile has a "exclusive or" operator. * * @param hasXorOperator A @c bool to determine whether this - * @c GeneratorProfile has a "exclusive or" operator. + * @ref GeneratorProfile has a "exclusive or" operator. */ void setHasXorOperator(bool hasXorOperator); /** - * @brief Test if this @c GeneratorProfile has a "not" operator. + * @brief Test if this @ref GeneratorProfile has a "not" operator. * - * Test if this @c GeneratorProfile has a "not" operator. + * Test if this @ref GeneratorProfile has a "not" operator. * - * @return @c true if the @c GeneratorProfile has a "not" operator, + * @return @c true if the @ref GeneratorProfile has a "not" operator, * @c false otherwise. */ bool hasNotOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "not" operator. + * @brief Set whether this @ref GeneratorProfile has a "not" operator. * - * Set whether this @c GeneratorProfile has a "not" operator. + * Set whether this @ref GeneratorProfile has a "not" operator. * * @param hasNotOperator A @c bool to determine whether this - * @c GeneratorProfile has a "not" operator. + * @ref GeneratorProfile has a "not" operator. */ void setHasNotOperator(bool hasNotOperator); @@ -906,22 +906,22 @@ class LIBCELLML_EXPORT GeneratorProfile void setRemString(const std::string &remString); /** - * @brief Test if this @c GeneratorProfile has a "power" operator. + * @brief Test if this @ref GeneratorProfile has a "power" operator. * - * Test if this @c GeneratorProfile has a "power" operator. + * Test if this @ref GeneratorProfile has a "power" operator. * - * @return @c true if the @c GeneratorProfile has a "power" operator, + * @return @c true if the @ref GeneratorProfile has a "power" operator, * @c false otherwise. */ bool hasPowerOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "power" operator. + * @brief Set whether this @ref GeneratorProfile has a "power" operator. * - * Set whether this @c GeneratorProfile has a "power" operator. + * Set whether this @ref GeneratorProfile has a "power" operator. * * @param hasPowerOperator A @c bool to determine whether this - * @c GeneratorProfile has a "power" operator. + * @ref GeneratorProfile has a "power" operator. */ void setHasPowerOperator(bool hasPowerOperator); @@ -1563,22 +1563,22 @@ class LIBCELLML_EXPORT GeneratorProfile void setPiecewiseElseString(const std::string &piecewiseElseString); /** - * @brief Test if this @c GeneratorProfile has a "conditional" operator. + * @brief Test if this @ref GeneratorProfile has a "conditional" operator. * - * Test if this @c GeneratorProfile has a "conditional" operator. + * Test if this @ref GeneratorProfile has a "conditional" operator. * - * @return @c true if the @c GeneratorProfile has a "conditional" operator, + * @return @c true if the @ref GeneratorProfile has a "conditional" operator, * @c false otherwise. */ bool hasConditionalOperator() const; /** - * @brief Set whether this @c GeneratorProfile has a "conditional" operator. + * @brief Set whether this @ref GeneratorProfile has a "conditional" operator. * - * Set whether this @c GeneratorProfile has a "conditional" operator. + * Set whether this @ref GeneratorProfile has a "conditional" operator. * * @param hasConditionalOperator A @c bool to determine whether this - * @c GeneratorProfile has a "conditional" operator. + * @ref GeneratorProfile has a "conditional" operator. */ void setHasConditionalOperator(bool hasConditionalOperator);