Commit 15873140 authored by Heinrich Schindler's avatar Heinrich Schindler
Browse files

Add function Sensor::HasMagneticField

parent bb5b31af
......@@ -31,6 +31,8 @@ class Sensor {
void EnableComponent(const unsigned int i, const bool on);
/// Activate/deactivate use of the magnetic field of a given component.
void EnableMagneticField(const unsigned int i, const bool on);
/// Does the sensor have a non-zero magnetic field?
bool HasMagneticField() const;
/// Add an electrode.
void AddElectrode(Component* comp, const std::string& label);
......
......@@ -355,6 +355,15 @@ void Sensor::EnableMagneticField(const unsigned int i, const bool on) {
std::get<2>(m_components[i]) = on;
}
bool Sensor::HasMagneticField() const {
for (const auto& cmp : m_components) {
if (!std::get<1>(cmp) || !std::get<2>(cmp)) continue;
if (std::get<0>(cmp)->HasMagneticField()) return true;
}
return false;
}
void Sensor::AddElectrode(Component* cmp, const std::string& label) {
if (!cmp) {
std::cerr << m_className << "::AddElectrode: Null pointer.\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment