From baf3fe8c2c71b20a8156cf6bbaf49ee007ea30d4 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 9 Aug 2012 14:30:48 +0100 Subject: [PATCH] ENH: Enabled strict type check on lookupClass --- .../db/objectRegistry/objectRegistry.H | 2 +- .../objectRegistry/objectRegistryTemplates.C | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index 48cabcc1cf..14306e41fb 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -157,7 +157,7 @@ public: //- Lookup and return all objects of the given Type template - HashTable lookupClass() const; + HashTable lookupClass(const bool strict = false) const; //- Is the named Type found? template diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C index eb7b8fab63..922d630de7 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,8 +29,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -Foam::wordList -Foam::objectRegistry::names() const +Foam::wordList Foam::objectRegistry::names() const { wordList objectNames(size()); @@ -50,14 +49,24 @@ Foam::objectRegistry::names() const template -Foam::HashTable -Foam::objectRegistry::lookupClass() const +Foam::HashTable Foam::objectRegistry::lookupClass +( + const bool strict +) const { HashTable objectsOfClass(size()); for (const_iterator iter = begin(); iter != end(); ++iter) { - if (isA(*iter())) + if (strict && isType(*iter())) + { + objectsOfClass.insert + ( + iter()->name(), + dynamic_cast(iter()) + ); + } + else if (isA(*iter())) { objectsOfClass.insert (