From f6d462a246ab7e1e3e16e44e33fffc8dfaaaba3b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 11 Feb 2019 10:58:18 +0100 Subject: [PATCH] STYLE: make objectRegistry::cfindIOobject() protected instead of public --- .../db/objectRegistry/objectRegistry.C | 74 ++++++------------- .../db/objectRegistry/objectRegistry.H | 60 ++++----------- 2 files changed, 37 insertions(+), 97 deletions(-) diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.C b/src/OpenFOAM/db/objectRegistry/objectRegistry.C index f93d0c1f7d..905f8fc496 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.C @@ -76,6 +76,29 @@ bool Foam::objectRegistry::parentNotTime() const } +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +const Foam::regIOobject* Foam::objectRegistry::cfindIOobject +( + const word& name, + const bool recursive +) const +{ + const_iterator iter = cfind(name); + + if (iter.found()) + { + return iter.val(); + } + else if (recursive && this->parentNotTime()) + { + return parent_.cfindIOobject(name, recursive); + } + + return nullptr; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::objectRegistry::objectRegistry(const Time& t, const label nObjects) @@ -383,57 +406,6 @@ bool Foam::objectRegistry::found } -const Foam::regIOobject* Foam::objectRegistry::cfindIOobject -( - const word& name, - const bool recursive -) const -{ - const_iterator iter = cfind(name); - - if (iter.found()) - { - return iter.val(); - } - else if (recursive && this->parentNotTime()) - { - return parent_.cfindIOobject(name, recursive); - } - - return nullptr; -} - - -const Foam::regIOobject* Foam::objectRegistry::findIOobject -( - const word& name, - const bool recursive -) const -{ - return cfindIOobject(name, recursive); -} - - -Foam::regIOobject* Foam::objectRegistry::findIOobject -( - const word& name, - const bool recursive -) -{ - return const_cast(cfindIOobject(name, recursive)); -} - - -Foam::regIOobject* Foam::objectRegistry::getIOobjectPtr -( - const word& name, - const bool recursive -) const -{ - return const_cast(cfindIOobject(name, recursive)); -} - - bool Foam::objectRegistry::modified() const { for (const_iterator iter = cbegin(); iter != cend(); ++iter) diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index d3d05761a8..fcfa109875 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -137,6 +137,20 @@ class objectRegistry void operator=(const objectRegistry&) = delete; + // Protected Member Functions + + //- Return const pointer to the regIOobject. + // + // \param recursive search parent registries + // + // \return nullptr if the object was not found. + const regIOobject* cfindIOobject + ( + const word& name, + const bool recursive = false + ) const; + + public: //- Declare type name for this IOobject @@ -347,52 +361,6 @@ public: bool found(const word& name, const bool recursive = false) const; - //- Return const pointer to the regIOobject. - // - // \param recursive search parent registries - // - // \return nullptr if the object was not found. - const regIOobject* cfindIOobject - ( - const word& name, - const bool recursive = false - ) const; - - //- Return const pointer to the regIOobject. - // - // \param recursive search parent registries - // - // \return nullptr if the object was not found. - const regIOobject* findIOobject - ( - const word& name, - const bool recursive = false - ) const; - - //- Return non-const pointer to the regIOobject. - // - // \param recursive search parent registries - // - // \return nullptr if the object was not found. - regIOobject* findIOobject - ( - const word& name, - const bool recursive = false - ); - - //- Return non-const pointer to the regIOobject, - //- using a const-cast to have it behave like a mutable. - // Exercise caution when using. - // - // \param recursive search parent registries. - // - // \return nullptr if the object was not found. - regIOobject* getIOobjectPtr - ( - const word& name, - const bool recursive = false - ) const; - //- Is the named Type found? // // \param recursive search parent registries