1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "postfixedSubRegistry.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 defineTypeNameAndDebug(postfixedSubRegistry, 0);
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 Foam::postfixedSubRegistry::postfixedSubRegistry
42 const label nIoObjects
45 objectRegistry(io, io.db().dbDir(), nIoObjects)
47 writeOpt() = IOobject::NO_WRITE;
51 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
53 Foam::postfixedSubRegistry::~postfixedSubRegistry()
55 objectRegistry::clear();
59 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
61 Foam::fileName Foam::postfixedSubRegistry::mangleFileName(const fileName& fName) const
63 return fileName(fName+name());
67 bool Foam::postfixedSubRegistry::checkIn(regIOobject& io) const
69 if (postfixedSubRegistry::debug)
71 Pout<< "postfixedSubRegistry::checkIn(regIOobject&) : "
72 << name() << " : checking in " << io.name()
76 word demangledName = io.name();
77 demangledName = demangledName(io.name().size() - name().size());
79 // Check into Mesh-Registry under full name
80 const_cast<objectRegistry&>(parent()).insert(io.name(), &io);
82 // Check into Mesh-Registry under short name
83 return const_cast<postfixedSubRegistry&>(*this).insert(demangledName, &io);;
87 bool Foam::postfixedSubRegistry::checkOut(regIOobject& io) const
89 word demangledName = io.name();
90 demangledName = demangledName(io.name().size() - name().size());
91 iterator iter = const_cast<postfixedSubRegistry&>(*this).find(demangledName);
92 iterator iterPar = const_cast<objectRegistry&>(parent()).find(io.name());
94 if (iter != end() && iterPar != end())
96 if (postfixedSubRegistry::debug)
98 Pout<< "postfixedSubRegistry::checkOut(regIOobject&) : "
99 << name() << " : checking out " << io.name()
103 if (iter() != &io || iterPar() != &io)
105 if (postfixedSubRegistry::debug)
107 WarningIn("postfixedSubRegistry::checkOut(regIOobject&)")
108 << name() << " : attempt to checkOut copy of " << io.name()
117 const_cast<postfixedSubRegistry&>(*this).erase(iter)
118 && const_cast<objectRegistry&>(parent()).erase(iterPar);
120 if (io.ownedByRegistry())
130 if (postfixedSubRegistry::debug)
132 Pout<< "postfixedSubRegistry::checkOut(regIOobject&) : "
133 << name() << " : could not find " << io.name()
134 << " in registry " << name()
143 // ************************************************************************* //