1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "objectRegistry.H"
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 Foam::objectRegistry::names() const
35 wordList objectNames(size());
38 for (const_iterator iter = begin(); iter != end(); ++iter)
40 if (isA<Type>(*iter()))
42 objectNames[count++] = iter()->name();
46 objectNames.setSize(count);
53 Foam::HashTable<const Type*>
54 Foam::objectRegistry::lookupClass() const
56 HashTable<const Type*> objectsOfClass(size());
58 for (const_iterator iter = begin(); iter != end(); ++iter)
60 if (isA<Type>(*iter()))
65 dynamic_cast<const Type*>(iter())
70 return objectsOfClass;
75 bool Foam::objectRegistry::foundObject(const word& name) const
77 const_iterator iter = find(name);
81 const Type* vpsiPtr_ = dynamic_cast<const Type*>(iter());
88 else if (this->parentNotTime())
90 return parent_.foundObject<Type>(name);
98 const Type& Foam::objectRegistry::lookupObject(const word& name) const
100 const_iterator iter = find(name);
104 const Type* vpsiPtr_ = dynamic_cast<const Type*>(iter());
113 "objectRegistry::lookupObject<Type>(const word&) const"
115 << " lookup of " << name << " from objectRegistry "
117 << " successful\n but it is not a " << Type::typeName
118 << ", it is a " << iter()->type()
119 << abort(FatalError);
123 if (this->parentNotTime())
125 return parent_.lookupObject<Type>(name);
130 "objectRegistry::lookupObject<Type>(const word&) const"
132 << " request for " << Type::typeName
133 << " " << name << " from objectRegistry " << this->name()
134 << " failed\n available objects of type " << Type::typeName
137 << abort(FatalError);
140 return *reinterpret_cast< const Type* >(0);
144 // ************************************************************************* //