|
From: Frank V. C. <fr...@us...> - 2000-11-18 03:35:25
|
Update of /cvsroot/corelinux/clfw/src/libs/LibLoad In directory slayer.i.sourceforge.net:/tmp/cvs-serv29061/src/libs/LibLoad Modified Files: Library.cpp Log Message: 122753 Library Load Re-implementation Index: Library.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/LibLoad/Library.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Library.cpp 2000/11/17 13:07:09 1.3 --- Library.cpp 2000/11/18 03:35:22 1.4 *************** *** 43,46 **** --- 43,47 ---- static CharPtr gTestMethod( "handlesType" ); static CharPtr gGetLoaderMethod( "getLoaderType" ); + static CharPtr gGetLibraryInstanceMethod( "loadInstance" ); static MetaClassPtr findHandler( CharPtr aName, MetaClassPtr aClass ) *************** *** 70,74 **** ( gTestMethod, ! (void **)&aName, (void *) &results ); --- 71,75 ---- ( gTestMethod, ! (void **)aName, (void *) &results ); *************** *** 120,125 **** Library::Library( void ) - : - theLoaderMap() { ; // do nothing --- 121,124 ---- *************** *** 164,221 **** // - // Registers a loader as per the type argument - // - - LoaderPtr Library::registerLoader( LibraryTypeRef aType, LoaderPtr aLoader ) - throw ( NullPointerException ) - { - LoaderPtr aOldLoader( NULLPTR ); - if( aLoader != NULLPTR ) - { - if( theLoaderMap.find(aType) != theLoaderMap.end() ) - { - aOldLoader = this->deregisterLoader(aType); - } - else - { - ; // do nothing - } - - theLoaderMap[aType] = aLoader; - - } - else - { - throw NullPointerException( LOCATION ); - } - - return aOldLoader; - } - - // - // Removes the loader associated with the type and - // return to the caller. - // - - LoaderPtr Library::deregisterLoader( LibraryTypeRef aType ) - throw ( LoaderNotFoundException ) - { - LoaderPtr aLoader( NULLPTR ); - TypeMapIterator aFItr( theLoaderMap.find(aType) ); - - if( aFItr != theLoaderMap.end() ) - { - aLoader = (*aFItr).second; - theLoaderMap.erase(aFItr); - } - else - { - throw LoaderNotFoundException( LOCATION ); - } - - return aLoader; - } - - // // Work the magic of ontologies! // --- 163,166 ---- *************** *** 239,243 **** else { ! } } --- 184,188 ---- else { ! aInstance = this->loadInstance( aName, aClass ); } } *************** *** 250,291 **** // ! LibraryInstancePtr Library::load( CharPtr, MetaClassPtr ) throw (NullPointerException, LoaderNotFoundException) { LibraryInstancePtr aInstance( NULLPTR ); - return aInstance; - } ! // ! // Request the loader actually load a library instance ! // ! LibraryInstancePtr Library::load( const std::string & aLibraryName, LibraryTypeRef aType ) ! throw ( NullPointerException, LoaderNotFoundException ) ! { ! LibraryInstancePtr aInstance( NULLPTR ); ! TypeMapIterator aFItr( theLoaderMap.find(aType) ); ! if( aFItr != theLoaderMap.end() ) ! { ! aInstance = (*aFItr).second->load(aLibraryName); ! if( aInstance == NULLPTR ) { ! throw NullPointerException( LOCATION ); } else { ! ; // do nothing } } ! else ! { ! throw LoaderNotFoundException( LOCATION ); ! } return aInstance; } // ! // Setup the traversal looking for an appropriate handler // --- 195,233 ---- // ! LibraryInstancePtr Library::load( CharPtr aName , MetaClassPtr aClass ) throw (NullPointerException, LoaderNotFoundException) { LibraryInstancePtr aInstance( NULLPTR ); ! if( aName == NULLPTR || aClass == NULLPTR ) ! { ! throw NullPointerException( LOCATION ); ! } ! else ! { ! bool results(false); ! aClass->dispatch ! ( ! gTestMethod, ! (void **)aName, ! (void *) &results ! ); ! if( results == true ) { ! aInstance = this->loadInstance( aName, aClass ); } else { ! throw LoaderNotFoundException( LOCATION ); } } ! return aInstance; } // ! // Setup the recursion looking for an appropriate handler // *************** *** 298,301 **** --- 240,294 ---- ); } + + // + // The actual work + // + + LibraryInstancePtr Library::loadInstance + ( + CharPtr aLibrary, + MetaClassPtr aTypeClass + ) + { + LibraryInstancePtr aInstance( NULLPTR ); + + // + // First we get the Loader from the LibraryType as it is + // the holder of the goods + // + + MetaTypePtr aLoaderType( NULLPTR ); + + aTypeClass->dispatch + ( + gGetLoaderMethod, + (void **)NULLPTR, + (void *) &aLoaderType + ); + + if( aLoaderType != NULLPTR ) + { + aLoaderType->dispatch + ( + gGetLibraryInstanceMethod, + (void **)aLibrary, + (void *) &aInstance + ); + + } + else + { + throw LoaderNotFoundException( LOCATION ); + } + + + // + // Then we get the loader to create a library + // instance + // + + return aInstance; + } + } |