Skip to content
Snippets Groups Projects
Commit d8578eb2 authored by renchao.lu's avatar renchao.lu Committed by Dmitri Naumov
Browse files

[MPL] add overloaded operator functions.

parent a4d2d058
No related branches found
No related tags found
No related merge requests found
......@@ -31,9 +31,21 @@ Component::Component(std::string const& component_name,
Property const& Component::property(PropertyType const& p) const
{
Property const* const property = properties_[p].get();
if (property == nullptr)
{
OGS_FATAL("Trying to access undefined property '{:s}' of {:s}",
property_enum_to_string[p], description());
}
return *properties_[p];
}
Property const& Component::operator[](PropertyType const& p) const
{
return property(p);
}
bool Component::hasProperty(PropertyType const& p) const
{
return properties_[p] != nullptr;
......
......@@ -34,6 +34,9 @@ public:
/// A get-function for retrieving a certain property.
Property const& property(PropertyType const& /*p*/) const;
Property const& operator[](PropertyType const& p) const;
bool hasProperty(PropertyType const& p) const;
template <typename T>
......
......@@ -61,6 +61,11 @@ Property const& Medium::property(PropertyType const& p) const
return *properties_[p];
}
Property const& Medium::operator[](PropertyType const& p) const
{
return property(p);
}
bool Medium::hasProperty(PropertyType const& p) const
{
return properties_[p] != nullptr;
......
......@@ -45,6 +45,9 @@ public:
/// A get-function for a property. The argument refers to the name of the
/// property.
Property const& property(PropertyType const& p) const;
Property const& operator[](PropertyType const& p) const;
bool hasProperty(PropertyType const& p) const;
/// A simple get-function for retrieving the number of phases the medium
......
......@@ -60,6 +60,11 @@ Property const& Phase::property(PropertyType const& p) const
return *properties_[p];
}
Property const& Phase::operator[](PropertyType const& p) const
{
return property(p);
}
bool Phase::hasProperty(PropertyType const& p) const
{
return properties_[p] != nullptr;
......
......@@ -46,6 +46,9 @@ public:
/// A get-function for a property. The argument refers to the name of the
/// property.
Property const& property(PropertyType const& p) const;
Property const& operator[](PropertyType const& p) const;
bool hasProperty(PropertyType const& p) const;
/// A get-function for retrieving the number of components in this phase.
......
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