Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of 'override' specifier #1589

Merged
merged 14 commits into from Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Expand Up @@ -148,6 +148,7 @@ jobs:
run: python3 `which scons` build env_vars=all
CXX=clang++-12 CC=clang-12 f90_interface=n extra_lib_dirs=/usr/lib/llvm/lib
-j2 debug=n --debug=time hdf_libdir=$HDF5_LIBDIR hdf_include=$HDF5_INCLUDEDIR
warning_flags='-Wall -Werror -Wsuggest-override'
- name: Test Cantera
run:
python3 `which scons` test show_long_tests=yes verbose_tests=yes --debug=time
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/base/AnyMap.h
Expand Up @@ -767,7 +767,7 @@ class InputFileError : public CanteraError
{
}

virtual string getClass() const {
string getClass() const override {
return "InputFileError";
}
protected:
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/base/Array.h
Expand Up @@ -86,7 +86,7 @@ class Array2D
* @param m This is the number of columns in the new matrix
* @param v Default fill value -> defaults to zero.
*/
void resize(size_t n, size_t m, double v=0.0);
virtual void resize(size_t n, size_t m, double v=0.0);

//! Append a column to the existing matrix using a std vector
/*!
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/base/ExtensionManagerFactory.h
Expand Up @@ -24,7 +24,7 @@ class ExtensionManagerFactory : public Factory<ExtensionManager>
}

//! Delete the static instance of this factory
virtual void deleteFactory();
void deleteFactory() override;

//! Static function that returns the static instance of the factory, creating it
//! if necessary.
Expand Down
4 changes: 1 addition & 3 deletions include/cantera/base/NoExitLogger.h
Expand Up @@ -14,10 +14,8 @@
class NoExitLogger : public Logger {
public:
NoExitLogger() {}
virtual ~NoExitLogger() {}

virtual void error(const string& msg)
{
void error(const string& msg) override {

Check warning on line 18 in include/cantera/base/NoExitLogger.h

View check run for this annotation

Codecov / codecov/patch

include/cantera/base/NoExitLogger.h#L18

Added line #L18 was not covered by tests
std::cerr << msg << std::endl;
}
};
Expand Down
14 changes: 7 additions & 7 deletions include/cantera/base/ctexceptions.h
Expand Up @@ -94,7 +94,7 @@
virtual ~CanteraError() throw() {};

//! Get a description of the error
const char* what() const throw();
const char* what() const throw() override;

//! Method overridden by derived classes to format the error message
virtual string getMessage() const;
Expand Down Expand Up @@ -147,8 +147,8 @@
ArraySizeError(const string& procedure, size_t sz, size_t reqd) :
CanteraError(procedure), sz_(sz), reqd_(reqd) {}

virtual string getMessage() const;
virtual string getClass() const {
string getMessage() const override;
string getClass() const override {

Check warning on line 151 in include/cantera/base/ctexceptions.h

View check run for this annotation

Codecov / codecov/patch

include/cantera/base/ctexceptions.h#L151

Added line #L151 was not covered by tests
return "ArraySizeError";
}

Expand Down Expand Up @@ -178,9 +178,9 @@
IndexError(const string& func, const string& arrayName, size_t m, size_t mmax) :
CanteraError(func), arrayName_(arrayName), m_(m), mmax_(mmax) {}

virtual ~IndexError() throw() {};
virtual string getMessage() const;
virtual string getClass() const {
~IndexError() throw() override {};
string getMessage() const override;
string getClass() const override {
return "IndexError";
}

Expand All @@ -204,7 +204,7 @@
NotImplementedError(const string& func, const string& msg, const Args&... args) :
CanteraError(func, msg, args...) {}

virtual string getClass() const {
string getClass() const override {
return "NotImplementedError";
}
};
Expand Down
6 changes: 3 additions & 3 deletions include/cantera/cython/funcWrapper.h
Expand Up @@ -100,7 +100,7 @@ class CallbackError : public Cantera::CanteraError
Py_XDECREF(m_value);
}

std::string getMessage() const {
std::string getMessage() const override {
std::string msg;

PyObject* name = PyObject_GetAttrString(m_type, "__name__");
Expand Down Expand Up @@ -130,7 +130,7 @@ class CallbackError : public Cantera::CanteraError
return msg;
}

virtual std::string getClass() const {
std::string getClass() const override {
return "Exception";
}

Expand All @@ -148,7 +148,7 @@ class Func1Py : public Cantera::Func1
m_pyobj(pyobj) {
}

double eval(double t) const {
double eval(double t) const override {
void* err[2] = {0, 0};
double y = m_callback(t, m_pyobj, err);
if (err[0]) {
Expand Down
8 changes: 4 additions & 4 deletions include/cantera/cython/utils_utils.h
Expand Up @@ -50,7 +50,7 @@
class PythonLogger : public Cantera::Logger
{
public:
virtual void write(const std::string& s) {
void write(const std::string& s) override {

Check warning on line 53 in include/cantera/cython/utils_utils.h

View check run for this annotation

Codecov / codecov/patch

include/cantera/cython/utils_utils.h#L53

Added line #L53 was not covered by tests
// 1000 bytes is the maximum size permitted by PySys_WriteStdout
static const size_t N = 999;
for (size_t i = 0; i < s.size(); i+=N) {
Expand All @@ -59,12 +59,12 @@
std::cout.flush();
}

virtual void writeendl() {
void writeendl() override {

Check warning on line 62 in include/cantera/cython/utils_utils.h

View check run for this annotation

Codecov / codecov/patch

include/cantera/cython/utils_utils.h#L62

Added line #L62 was not covered by tests
PySys_WriteStdout("%s", "\n");
std::cout.flush();
}

virtual void warn(const std::string& warning, const std::string& msg) {
void warn(const std::string& warning, const std::string& msg) override {
if (mapped_PyWarnings.find(warning) != mapped_PyWarnings.end()) {
PyErr_WarnEx(mapped_PyWarnings[warning], msg.c_str(), 1);
} else {
Expand All @@ -73,7 +73,7 @@
}
}

virtual void error(const std::string& msg) {
void error(const std::string& msg) override {

Check warning on line 76 in include/cantera/cython/utils_utils.h

View check run for this annotation

Codecov / codecov/patch

include/cantera/cython/utils_utils.h#L76

Added line #L76 was not covered by tests
PyErr_SetString(PyExc_RuntimeError, msg.c_str());
}
};
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/extensions/PythonExtensionManager.h
Expand Up @@ -25,7 +25,7 @@ namespace Cantera
class PythonExtensionManager : public ExtensionManager
{
public:
virtual void registerRateBuilders(const string& extensionName) override;
void registerRateBuilders(const string& extensionName) override;

void registerRateBuilder(const string& moduleName,
const string& className, const string& rateName) override;
Expand Down
13 changes: 6 additions & 7 deletions include/cantera/kinetics/Arrhenius.h
Expand Up @@ -28,7 +28,7 @@ class AnyMap;
*/
struct ArrheniusData : public ReactionData
{
virtual bool update(const ThermoPhase& phase, const Kinetics& kin);
bool update(const ThermoPhase& phase, const Kinetics& kin) override;
using ReactionData::update;
};

Expand Down Expand Up @@ -79,15 +79,14 @@ class ArrheniusBase : public ReactionRate
//! equivalent field
void getRateParameters(AnyMap& node) const;

virtual void setParameters(
const AnyMap& node, const UnitStack& rate_units) override;
void setParameters(const AnyMap& node, const UnitStack& rate_units) override;

virtual void getParameters(AnyMap& node) const override;
void getParameters(AnyMap& node) const override;

//! Check rate expression
virtual void check(const string& equation) override;
void check(const string& equation) override;

virtual void validate(const string& equation, const Kinetics& kin) override;
void validate(const string& equation, const Kinetics& kin) override;

//! Return the pre-exponential factor *A* (in m, kmol, s to powers depending
//! on the reaction order)
Expand Down Expand Up @@ -176,7 +175,7 @@ class ArrheniusRate : public ArrheniusBase
return make_unique<MultiRate<ArrheniusRate, ArrheniusData>>();
}

virtual const string type() const override {
const string type() const override {
return "Arrhenius";
}

Expand Down
12 changes: 6 additions & 6 deletions include/cantera/kinetics/BlowersMaselRate.h
Expand Up @@ -20,11 +20,11 @@ struct BlowersMaselData : public ReactionData
{
BlowersMaselData() = default;

virtual void update(double T) override;
virtual bool update(const ThermoPhase& phase, const Kinetics& kin) override;
void update(double T) override;
bool update(const ThermoPhase& phase, const Kinetics& kin) override;
using ReactionData::update;

virtual void resize(size_t nSpecies, size_t nReactions, size_t nPhases) override {
void resize(size_t nSpecies, size_t nReactions, size_t nPhases) override {
partialMolarEnthalpies.resize(nSpecies, 0.);
ready = true;
}
Expand Down Expand Up @@ -90,11 +90,11 @@ class BlowersMaselRate : public ArrheniusBase
return make_unique<MultiRate<BlowersMaselRate, BlowersMaselData>>();
}

virtual const string type() const override {
const string type() const override {
return "Blowers-Masel";
}

virtual void setContext(const Reaction& rxn, const Kinetics& kin) override;
void setContext(const Reaction& rxn, const Kinetics& kin) override;

//! Evaluate reaction rate
double evalRate(double logT, double recipT) const {
Expand Down Expand Up @@ -149,7 +149,7 @@ class BlowersMaselRate : public ArrheniusBase
}

public:
virtual double activationEnergy() const override {
double activationEnergy() const override {
return effectiveActivationEnergy_R(m_deltaH_R) * GasConstant;
}

Expand Down
20 changes: 10 additions & 10 deletions include/cantera/kinetics/ChebyshevRate.h
Expand Up @@ -24,15 +24,15 @@ struct ChebyshevData : public ReactionData
{
ChebyshevData() = default;

virtual void update(double T) override;
void update(double T) override;

virtual void update(double T, double P) override {
void update(double T, double P) override {
ReactionData::update(T);
pressure = P;
log10P = std::log10(P);
}

virtual bool update(const ThermoPhase& phase, const Kinetics& kin) override;
bool update(const ThermoPhase& phase, const Kinetics& kin) override;

using ReactionData::update;

Expand All @@ -43,9 +43,9 @@ struct ChebyshevData : public ReactionData
*/
void perturbPressure(double deltaP);

virtual void restore() override;
void restore() override;

virtual void invalidateCache() override {
void invalidateCache() override {
ReactionData::invalidateCache();
pressure = NAN;
}
Expand Down Expand Up @@ -109,20 +109,20 @@ class ChebyshevRate final : public ReactionRate

ChebyshevRate(const AnyMap& node, const UnitStack& rate_units={});

unique_ptr<MultiRateBase> newMultiRate() const {
unique_ptr<MultiRateBase> newMultiRate() const override {
return make_unique<MultiRate<ChebyshevRate, ChebyshevData>>();
}

const string type() const { return "Chebyshev"; }
const string type() const override { return "Chebyshev"; }

//! Perform object setup based on AnyMap node information
/*!
* @param node AnyMap containing rate information
* @param rate_units Unit definitions specific to rate information
*/
void setParameters(const AnyMap& node, const UnitStack& rate_units);
void setParameters(const AnyMap& node, const UnitStack& rate_units) override;

void getParameters(AnyMap& rateNode) const;
void getParameters(AnyMap& rateNode) const override;

//! @deprecated To be removed after %Cantera 3.0.
void getParameters(AnyMap& rateNode, const Units& rate_units) const {
Expand All @@ -131,7 +131,7 @@ class ChebyshevRate final : public ReactionRate
return getParameters(rateNode);
}

virtual void validate(const string& equation, const Kinetics& kin);
void validate(const string& equation, const Kinetics& kin) override;

//! Update information specific to reaction
/*!
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/kinetics/Custom.h
Expand Up @@ -49,7 +49,7 @@ class CustomFunc1Rate final : public ReactionRate
void getParameters(AnyMap& rateNode, const Units& rate_units=Units(0.)) const;
using ReactionRate::getParameters;

virtual void validate(const string& equation, const Kinetics& kin) override;
void validate(const string& equation, const Kinetics& kin) override;

//! Update information specific to reaction
/*!
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/kinetics/EdgeKinetics.h
Expand Up @@ -25,7 +25,7 @@ class EdgeKinetics : public InterfaceKinetics
m_nDim = 1;
}

virtual string kineticsType() const {
string kineticsType() const override {
return "edge";
}
};
Expand Down