Commit 17719a78 authored by Martin Heistermann's avatar Martin Heistermann

use internal_type_name in property_exists() instead of dynamic_cast

parent 919e020d
Pipeline #11277 passed with stage
in 7 minutes and 13 seconds
......@@ -84,6 +84,8 @@ template <> const std::string entityTypeName<Entity::Mesh>();
template<typename T, typename Entity>
class PropertyTT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, Entity> {
public:
using value_type = T;
using entity_type = Entity;
template<typename MeshT>
PropertyTT(MeshT *mesh, const std::string& _name, const T &_def = T())
: PropertyTT(std::move(mesh->template request_property<T, Entity>(_name, _def)))
......
......@@ -43,6 +43,7 @@
#include "OpenVolumeMeshProperty.hh"
#include "PropertyHandles.hh"
#include "TypeName.hh"
#include "ForwardDeclarations.hh"
namespace OpenVolumeMesh {
......@@ -222,7 +223,9 @@ public:
private:
template <class FullPropT, class PropIterT>
bool property_exists(const PropIterT& _begin, const PropIterT& _end, const std::string& _name) const {
bool property_exists(const PropIterT& _begin, const PropIterT& _end, const std::string& _name) const
{
auto type_name = get_type_name<typename FullPropT::value_type>();
if(_name.empty()) {
#ifndef NDEBUG
......@@ -235,16 +238,10 @@ private:
PropIterT it = _begin;
for(; it != _end; ++it)
{
if((*it)->name() == _name )
{
#if defined OVM_FORCE_STATIC_CAST && OVM_FORCE_STATIC_CAST
return true;
#else
if(dynamic_cast<FullPropT*>(*it) != nullptr)
if((*it)->name() == _name
&& (*it)->internal_type_name() == type_name)
{
return true;
}
#endif
return true;
}
}
return false;
......
#pragma once
#include <string>
#include <typeinfo>
......@@ -6,7 +8,7 @@
/// We need this in order to provide property type safety when
/// only limited RTTI support is available.
template<typename T>
std::string get_type_name()
inline std::string get_type_name()
{
#ifdef _MSC_VER
// MSVC's type_name only returns a friendly name with .name(),
......
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