FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

MeshObject.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "MeshObject.H"
00027 #include <OpenFOAM/objectRegistry.H>
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 template<class Mesh, class Type>
00032 Foam::MeshObject<Mesh, Type>::MeshObject(const Mesh& mesh)
00033 :
00034     regIOobject
00035     (
00036         IOobject
00037         (
00038             Type::typeName,
00039             mesh.thisDb().instance(),
00040             mesh.thisDb()
00041         )
00042     ),
00043     mesh_(mesh)
00044 {}
00045 
00046 
00047 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00048 
00049 template<class Mesh, class Type>
00050 const Type& Foam::MeshObject<Mesh, Type>::New
00051 (
00052     const Mesh& mesh
00053 )
00054 {
00055     if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00056     {
00057         return store(new Type(mesh));
00058     }
00059     else
00060     {
00061         return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00062     }
00063 }
00064 
00065 
00066 template<class Mesh, class Type>
00067 template<class Data1>
00068 const Type& Foam::MeshObject<Mesh, Type>::New
00069 (
00070     const Mesh& mesh,
00071     const Data1& d
00072 )
00073 {
00074     if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00075     {
00076         return store(new Type(mesh, d));
00077     }
00078     else
00079     {
00080         return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00081     }
00082 }
00083 
00084 
00085 template<class Mesh, class Type>
00086 template<class Data1, class Data2>
00087 const Type& Foam::MeshObject<Mesh, Type>::New
00088 (
00089     const Mesh& mesh,
00090     const Data1& d1,
00091     const Data2& d2
00092 )
00093 {
00094     if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00095     {
00096         return store(new Type(mesh, d1, d2));
00097     }
00098     else
00099     {
00100         return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00101     }
00102 }
00103 
00104 
00105 template<class Mesh, class Type>
00106 template<class Data1, class Data2, class Data3>
00107 const Type& Foam::MeshObject<Mesh, Type>::New
00108 (
00109     const Mesh& mesh,
00110     const Data1& d1,
00111     const Data2& d2,
00112     const Data3& d3
00113 )
00114 {
00115     if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00116     {
00117         return store(new Type(mesh, d1, d2, d3));
00118     }
00119     else
00120     {
00121         return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00122     }
00123 }
00124 
00125 
00126 template<class Mesh, class Type>
00127 template<class Data1, class Data2, class Data3, class Data4>
00128 const Type& Foam::MeshObject<Mesh, Type>::New
00129 (
00130     const Mesh& mesh,
00131     const Data1& d1,
00132     const Data2& d2,
00133     const Data3& d3,
00134     const Data4& d4
00135 )
00136 {
00137     if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00138     {
00139         return store(new Type(mesh, d1, d2, d3, d4));
00140     }
00141     else
00142     {
00143         return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00144     }
00145 }
00146 
00147 
00148 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * //
00149 
00150 template<class Mesh, class Type>
00151 bool Foam::MeshObject<Mesh, Type>::Delete(const Mesh& mesh)
00152 {
00153     if (mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00154     {
00155         return mesh.thisDb().checkOut
00156         (
00157             const_cast<Type&>
00158             (
00159                 mesh.thisDb().objectRegistry::lookupObject<Type>
00160                 (
00161                     Type::typeName
00162                 )
00163             )
00164         );
00165     }
00166     else
00167     {
00168         return false;
00169     }
00170 }
00171 
00172 
00173 template<class Mesh, class Type>
00174 Foam::MeshObject<Mesh, Type>::~MeshObject()
00175 {
00176     release();
00177 }
00178 
00179 
00180 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines