|
From: Frank V. C. <fr...@us...> - 2000-11-23 15:41:36
|
Update of /cvsroot/corelinux/clfw/src/libs/LibLoad In directory slayer.i.sourceforge.net:/tmp/cvs-serv22251/src/libs/LibLoad Modified Files: Library.cpp LibraryObjectRegistry.cpp Log Message: 122583 release 0.2.6 Index: Library.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/LibLoad/Library.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Library.cpp 2000/11/18 03:35:22 1.4 --- Library.cpp 2000/11/23 15:41:31 1.5 *************** *** 37,49 **** #endif #include <cstring> namespace corelinux { ! static CharPtr gTestMethod( "handlesType" ); ! static CharPtr gGetLoaderMethod( "getLoaderType" ); ! static CharPtr gGetLibraryInstanceMethod( "loadInstance" ); ! static MetaClassPtr findHandler( CharPtr aName, MetaClassPtr aClass ) { MetaClassPtr aPtr( NULLPTR ); --- 37,55 ---- #endif + #if !defined(__LIBRARYINSTANCE_HPP) + #include INCL_LibraryInstance + #endif + + #include <cstring> namespace corelinux { ! const CharPtr gTestMethod( "handlesType" ); ! const CharPtr gGetLoaderTypeMethod( "getLoaderType" ); ! const CharPtr gLoadInstanceMethod( "loadInstance" ); ! const CharPtr gUnLoadInstanceMethod( "unloadInstance" ); ! static MetaClassPtr findHandler( CharCptr aName, MetaClassPtr aClass ) { MetaClassPtr aPtr( NULLPTR ); *************** *** 163,167 **** // ! // Work the magic of ontologies! // --- 169,173 ---- // ! // Find a loader that accepts the type given in the name // *************** *** 229,236 **** // // Setup the recursion looking for an appropriate handler // ! MetaClassPtr Library::findLibraryHandler( CharPtr aName ) { return findHandler --- 235,275 ---- // + // Drop the instance via the loader + // + + void Library::unLoad( LibraryInstancePtr aLibInst ) + throw ( NullPointerException ) + { + if( aLibInst != NULLPTR ) + { + MetaClassPtr aClass + ( + this->findLibraryHandler + ( + aLibInst->getLibraryName() + ) + ); + + if( aClass == NULLPTR ) + { + throw LoaderNotFoundException( LOCATION ); + } + else + { + this->unloadInstance( aLibInst, aClass ); + } + + } + else + { + throw NullPointerException( LOCATION ); + } + } + + // // Setup the recursion looking for an appropriate handler // ! MetaClassPtr Library::findLibraryHandler( CharCptr aName ) { return findHandler *************** *** 247,251 **** LibraryInstancePtr Library::loadInstance ( ! CharPtr aLibrary, MetaClassPtr aTypeClass ) --- 286,290 ---- LibraryInstancePtr Library::loadInstance ( ! CharPtr aLibraryName, MetaClassPtr aTypeClass ) *************** *** 262,266 **** aTypeClass->dispatch ( ! gGetLoaderMethod, (void **)NULLPTR, (void *) &aLoaderType --- 301,305 ---- aTypeClass->dispatch ( ! gGetLoaderTypeMethod, (void **)NULLPTR, (void *) &aLoaderType *************** *** 271,276 **** aLoaderType->dispatch ( ! gGetLibraryInstanceMethod, ! (void **)aLibrary, (void *) &aInstance ); --- 310,315 ---- aLoaderType->dispatch ( ! gLoadInstanceMethod, ! (void **)aLibraryName, (void *) &aInstance ); *************** *** 289,292 **** --- 328,371 ---- return aInstance; + } + + // + // The actual work of unloading the instance + // + + void Library::unloadInstance + ( + LibraryInstancePtr anInstance, + MetaClassPtr aTypeClass + ) + { + // + // First we get the Loader from the LibraryType as it is + // the holder of the goods + // + + MetaTypePtr aLoaderType( NULLPTR ); + + aTypeClass->dispatch + ( + gGetLoaderTypeMethod, + (void **)NULLPTR, + (void *) &aLoaderType + ); + + if( aLoaderType != NULLPTR ) + { + aLoaderType->dispatch + ( + gUnLoadInstanceMethod, + (void **)anInstance, + (void *) NULLPTR + ); + + } + else + { + throw LoaderNotFoundException( LOCATION ); + } } Index: LibraryObjectRegistry.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/LibLoad/LibraryObjectRegistry.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** LibraryObjectRegistry.cpp 2000/11/19 05:19:52 1.4 --- LibraryObjectRegistry.cpp 2000/11/23 15:41:31 1.5 *************** *** 57,62 **** // ! static CharPtr gCreateInstanceMethod( "create" ); ! static CharPtr gDestroyInstanceMethod( "destroy" ); static LibraryObjectPtr fetchObject( CharCptr aName, MetaClassPtr aClass ) --- 57,62 ---- // ! const CharPtr gCreateInstanceMethod( "create" ); ! const CharPtr gDestroyInstanceMethod( "destroy" ); static LibraryObjectPtr fetchObject( CharCptr aName, MetaClassPtr aClass ) *************** *** 182,186 **** { LibraryObjectRegistryPtr aLORPtr( theRegistry.instance() ); - Guard myGuard( aLORPtr->access() ); aLibraryObject = aLORPtr->resolveObject( aLibraryInstance, aName ); --- 182,185 ---- *************** *** 208,212 **** { LibraryObjectRegistryPtr aLORPtr( theRegistry.instance() ); - Guard myGuard( aLORPtr->access() ); aLORPtr->disgardObject( aLibraryInstance, aLibraryObject ); --- 207,210 ---- *************** *** 220,223 **** --- 218,240 ---- // + // Done with all library objects (assumed) + // + void LibraryObjectRegistry::dropAllObjects( LibraryInstancePtr aLibraryInstance ) + throw ( NullPointerException ) + { + if( aLibraryInstance != NULLPTR ) + { + LibraryObjectRegistryPtr aLORPtr( theRegistry.instance() ); + + aLORPtr->dropObjects( aLibraryInstance ); + } + else + { + throw NullPointerException( LOCATION ); + } + } + + + // // Instance methods // *************** *** 234,237 **** --- 251,255 ---- ) { + GUARD; LibraryInstanceMapIterator aFItr( theInstances.find(aInstance) ); LibObjectReference aObjCache = {NULLPTR,1}; *************** *** 309,312 **** --- 327,331 ---- ) { + GUARD; LibraryInstanceMapIterator aFItr( theInstances.find(aInstance) ); *************** *** 345,348 **** --- 364,425 ---- ; // exception ? } + + } + else + { + ; // do nothing + } + } + + // + // Clean out library instance associated library objects + // + + void LibraryObjectRegistry::dropObjects( LibraryInstancePtr aInstance ) + { + GUARD; + + LibraryInstanceMapIterator aFItr; + + if( aInstance == NULLPTR ) + { + aFItr = theInstances.begin(); + } + else + { + aFItr = theInstances.find( aInstance ); + } + + // + // If we have one (either matched or all) + // we go through it's associated objects and + // dispatch the demise of each object, clearing + // the secondary map as we go. + // + + if( aFItr != theInstances.end() ) + { + do + { + ObjectInstanceMapIterator aFOItr( (*aFItr).second.begin() ); + ObjectInstanceMapIterator aFEItr( (*aFItr).second.end() ); + + while( aFOItr != aFEItr ) + { + LibraryObjectPtr aObject( (*aFOItr).second.theLibObj ); + + aObject->getType()->dispatch + ( + aObject, + gDestroyInstanceMethod, + (void **) NULLPTR, + (void *) NULLPTR + ); + ++aFOItr; + } + + (*aFItr).second.clear(); + ++aFItr; + } while( aInstance == NULLPTR && aFItr != theInstances.end() ); } |