1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "objectRegistry.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 wordList objectRegistry::names() const
39 wordList objectNames(size());
42 for (const_iterator iter = begin(); iter != end(); ++iter)
44 if (isA<Type>(*iter()))
46 objectNames[count++] = iter()->name();
50 objectNames.setSize(count);
57 HashTable<const Type*> objectRegistry::lookupClass() const
59 HashTable<const Type*> objectsOfClass(size());
61 for (const_iterator iter = begin(); iter != end(); ++iter)
63 if (isA<Type>(*iter()))
68 dynamic_cast<const Type*>(iter())
73 return objectsOfClass;
78 bool objectRegistry::foundObject(const word& name) const
80 const_iterator iter = find(name);
84 const Type* vpsiPtr_ = dynamic_cast<const Type*>(iter());
97 if (&parent_ != dynamic_cast<const objectRegistry*>(&time_))
99 return parent_.foundObject<Type>(name);
110 const Type& objectRegistry::lookupObject(const word& name) const
112 const_iterator iter = find(name);
116 const Type* vpsiPtr_ = dynamic_cast<const Type*>(iter());
123 FatalErrorIn("objectRegistry::lookupObject<Type>(const word&) const")
125 << " lookup of " << name << " from objectRegistry "
127 << " successful\n but it is not a " << Type::typeName
128 << ", it is a " << iter()->type()
129 << abort(FatalError);
133 if (&parent_ != dynamic_cast<const objectRegistry*>(&time_))
135 return parent_.lookupObject<Type>(name);
141 "objectRegistry::lookupObject<Type>(const word&) const"
143 << " request for " << Type::typeName
144 << " " << name << " from objectRegistry " << this->name()
145 << " failed\n available objects of type " << Type::typeName
148 << abort(FatalError);
152 const Type* dummyPtr_ = NULL;
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 } // End namespace Foam
161 // ************************************************************************* //