|
From: Frank V. C. <fr...@us...> - 2000-11-20 05:26:38
|
Update of /cvsroot/corelinux/clfll/src/clfll In directory slayer.i.sourceforge.net:/tmp/cvs-serv13808/src/clfll Modified Files: FunctionLoader.cpp Makefile.am Added Files: FunctionLibraryInstance.cpp FunctionLibraryObject.cpp Log Message: 122702 - Needs latest CVS clfw ***** Error reading new file: (2, 'No such file or directory') ***** Error reading new file: (2, 'No such file or directory') Index: FunctionLoader.cpp =================================================================== RCS file: /cvsroot/corelinux/clfll/src/clfll/FunctionLoader.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** FunctionLoader.cpp 2000/11/18 22:45:22 1.1 --- FunctionLoader.cpp 2000/11/20 05:26:35 1.2 *************** *** 27,34 **** #endif ! #include <cstdio> namespace corelinux { // // Constructor --- 27,44 ---- #endif ! #if !defined(__FUNCTIONLIBRARYINSTANCE_HPP) ! #include <FunctionLibraryInstance.hpp> ! #endif + extern "C" + { + #include <dlfcn.h> + #include <stdio.h> + } + namespace corelinux { + InstanceMap FunctionLoader::theInstances; + // // Constructor *************** *** 66,70 **** // ! bool FunctionLoader::operator==( FunctionLoaderCref aFunctionLoader ) const { return ( this == &aFunctionLoader ); --- 76,83 ---- // ! bool FunctionLoader::operator== ! ( ! FunctionLoaderCref aFunctionLoader ! ) const { return ( this == &aFunctionLoader ); *************** *** 79,95 **** return ( *this ); } ! LibraryInstancePtr FunctionLoader::load( CharPtr ) throw ( LoadException ) { LibraryInstancePtr aPtr( NULLPTR ); return aPtr; } - ! //! version FunctionLoader for the MetaType const DwordCref version(1); ! //! meta indentifier for the FunctionLoader const UniversalIdentifier metaIdentifier --- 92,131 ---- return ( *this ); } + + // + // Load routine produces the appropriate instance after creating + // with dlopen + // ! LibraryInstancePtr FunctionLoader::load( CharPtr aLibName ) ! throw ( LoadException ) { LibraryInstancePtr aPtr( NULLPTR ); + InstanceMapIterator aFItr(FunctionLoader::theInstances.find(aLibName)); + + if( aFItr != FunctionLoader::theInstances.end() ) + { + aPtr = (*aFItr).second; + } + else + { + Handle libHandle( dlopen( aLibName, RTLD_NOW ) ); + if( libHandle != NULLPTR ) + { + aPtr = new FunctionLibraryInstance( aLibName, libHandle ); + } + else + { + ; // exception? + } + } return aPtr; } ! // version FunctionLoader for the MetaType const DwordCref version(1); ! // meta indentifier for the FunctionLoader const UniversalIdentifier metaIdentifier *************** *** 113,119 **** DISPATCH_STATIC_FUNCTION( FunctionLoader, loadInstance ) CharPtr aLibraryName = (CharPtr)args; LibraryInstancePtr *myRet = (LibraryInstancePtr *) ret ; ! *myRet = NULLPTR; CLOSE_DISPATCH_FUNCTION; --- 149,159 ---- DISPATCH_STATIC_FUNCTION( FunctionLoader, loadInstance ) + CharPtr aLibraryName = (CharPtr)args; LibraryInstancePtr *myRet = (LibraryInstancePtr *) ret ; ! ! FunctionLoader aLoader; ! *myRet = aLoader.load( aLibraryName ); ! CLOSE_DISPATCH_FUNCTION; *************** *** 126,130 **** CLOSE_DISPATCH_TABLE; ! // we use the abstract macro for MetaTypeAggregate autonaming DEFINE_METATYPE --- 166,170 ---- CLOSE_DISPATCH_TABLE; ! // we use the regular macro for FunctionLoader autonaming DEFINE_METATYPE Index: Makefile.am =================================================================== RCS file: /cvsroot/corelinux/clfll/src/clfll/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Makefile.am 2000/11/18 22:45:22 1.2 --- Makefile.am 2000/11/20 05:26:35 1.3 *************** *** 12,18 **** SUFFIXES = .cpp .hpp .c .h .f .F .o .moc ! SRCS = clfll.cpp \ ! FunctionLoader.cpp \ ! FunctionLibraryType.cpp \ Makefile.am --- 12,20 ---- SUFFIXES = .cpp .hpp .c .h .f .F .o .moc ! SRCS = clfll.cpp \ ! FunctionLoader.cpp \ ! FunctionLibraryType.cpp \ ! FunctionLibraryInstance.cpp \ ! FunctionLibraryObject.cpp \ Makefile.am |