mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Enabled strict type check on lookupClass
This commit is contained in:
@ -157,7 +157,7 @@ public:
|
|||||||
|
|
||||||
//- Lookup and return all objects of the given Type
|
//- Lookup and return all objects of the given Type
|
||||||
template<class Type>
|
template<class Type>
|
||||||
HashTable<const Type*> lookupClass() const;
|
HashTable<const Type*> lookupClass(const bool strict = false) const;
|
||||||
|
|
||||||
//- Is the named Type found?
|
//- Is the named Type found?
|
||||||
template<class Type>
|
template<class Type>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -29,8 +29,7 @@ License
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::wordList
|
Foam::wordList Foam::objectRegistry::names() const
|
||||||
Foam::objectRegistry::names() const
|
|
||||||
{
|
{
|
||||||
wordList objectNames(size());
|
wordList objectNames(size());
|
||||||
|
|
||||||
@ -50,14 +49,24 @@ Foam::objectRegistry::names() const
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::HashTable<const Type*>
|
Foam::HashTable<const Type*> Foam::objectRegistry::lookupClass
|
||||||
Foam::objectRegistry::lookupClass() const
|
(
|
||||||
|
const bool strict
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
HashTable<const Type*> objectsOfClass(size());
|
HashTable<const Type*> objectsOfClass(size());
|
||||||
|
|
||||||
for (const_iterator iter = begin(); iter != end(); ++iter)
|
for (const_iterator iter = begin(); iter != end(); ++iter)
|
||||||
{
|
{
|
||||||
if (isA<Type>(*iter()))
|
if (strict && isType<Type>(*iter()))
|
||||||
|
{
|
||||||
|
objectsOfClass.insert
|
||||||
|
(
|
||||||
|
iter()->name(),
|
||||||
|
dynamic_cast<const Type*>(iter())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (isA<Type>(*iter()))
|
||||||
{
|
{
|
||||||
objectsOfClass.insert
|
objectsOfClass.insert
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user