1 /*----------------------------------------------------------------------------*\
3 | ____| _| |_ / __ \ /\ | \/ |
4 | |__ _ __ ___ ___ / \| | | | / \ | \ / |
5 | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
6 | | | | | __/ __/\_ _/| |__| / ____ \| | | |
7 |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
9 FreeFOAM: The Cross-Platform CFD Toolkit
11 Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
12 Gerber van der Graaf <gerber_graaf@users.sf.net>
13 --------------------------------------------------------------------------------
15 This file is part of FreeFOAM.
17 FreeFOAM is free software: you can redistribute it and/or modify it
18 under the terms of the GNU General Public License as published by the
19 Free Software Foundation, either version 3 of the License, or (at your
20 option) any later version.
22 FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
23 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 You should have received a copy of the GNU General Public License
28 along with FreeFOAM. If not, see <http://www.gnu.org/licenses/>.
30 \*----------------------------------------------------------------------------*/
32 #include <OpenFOAM/PstreamImpl.H>
33 #include <OpenFOAM/debug.H>
34 #include <OpenFOAM/OSspecific.H>
35 #include <OpenFOAM/dictionary.H>
36 #include <OpenFOAM/dlLibraryTable.H>
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 // * * * * * * * * * * * * * Local Helper Functions * * * * * * * * * * * * //
44 // helper function to find the config section name
45 word PstreamConfigSectionName();
47 // * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * //
49 template<class T, class CTable>
50 autoPtr<T> PstreamImpl::loadPstreamInstance(const word& dictEntry, const word& envName, CTable* ctable)
52 word PstreamClassName;
53 // check whether the environment variable is set
56 PstreamClassName = getEnv(envName);
60 // otherwise check the global controlDict
61 word configName = PstreamConfigSectionName();
62 debug::controlDict().subDict("PstreamImplementation")
63 .subDict(configName).lookup(dictEntry) >> PstreamClassName;
66 if(PstreamImpl::debug)
68 Info<< "Trying to instantiate '" << PstreamClassName << "'" << endl;
71 typename CTable::iterator cstrIter =
72 ctable->find(PstreamClassName);
74 if (cstrIter == ctable->end())
78 "PstreamImpl::loadPstreamInstance(const word&, const word&)"
79 ) << "Unknown type '" << PstreamClassName << "'"
81 << "Valid types are :" << endl
83 << Foam::exit(FatalError);
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 } // End namespace Foam
94 // ************************ vim: set sw=4 sts=4 et: ************************ //