diff --git a/MeshLib/Properties-impl.h b/MeshLib/Properties-impl.h index ff61aab52427491336525bc03ca8069ea4be5942..8b7669dd7c249769e3f27f873e5168ddac0791b4 100644 --- a/MeshLib/Properties-impl.h +++ b/MeshLib/Properties-impl.h @@ -87,6 +87,33 @@ bool Properties::existsPropertyVector(std::string const& name) const return dynamic_cast<PropertyVector<T> const*>(it->second) != nullptr; } +template <typename T> +bool Properties::existsPropertyVector(std::string const& name, + MeshItemType const item_type, + int const number_of_components) const +{ + auto const it = _properties.find(name); + if (it == _properties.end()) + { + return false; + } + + auto property = dynamic_cast<PropertyVector<T>*>(it->second); + if (property == nullptr) + { + return false; + } + if (property->getMeshItemType() != item_type) + { + return false; + } + if (property->getNumberOfComponents() != number_of_components) + { + return false; + } + return true; +} + template <typename T> PropertyVector<T> const* Properties::getPropertyVector( std::string const& name) const diff --git a/MeshLib/Properties.h b/MeshLib/Properties.h index f31ea3c70afa69da712150eb5bbdbb62a127152b..1dcf650bbdaa0aa8bb1dc9e3cf1944b9c564629e 100644 --- a/MeshLib/Properties.h +++ b/MeshLib/Properties.h @@ -85,6 +85,14 @@ public: template <typename T> bool existsPropertyVector(std::string const& name) const; + /// Checks if a property vector with given type \c T, \c name, \c item_type + /// and \c number_of_components exists. + /// @param name name of the requested property vector + template <typename T> + bool existsPropertyVector(std::string const& name, + MeshItemType const item_type, + int const number_of_components) const; + /// Returns a property vector with given \c name or aborts calling OGS_FATAL /// if no such property vector exists. template <typename T>