| 281 | // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // |
| 282 | |
| 283 | void Foam::codedBase::updateLibrary |
| 284 | ( |
| 285 | const word& name |
| 286 | ) const |
| 287 | { |
| 288 | const dictionary& dict = this->codeDict(); |
| 289 | |
| 290 | dynamicCode::checkSecurity |
| 291 | ( |
| 292 | "codedBase::updateLibrary()", |
| 293 | dict |
| 294 | ); |
| 295 | |
| 296 | dynamicCodeContext context(dict); |
| 297 | |
| 298 | // codeName: name + _<sha1> |
| 299 | // codeDir : name |
| 300 | dynamicCode dynCode |
| 301 | ( |
| 302 | name + context.sha1().str(true), |
| 303 | name |
| 304 | ); |
| 305 | const fileName libPath = dynCode.libPath(); |
| 306 | |
| 307 | |
| 308 | // the correct library was already loaded => we are done |
| 309 | if (libs().findLibrary(libPath)) |
| 310 | { |
| 311 | return; |
| 312 | } |
| 313 | |
| 314 | Info<< "Using dynamicCode for " << this->description().c_str() |
| 315 | << " at line " << dict.startLineNumber() |
| 316 | << " in " << dict.name() << endl; |
| 317 | |
| 318 | |
| 319 | // remove instantiation of fvPatchField provided by library |
| 320 | this->clearRedirect(); |
| 321 | |
| 322 | // may need to unload old library |
| 323 | unloadLibrary |
| 324 | ( |
| 325 | oldLibPath_, |
| 326 | dynamicCode::libraryBaseName(oldLibPath_), |
| 327 | context.dict() |
| 328 | ); |
| 329 | |
| 330 | // try loading an existing library (avoid compilation when possible) |
| 331 | if (!loadLibrary(libPath, dynCode.codeName(), context.dict())) |
| 332 | { |
| 333 | createLibrary(dynCode, context); |
| 334 | |
| 335 | loadLibrary(libPath, dynCode.codeName(), context.dict()); |
| 336 | } |
| 337 | |
| 338 | // retain for future reference |
| 339 | oldLibPath_ = libPath; |
| 340 | } |
no test coverage detected