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 "coordinateSystems.H"
27 #include "IOPtrList.H"
29 #include "stringListOps.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(coordinateSystems, 0);
36 defineTemplateTypeNameAndDebug(IOPtrList<coordinateSystem>, 0);
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 Foam::coordinateSystems::coordinateSystems(const IOobject& io)
43 IOPtrList<coordinateSystem>(io)
47 Foam::coordinateSystems::coordinateSystems
50 const PtrList<coordinateSystem>& lst
53 IOPtrList<coordinateSystem>(io, lst)
57 Foam::coordinateSystems::coordinateSystems
60 const Xfer<PtrList<coordinateSystem> >& lst
63 IOPtrList<coordinateSystem>(io, lst)
67 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
69 // Read construct from registry, or return previously registered
70 const Foam::coordinateSystems& Foam::coordinateSystems::New
72 const objectRegistry& obr
75 if (obr.foundObject<coordinateSystems>(typeName))
77 return obr.lookupObject<coordinateSystems>(typeName);
90 IOobject::READ_IF_PRESENT,
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 Foam::label Foam::coordinateSystems::find(const keyType& key) const
103 return findIndex(key);
107 Foam::labelList Foam::coordinateSystems::findIndices(const keyType& key) const
112 indices = findStrings(key, toc());
116 indices.setSize(size());
120 if (key == operator[](i).name())
122 indices[nFound++] = i;
125 indices.setSize(nFound);
132 Foam::label Foam::coordinateSystems::findIndex(const keyType& key) const
136 labelList indices = findIndices(key);
137 // return first element
138 if (!indices.empty())
147 if (key == operator[](i).name())
158 bool Foam::coordinateSystems::found(const keyType& key) const
160 return findIndex(key) != -1;
164 Foam::wordList Foam::coordinateSystems::toc() const
166 wordList keywords(size());
170 keywords[i] = operator[](i).name();
177 bool Foam::coordinateSystems::writeData(Ostream& os, bool subDict) const
179 os << nl << size() << nl << token::BEGIN_LIST;
184 operator[](i).writeDict(os, subDict);
187 os << token::END_LIST << nl;
193 // ************************************************************************* //