From e5823e08ab2db107d7a2cd9f71e26e855fd8cbc9 Mon Sep 17 00:00:00 2001 From: Willem Deconinck Date: Tue, 5 Sep 2023 18:41:49 +0200 Subject: [PATCH] Add FieldObserver::onFieldDestruction --- src/atlas/field/detail/FieldImpl.cc | 3 +++ src/atlas/field/detail/FieldImpl.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/atlas/field/detail/FieldImpl.cc b/src/atlas/field/detail/FieldImpl.cc index 78d929f23..3d655926d 100644 --- a/src/atlas/field/detail/FieldImpl.cc +++ b/src/atlas/field/detail/FieldImpl.cc @@ -94,6 +94,9 @@ FieldImpl::FieldImpl(const std::string& name, array::Array* array) } FieldImpl::~FieldImpl() { + for (FieldObserver* observer : field_observers_) { + observer->onFieldDestruction(*this); + } array_->detach(); if (array_->owners() == 0) { for (auto& f : callback_on_destruction_) { diff --git a/src/atlas/field/detail/FieldImpl.h b/src/atlas/field/detail/FieldImpl.h index cdd9c308f..24af72d2c 100644 --- a/src/atlas/field/detail/FieldImpl.h +++ b/src/atlas/field/detail/FieldImpl.h @@ -257,7 +257,8 @@ class FieldObserver { } } - virtual void onFieldRename(FieldImpl&) = 0; + virtual void onFieldRename(FieldImpl&) {} + virtual void onFieldDestruction(FieldImpl&) {} }; //----------------------------------------------------------------------------------------------------------------------