mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
shared_ptr references in compile-time loop to prevent unnecessary ref-bumps
This commit is contained in:
@@ -111,7 +111,7 @@ namespace {
|
||||
/* A compile-time for loop over the taxonomy kinds */
|
||||
template <size_t N>
|
||||
struct dispatch_conversion {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, ifcopenshell::geometry::taxonomy::kinds item_kind, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults& results) {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, ifcopenshell::geometry::taxonomy::kinds item_kind, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults& results) {
|
||||
if (N == item_kind) {
|
||||
auto concrete_item = std::static_pointer_cast<ifcopenshell::geometry::taxonomy::type_by_kind::type<N>>(item);
|
||||
return kernel->convert_impl(concrete_item, results);
|
||||
@@ -123,7 +123,7 @@ namespace {
|
||||
|
||||
template <>
|
||||
struct dispatch_conversion<ifcopenshell::geometry::taxonomy::type_by_kind::max> {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, ifcopenshell::geometry::taxonomy::kinds, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults&) {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, ifcopenshell::geometry::taxonomy::kinds, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults&) {
|
||||
Logger::Error("No conversion for " + std::to_string(item->kind()));
|
||||
return false;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ namespace {
|
||||
|
||||
template <size_t N>
|
||||
struct dispatch_with_upgrade {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults& results) {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults& results) {
|
||||
auto concrete_item = ifcopenshell::geometry::taxonomy::template dcast<ifcopenshell::geometry::taxonomy::upgrades::type<N>>(item);
|
||||
if (concrete_item) {
|
||||
return kernel->convert_impl(concrete_item, results);
|
||||
@@ -143,7 +143,7 @@ namespace {
|
||||
|
||||
template <>
|
||||
struct dispatch_with_upgrade<ifcopenshell::geometry::taxonomy::upgrades::max> {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults&) {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults&) {
|
||||
Logger::Error("No conversion with upgrade for " + std::to_string(item->kind()));
|
||||
return false;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ namespace {
|
||||
/* A compile-time for loop over the curve kinds */
|
||||
template <typename T, size_t N = 0>
|
||||
struct dispatch_curve_creation {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr item, T& visitor) {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T& visitor) {
|
||||
constexpr auto KindIndex = TupleTypeIndex<std::tuple_element_t<N, ifcopenshell::geometry::taxonomy::impl::CurvesTuple>, ifcopenshell::geometry::taxonomy::impl::KindsTuple>::value;
|
||||
if (item->kind() == KindIndex) {
|
||||
auto concrete_item = std::static_pointer_cast<ifcopenshell::geometry::taxonomy::curves::type<N>>(item);
|
||||
@@ -179,7 +179,7 @@ namespace {
|
||||
|
||||
template <typename T>
|
||||
struct dispatch_curve_creation<T, ifcopenshell::geometry::taxonomy::curves::max> {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr item, T&) {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) {
|
||||
Logger::Error("No conversion for " + std::to_string(item->kind()));
|
||||
return false;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ namespace {
|
||||
/* A compile-time for loop over the curve kinds */
|
||||
template <typename T, size_t N = 0>
|
||||
struct dispatch_surface_creation {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr item, T& visitor) {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T& visitor) {
|
||||
auto v = ifcopenshell::geometry::taxonomy::template dcast<ifcopenshell::geometry::taxonomy::surfaces::type<N>>(item);
|
||||
if (v && item->kind() == v->kind()) {
|
||||
visitor(v);
|
||||
@@ -201,7 +201,7 @@ namespace {
|
||||
|
||||
template <typename T>
|
||||
struct dispatch_surface_creation<T, ifcopenshell::geometry::taxonomy::surfaces::max> {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr item, T&) {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) {
|
||||
Logger::Error("No conversion for " + std::to_string(item->kind()));
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user