Skip to content
Snippets Groups Projects
Commit eb009012 authored by joergbuchwald's avatar joergbuchwald Committed by Dmitri Naumov
Browse files

MPL: add debug warnings for unused parameters

parent 37aa049e
No related branches found
No related tags found
No related merge requests found
...@@ -71,6 +71,9 @@ PropertyDataType Property::initialValue( ...@@ -71,6 +71,9 @@ PropertyDataType Property::initialValue(
PropertyDataType Property::value() const PropertyDataType Property::value() const
{ {
#ifndef NDEBUG
property_used = true;
#endif
return value_; return value_;
} }
...@@ -79,6 +82,9 @@ PropertyDataType Property::value(VariableArray const& /*variable_array*/, ...@@ -79,6 +82,9 @@ PropertyDataType Property::value(VariableArray const& /*variable_array*/,
ParameterLib::SpatialPosition const& /*pos*/, ParameterLib::SpatialPosition const& /*pos*/,
double const /*t*/, double const /*dt*/) const double const /*t*/, double const /*dt*/) const
{ {
#ifndef NDEBUG
property_used = true;
#endif
return value_; return value_;
} }
...@@ -86,6 +92,9 @@ PropertyDataType Property::value(VariableArray const& variable_array, ...@@ -86,6 +92,9 @@ PropertyDataType Property::value(VariableArray const& variable_array,
ParameterLib::SpatialPosition const& pos, ParameterLib::SpatialPosition const& pos,
double const t, double const dt) const double const t, double const dt) const
{ {
#ifndef NDEBUG
property_used = true;
#endif
return value(variable_array, VariableArray{}, pos, t, dt); return value(variable_array, VariableArray{}, pos, t, dt);
} }
...@@ -95,6 +104,9 @@ PropertyDataType Property::dValue(VariableArray const& /*variable_array*/, ...@@ -95,6 +104,9 @@ PropertyDataType Property::dValue(VariableArray const& /*variable_array*/,
ParameterLib::SpatialPosition const& /*pos*/, ParameterLib::SpatialPosition const& /*pos*/,
double const /*t*/, double const /*dt*/) const double const /*t*/, double const /*dt*/) const
{ {
#ifndef NDEBUG
property_used = true;
#endif
return dvalue_; return dvalue_;
} }
...@@ -105,6 +117,9 @@ PropertyDataType Property::dValue(VariableArray const& variable_array, ...@@ -105,6 +117,9 @@ PropertyDataType Property::dValue(VariableArray const& variable_array,
ParameterLib::SpatialPosition const& pos, ParameterLib::SpatialPosition const& pos,
double const t, double const dt) const double const t, double const dt) const
{ {
#ifndef NDEBUG
property_used = true;
#endif
return dValue(variable_array, VariableArray{}, variable, pos, t, dt); return dValue(variable_array, VariableArray{}, variable, pos, t, dt);
} }
...@@ -116,6 +131,9 @@ PropertyDataType Property::d2Value(VariableArray const& /*variable_array*/, ...@@ -116,6 +131,9 @@ PropertyDataType Property::d2Value(VariableArray const& /*variable_array*/,
double const /*t*/, double const /*t*/,
double const /*dt*/) const double const /*dt*/) const
{ {
#ifndef NDEBUG
property_used = true;
#endif
return 0.0; return 0.0;
} }
......
...@@ -44,7 +44,21 @@ PropertyDataType fromVector(std::vector<double> const& values); ...@@ -44,7 +44,21 @@ PropertyDataType fromVector(std::vector<double> const& values);
class Property class Property
{ {
public: public:
#ifndef NDEBUG
virtual ~Property()
{
if(property_used)
{
DBUG("Property is used: '{:s}'", description());
}
else
{
WARN("Property is not used: '{:s}'", description());
}
}
#else
virtual ~Property() = default; virtual ~Property() = default;
#endif
/// Returns the initial (or reference) value of the property. /// Returns the initial (or reference) value of the property.
/// The default implementation forwards to the value function. /// The default implementation forwards to the value function.
...@@ -120,6 +134,9 @@ public: ...@@ -120,6 +134,9 @@ public:
{ {
try try
{ {
#ifndef NDEBUG
property_used = true;
#endif
return std::get<T>(value()); return std::get<T>(value());
} }
catch (std::bad_variant_access const&) catch (std::bad_variant_access const&)
...@@ -141,6 +158,9 @@ public: ...@@ -141,6 +158,9 @@ public:
{ {
try try
{ {
#ifndef NDEBUG
property_used = true;
#endif
return std::get<T>( return std::get<T>(
value(variable_array, variable_array_prev, pos, t, dt)); value(variable_array, variable_array_prev, pos, t, dt));
} }
...@@ -163,6 +183,9 @@ public: ...@@ -163,6 +183,9 @@ public:
{ {
try try
{ {
#ifndef NDEBUG
property_used = true;
#endif
return std::get<T>(value(variable_array, pos, t, dt)); return std::get<T>(value(variable_array, pos, t, dt));
} }
catch (std::bad_variant_access const&) catch (std::bad_variant_access const&)
...@@ -185,6 +208,9 @@ public: ...@@ -185,6 +208,9 @@ public:
{ {
try try
{ {
#ifndef NDEBUG
property_used = true;
#endif
return std::get<T>(dValue(variable_array, variable_array_prev, return std::get<T>(dValue(variable_array, variable_array_prev,
variable, pos, t, dt)); variable, pos, t, dt));
} }
...@@ -206,6 +232,9 @@ public: ...@@ -206,6 +232,9 @@ public:
{ {
try try
{ {
#ifndef NDEBUG
property_used = true;
#endif
return std::get<T>(dValue(variable_array, variable, pos, t, dt)); return std::get<T>(dValue(variable_array, variable, pos, t, dt));
} }
catch (std::bad_variant_access const&) catch (std::bad_variant_access const&)
...@@ -227,6 +256,9 @@ public: ...@@ -227,6 +256,9 @@ public:
{ {
try try
{ {
#ifndef NDEBUG
property_used = true;
#endif
return std::get<T>( return std::get<T>(
d2Value(variable_array, variable1, variable2, pos, t, dt)); d2Value(variable_array, variable1, variable2, pos, t, dt));
} }
...@@ -260,6 +292,9 @@ private: ...@@ -260,6 +292,9 @@ private:
// medium, phase or component // medium, phase or component
} }
std::string description() const; std::string description() const;
#ifndef NDEBUG
mutable bool property_used = false;
#endif
private: private:
/// Corresponds to the PropertyDataType /// Corresponds to the PropertyDataType
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment