From c117aa664a574889f13dba422747eefa7d519ba8 Mon Sep 17 00:00:00 2001 From: Xavier Robin <xavalias-github@xavier.robin.name> Date: Thu, 27 Jul 2023 10:33:02 +0200 Subject: [PATCH] refactor: SCHWED-4345 use same logic for IsValid and CheckValidity In both cases we check if we have a valid implementation AND if the underlying entity is still there. --- modules/mol/base/src/atom_base.cc | 4 ++-- modules/mol/base/src/chain_base.cc | 4 ++-- modules/mol/base/src/residue_base.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/mol/base/src/atom_base.cc b/modules/mol/base/src/atom_base.cc index 3dae54fb8..24f3bd7d4 100644 --- a/modules/mol/base/src/atom_base.cc +++ b/modules/mol/base/src/atom_base.cc @@ -104,12 +104,12 @@ String AtomBase::GetQualifiedName() const bool AtomBase::IsValid() const { - return Impl().get()!=0; + return Impl().get()!=0 && impl_->GetEntity(); } void AtomBase::CheckValidity() const { - if (! (impl_ && impl_->GetEntity())) + if (! IsValid()) throw InvalidHandle(); } diff --git a/modules/mol/base/src/chain_base.cc b/modules/mol/base/src/chain_base.cc index 322177349..db9b1346b 100644 --- a/modules/mol/base/src/chain_base.cc +++ b/modules/mol/base/src/chain_base.cc @@ -54,11 +54,11 @@ String ChainBase::GetDescription() const { bool ChainBase::IsValid() const { - return Impl().get()!=0; + return Impl().get()!=0 && impl_->GetEntity(); } void ChainBase::CheckValidity() const { - if (! (impl_ && impl_->GetEntity())) + if (! IsValid()) throw InvalidHandle(); } diff --git a/modules/mol/base/src/residue_base.cc b/modules/mol/base/src/residue_base.cc index c227e090e..854b4b1aa 100644 --- a/modules/mol/base/src/residue_base.cc +++ b/modules/mol/base/src/residue_base.cc @@ -158,12 +158,12 @@ const impl::ResidueImplPtr& ResidueBase::Impl() const bool ResidueBase::IsValid() const { - return Impl().get()!=0; + return Impl().get()!=0 && impl_->GetEntity(); } void ResidueBase::CheckValidity() const { - if (! (impl_ && impl_->GetEntity())) + if (! IsValid()) throw InvalidHandle(); } -- GitLab