00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #include "MeshObject.H"
00027 #include <OpenFOAM/objectRegistry.H>
00028 
00029 
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 
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 
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