OGS
Component.cpp
Go to the documentation of this file.
1 
13 #include "Component.h"
14 
15 #include "Components/Components.h"
16 #include "Properties/Properties.h"
17 
18 namespace MaterialPropertyLib
19 {
21 
22 Component::Component(std::string const& component_name,
23  std::unique_ptr<PropertyArray>&& properties)
24  : name(component_name)
25 {
26  if (properties)
27  {
28  overwriteExistingProperties(properties_, *properties, this);
29  }
30 }
31 
33 {
34  Property const* const property = properties_[p].get();
35  if (property == nullptr)
36  {
37  OGS_FATAL("Trying to access undefined property '{:s}' of {:s}",
39  }
40 
41  return *properties_[p];
42 }
43 
45 {
46  return property(p);
47 }
48 
50 {
51  return properties_[p] != nullptr;
52 }
53 
54 std::string Component::description() const
55 {
56  return "component '" + name + "'";
57 }
58 } // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition: Error.h:26
Property const & property(PropertyType const &) const
A get-function for retrieving a certain property.
Definition: Component.cpp:32
Property const & operator[](PropertyType const &p) const
Definition: Component.cpp:44
std::string const name
Definition: Component.h:77
PropertyArray properties_
The property array of the component.
Definition: Component.h:81
bool hasProperty(PropertyType const &p) const
Definition: Component.cpp:49
std::string description() const
Short description of the component with its name.
Definition: Component.cpp:54
void overwriteExistingProperties(PropertyArray &properties, PropertyArray &new_properties, std::variant< Medium *, Phase *, Component * > scale_pointer)
Definition: Property.h:311
static const std::array< std::string, PropertyType::number_of_properties > property_enum_to_string
Definition: PropertyType.h:111