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
00027 #include "MeshObject.H"
00028 #include "objectRegistry.H"
00029
00030
00031
00032 template<class Mesh, class Type>
00033 Foam::MeshObject<Mesh, Type>::MeshObject(const Mesh& mesh)
00034 :
00035 regIOobject
00036 (
00037 IOobject
00038 (
00039 Type::typeName,
00040 mesh.thisDb().instance(),
00041 mesh.thisDb()
00042 )
00043 ),
00044 mesh_(mesh)
00045 {}
00046
00047
00048
00049
00050 template<class Mesh, class Type>
00051 const Type& Foam::MeshObject<Mesh, Type>::New
00052 (
00053 const Mesh& mesh
00054 )
00055 {
00056 if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00057 {
00058 return store(new Type(mesh));
00059 }
00060 else
00061 {
00062 return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00063 }
00064 }
00065
00066
00067 template<class Mesh, class Type>
00068 template<class Data1>
00069 const Type& Foam::MeshObject<Mesh, Type>::New
00070 (
00071 const Mesh& mesh,
00072 const Data1& d
00073 )
00074 {
00075 if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00076 {
00077 return store(new Type(mesh, d));
00078 }
00079 else
00080 {
00081 return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00082 }
00083 }
00084
00085
00086 template<class Mesh, class Type>
00087 template<class Data1, class Data2>
00088 const Type& Foam::MeshObject<Mesh, Type>::New
00089 (
00090 const Mesh& mesh,
00091 const Data1& d1,
00092 const Data2& d2
00093 )
00094 {
00095 if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00096 {
00097 return store(new Type(mesh, d1, d2));
00098 }
00099 else
00100 {
00101 return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00102 }
00103 }
00104
00105
00106 template<class Mesh, class Type>
00107 template<class Data1, class Data2, class Data3>
00108 const Type& Foam::MeshObject<Mesh, Type>::New
00109 (
00110 const Mesh& mesh,
00111 const Data1& d1,
00112 const Data2& d2,
00113 const Data3& d3
00114 )
00115 {
00116 if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00117 {
00118 return store(new Type(mesh, d1, d2, d3));
00119 }
00120 else
00121 {
00122 return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00123 }
00124 }
00125
00126
00127 template<class Mesh, class Type>
00128 template<class Data1, class Data2, class Data3, class Data4>
00129 const Type& Foam::MeshObject<Mesh, Type>::New
00130 (
00131 const Mesh& mesh,
00132 const Data1& d1,
00133 const Data2& d2,
00134 const Data3& d3,
00135 const Data4& d4
00136 )
00137 {
00138 if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00139 {
00140 return store(new Type(mesh, d1, d2, d3, d4));
00141 }
00142 else
00143 {
00144 return mesh.thisDb().objectRegistry::lookupObject<Type>(Type::typeName);
00145 }
00146 }
00147
00148
00149
00150
00151 template<class Mesh, class Type>
00152 bool Foam::MeshObject<Mesh, Type>::Delete(const Mesh& mesh)
00153 {
00154 if (mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
00155 {
00156 return mesh.thisDb().checkOut
00157 (
00158 const_cast<Type&>
00159 (
00160 mesh.thisDb().objectRegistry::lookupObject<Type>
00161 (
00162 Type::typeName
00163 )
00164 )
00165 );
00166 }
00167 else
00168 {
00169 return false;
00170 }
00171 }
00172
00173
00174 template<class Mesh, class Type>
00175 Foam::MeshObject<Mesh, Type>::~MeshObject()
00176 {
00177 release();
00178 }
00179
00180
00181