|
From: Frank V. C. <fr...@us...> - 2000-11-19 03:18:31
|
Update of /cvsroot/corelinux/clfw/src/libs/LibLoad In directory slayer.i.sourceforge.net:/tmp/cvs-serv20361/src/libs/LibLoad Modified Files: LibraryInstance.cpp LibraryObject.cpp LibraryObjectRegistry.cpp Makefile.am Removed Files: LibraryObjectDefinition.cpp Log Message: 122753 Refit LibraryLoad Index: LibraryInstance.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/LibLoad/LibraryInstance.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** LibraryInstance.cpp 2000/08/31 02:18:51 1.2 --- LibraryInstance.cpp 2000/11/19 03:18:28 1.3 *************** *** 34,37 **** --- 34,39 ---- #endif + #include <cstring> + namespace corelinux { *************** *** 40,49 **** // ! LibraryInstance::LibraryInstance( const std::string &aName ) throw ( NullPointerException ) : ! theLibraryName( aName ) { ! if( theLibraryName.empty() == true ) { throw NullPointerException(LOCATION); --- 42,51 ---- // ! LibraryInstance::LibraryInstance( CharCptr aName ) throw ( NullPointerException ) : ! theLibraryName( NULLPTR ) { ! if( aName == NULLPTR ) { throw NullPointerException(LOCATION); *************** *** 51,55 **** else { ! ; // do nothing } } --- 53,58 ---- else { ! theLibraryName = new char[strlen(aName)+1]; ! strcpy(theLibraryName,aName); } } *************** *** 61,65 **** LibraryInstance::LibraryInstance( void ) throw ( Assertion ) : ! theLibraryName() { NEVER_GET_HERE; --- 64,68 ---- LibraryInstance::LibraryInstance( void ) throw ( Assertion ) : ! theLibraryName(NULLPTR) { NEVER_GET_HERE; *************** *** 73,77 **** throw ( Assertion ) : ! theLibraryName() { NEVER_GET_HERE; --- 76,80 ---- throw ( Assertion ) : ! theLibraryName(NULLPTR) { NEVER_GET_HERE; *************** *** 84,88 **** LibraryInstance::~LibraryInstance( void ) { ! ; // do nothing } --- 87,99 ---- LibraryInstance::~LibraryInstance( void ) { ! if( theLibraryName != NULLPTR ) ! { ! delete [] theLibraryName; ! theLibraryName = NULLPTR; ! } ! else ! { ! ; // do nothing ! } } *************** *** 107,118 **** } - // - // Name coercion - // - - LibraryInstance::operator const std::string &( void ) const - { - return theLibraryName; - } // --- 118,121 ---- *************** *** 120,124 **** // ! const std::string & LibraryInstance::getLibraryName( void ) const { return theLibraryName; --- 123,127 ---- // ! CharCptr LibraryInstance::getLibraryName( void ) const { return theLibraryName; *************** *** 131,135 **** LibraryObjectPtr LibraryInstance::getLibraryObject ( ! const std::string & aObjectName ) throw ( NullPointerException ) --- 134,138 ---- LibraryObjectPtr LibraryInstance::getLibraryObject ( ! CharCptr aObjectName ) throw ( NullPointerException ) Index: LibraryObject.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/LibLoad/LibraryObject.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** LibraryObject.cpp 2000/08/31 02:18:51 1.2 --- LibraryObject.cpp 2000/11/19 03:18:28 1.3 *************** *** 32,62 **** { LibraryObject::LibraryObject( void ) - throw ( Assertion ) : ! theName( "" ) { ! NEVER_GET_HERE; } // - // Valid Constructor - // - - LibraryObject::LibraryObject( const std::string & aName ) - : - theName( aName ) - { - ; // do nothing - } - - // // Copy constructor // ! LibraryObject::LibraryObject( LibraryObjectCref aLibraryObject ) : ! theName( aLibraryObject.getName() ) { ! } --- 32,50 ---- { LibraryObject::LibraryObject( void ) : ! Aggregate() { ! ; } // // Copy constructor // ! LibraryObject::LibraryObject( LibraryObjectCref ) : ! Aggregate() { ! NEVER_GET_HERE; } *************** *** 90,101 **** } ! // ! // Accessor for name ! // ! const std::string & LibraryObject::getName( void ) const ! { ! return theName; ! } } --- 78,115 ---- } ! // version LibraryObject for the MetaType ! const DwordCref version(1); ! ! // meta indentifier for the LibraryObject ! ! const UniversalIdentifier metaIdentifier ! ( ! "0829af44-accb-11d4-8df6-00500489272c" ! ); ! ! // Define LibraryObject parents ! ! OPEN_METATYPE_PARENTS( LibraryObject ) ! DEFINE_METATYPE_PARENT( Aggregate ) ! CLOSE_METATYPE_PARENT; ! ! // We construct the null values reference ! ! OPEN_INSTANCEDATA( LibraryObject ) ! CLOSE_INSTANCEDATA; ! ! DEFINE_DUMMY_DISPATCHTABLE( LibraryObject ); ! ! // we use the abstract macro for MetaTypeAggregate autonaming ! ! DEFINE_ABSTRACT_METATYPE ! ( ! LibraryObject, ! metaIdentifier, ! version , ! NULLPTR, ! "Abstract aggregate describing a library entity" ! ); } Index: LibraryObjectRegistry.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/LibLoad/LibraryObjectRegistry.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** LibraryObjectRegistry.cpp 2000/08/31 02:18:51 1.2 --- LibraryObjectRegistry.cpp 2000/11/19 03:18:28 1.3 *************** *** 33,40 **** #endif - #if !defined(__LIBRARYOBJECTDEFINITION_HPP) - #include INCL_LibraryObjectDefinition - #endif - #if !defined(__LIBRARYOBJECT_HPP) #include INCL_LibraryObject --- 33,36 ---- *************** *** 60,64 **** if( theRegistry.instance() == NULLPTR ) { ! theDefinitions.clear(); } else --- 56,60 ---- if( theRegistry.instance() == NULLPTR ) { ! theInstances.clear(); } else *************** *** 86,90 **** LibraryObjectRegistry::~LibraryObjectRegistry( void ) { ! theDefinitions.clear(); } --- 82,86 ---- LibraryObjectRegistry::~LibraryObjectRegistry( void ) { ! theInstances.clear(); } *************** *** 95,100 **** LibraryObjectPtr LibraryObjectRegistry::createObject ( ! LibraryInstancePtr aLibraryInstance, ! const std::string & aDefinitionName ) throw ( NullPointerException ) --- 91,96 ---- LibraryObjectPtr LibraryObjectRegistry::createObject ( ! LibraryInstancePtr aLibraryInstance, ! CharCptr aName ) throw ( NullPointerException ) *************** *** 102,125 **** LibraryObjectPtr aLibraryObject( NULLPTR ); ! if( aLibraryInstance != NULLPTR && aDefinitionName.empty() == false ) { - LibraryObjectDefinitionPtr aOdPtr( NULLPTR ); LibraryObjectRegistryPtr aLORPtr( theRegistry.instance() ); Guard myGuard( aLORPtr->access() ); - aOdPtr = aLORPtr->getDefinition - ( - aLibraryInstance->getLibraryName(), - aDefinitionName - ); - if( aOdPtr != NULLPTR ) - { - aLibraryObject = aOdPtr->createIndividual( aLibraryInstance ); - } - else - { - throw NullPointerException( LOCATION ); - } } else --- 98,108 ---- LibraryObjectPtr aLibraryObject( NULLPTR ); ! if( aLibraryInstance != NULLPTR && ! aName != NULLPTR ) { LibraryObjectRegistryPtr aLORPtr( theRegistry.instance() ); Guard myGuard( aLORPtr->access() ); } else *************** *** 144,242 **** if( aLibraryInstance != NULLPTR && aLibraryObject != NULLPTR ) { - LibraryObjectDefinitionPtr aOdPtr( NULLPTR ); LibraryObjectRegistryPtr aLORPtr( theRegistry.instance() ); Guard myGuard( aLORPtr->access() ); - aOdPtr = aLORPtr->getDefinition - ( - aLibraryInstance->getLibraryName(), - aLibraryObject->getName() - ); - - if( aOdPtr != NULLPTR ) - { - aOdPtr->destroyIndividual( aLibraryInstance, aLibraryObject ); - } - else - { - throw NullPointerException( LOCATION ); - } - } - else - { - throw NullPointerException( LOCATION ); - } - - } - - // - // Register a definition - // - - void LibraryObjectRegistry::registerObjectDefinition - ( - const std::string & aLibraryName, - LibraryObjectDefinitionPtr aDefinition - ) - throw ( NullPointerException ) - { - if( aDefinition != NULLPTR && !(aLibraryName.empty()) ) - { - // - // Put it in a collection to factor function - // - - ObjectDefinitions tm; - tm.insert - ( - ObjectDefinitions::value_type - ( - (const std::string &)(*aDefinition), - aDefinition - ) - ); - - theRegistry.instance()->addDefinition(aLibraryName,tm); - } - else - { - throw NullPointerException( LOCATION ); - } - } - - // - // Register a map of definitions - // - - void LibraryObjectRegistry::registerObjectDefinition - ( - const std::string & aLibraryName, - ObjectDefinitionsCref aDefinitionMap - ) - throw ( NullPointerException ) - { - if( aDefinitionMap.size() != 0 && !(aLibraryName.empty()) ) - { - theRegistry.instance()->addDefinition( aLibraryName, aDefinitionMap ); - } - else - { - throw NullPointerException( LOCATION ); - } - } - - // - // Deregister a single definition - // - void LibraryObjectRegistry::deregisterObjectDefinition - ( - const std::string & aLibraryName - ) - throw ( NullPointerException ) - { - if( ! ( aLibraryName.empty() ) ) - { - theRegistry.instance()->removeDefinition( aLibraryName ); } else --- 127,134 ---- *************** *** 244,311 **** throw NullPointerException( LOCATION ); } - } - // - // Deregister a single definition - // - - void LibraryObjectRegistry::deregisterObjectDefinition - ( - const std::string & aLibraryName, - LibraryObjectDefinitionPtr aDefinition - ) - throw ( NullPointerException ) - { - if( aDefinition != NULLPTR && ! ( aLibraryName.empty() ) ) - { - // - // Put it in a collection to factor function - // - - ObjectDefinitions tm; - tm.insert - ( - ObjectDefinitions::value_type - ( - (const std::string &)(*aDefinition), - aDefinition - ) - ); - - theRegistry.instance()->removeDefinition( aLibraryName, &tm ); - - } - else - { - throw NullPointerException( LOCATION ); - } } // - // Deregister a single definition - // - - void LibraryObjectRegistry::deregisterObjectDefinition - ( - const std::string & aLibraryName, - ObjectDefinitionsCref aDefinitionMap - ) - throw ( NullPointerException ) - { - if( aDefinitionMap.size() != 0 && ! ( aLibraryName.empty() ) ) - { - theRegistry.instance()->removeDefinition - ( - aLibraryName, - &aDefinitionMap - ); - } - else - { - throw NullPointerException( LOCATION ); - } - } - - // // Instance methods // --- 136,143 ---- *************** *** 317,504 **** bool LibraryObjectRegistry::isLibraryDefined ( ! const std::string & aLibrary ) const { GUARD; ! return ( theDefinitions.find( aLibrary ) != theDefinitions.end() ); ! } ! ! // ! // Resolve the definition ! // ! ! LibraryObjectDefinitionPtr LibraryObjectRegistry::getDefinition ! ( ! const std::string & aLibrary, ! const std::string & aDefinition ! ) ! { ! LibraryObjectDefinitionPtr aOdPtr( NULLPTR ); ! DefinitionMapIterator aLItr(theDefinitions.find( aLibrary )); ! ! if( aLItr != theDefinitions.end() ) { ! ObjectDefinitionsIterator aDItr((*aLItr).second.find(aDefinition)); ! if( aDItr != (*aLItr).second.end() ) { ! aOdPtr = (*aDItr).second; } else { ! ; // do nothing } - } - else - { - ; // do nothing } ! ! return aOdPtr; } - // Add a definition entry to the library key - - void LibraryObjectRegistry::addDefinition - ( - const std::string & aLibrary, - ObjectDefinitionsCref aObjectMap - ) - { - GUARD; - - DefinitionMapIterator aItr; - ObjectDefinitionsConstIterator begin(aObjectMap.begin()); - ObjectDefinitionsConstIterator end(aObjectMap.end()); - - // - // If the library is defined - // - - if( (aItr = theDefinitions.find( aLibrary )) != theDefinitions.end() ) - { - ; // do nothing - } - - // - // This is the first entry - // - - else - { - - ObjectDefinitions tm; - tm.insert - ( - ObjectDefinitions::value_type - ( - (*begin).first, - (*begin).second - ) - ); - - theDefinitions.insert( DefinitionMap::value_type(aLibrary,tm) ); - aItr = theDefinitions.find( aLibrary ); - ++begin; - } - - // - // And the entry does not collide, insert - // - - while( begin != end ) - { - if( (*aItr).second.find( (*begin).first ) == (*aItr).second.end() ) - { - (*aItr).second.insert - ( - ObjectDefinitions::value_type - ( - (*begin).first, - (*begin).second - ) - ); - } - - // - // Otherwise collide, type exception? - // - - else - { - NEVER_GET_HERE; - } - ++begin; - } - } - - // Add a definition entry to the library key - - void LibraryObjectRegistry::removeDefinition - ( - const std::string & aLibrary, - ObjectDefinitionsCptr aObjectMap - ) - { - GUARD; - - DefinitionMapIterator aItr(theDefinitions.find( aLibrary )); - - if( aItr != theDefinitions.end() ) - { - Count remain(0); - - // - // If it is a full library deregister - // - - if( aObjectMap == NULLPTR ) - { - ObjectDefinitionsIterator begin; - ObjectDefinitionsIterator end; - - // First clean out the definitions map - begin = (*aItr).second.begin(); - end = (*aItr).second.end(); - (*aItr).second.erase(begin,end); - } - - // - // Incremental removal - // - - else - { - ObjectDefinitionsConstIterator begin(aObjectMap->begin()); - ObjectDefinitionsConstIterator end(aObjectMap->end()); - - while( begin != end ) - { - (*aItr).second.erase( (*begin).first ); - ++begin; - } - - remain = Count( (*aItr).second.size() ); - } - - // - // Check for library removal - // - - if( remain == 0 ) - { - theDefinitions.erase(aItr); - } - else - { - - } - } - else - { - ; // do nothing? exception? - } - } } --- 149,175 ---- bool LibraryObjectRegistry::isLibraryDefined ( ! CharCptr aLibrary ) const { GUARD; ! bool found(false); ! ObjectInstanceMapConstIterator begin( theInstances.begin() ); ! ObjectInstanceMapConstIterator end( theInstances.end() ); ! while( begin != end && found == false ) { ! if( strcmp( (*begin).first->getLibraryName(), aLibrary ) == 0 ) { ! found = true; } else { ! ++begin; } } ! return found; } } Index: Makefile.am =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/LibLoad/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Makefile.am 2000/08/31 02:18:51 1.4 --- Makefile.am 2000/11/19 03:18:28 1.5 *************** *** 18,22 **** LibraryInstance.cpp \ LibraryObject.cpp \ - LibraryObjectDefinition.cpp \ LibraryObjectRegistry.cpp \ LibraryType.cpp \ --- 18,21 ---- --- LibraryObjectDefinition.cpp DELETED --- |