|
From: Frank V. C. <fr...@us...> - 2000-11-15 01:14:36
|
Update of /cvsroot/corelinux/clfw/src/libs/clfw In directory slayer.i.sourceforge.net:/tmp/cvs-serv20673/src/libs/clfw Modified Files: Makefile.am MetaSpace.cpp MetaType.cpp Ontology.cpp Added Files: MetaClass.cpp Log Message: 116737 Ontology ***** Error reading new file: (2, 'No such file or directory') Index: Makefile.am =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/Makefile.am,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** Makefile.am 2000/11/11 17:45:54 1.15 --- Makefile.am 2000/11/15 01:14:32 1.16 *************** *** 30,33 **** --- 30,34 ---- UnsignedInteger.cpp \ MetaSpace.cpp \ + MetaClass.cpp \ Ontology.cpp \ UnsignedShortInteger.cpp Index: MetaSpace.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/MetaSpace.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** MetaSpace.cpp 2000/11/12 03:22:06 1.2 --- MetaSpace.cpp 2000/11/15 01:14:32 1.3 *************** *** 136,139 **** --- 136,168 ---- } + OntologyPtr MetaSpace::getOntology( CharCptr domain ) + { + OntologyPtr aPtr( NULLPTR ); + + if( MetaSpace::theInitializedFlag == true ) + { + OntologyMapPtr theMap( (OntologyMapPtr)MetaSpace::theHead ); + OntologyMapIterator aFItr + ( + theMap->find( domain ? domain : MetaSpace::theDefaultDomain ) + ); + + if( aFItr != theMap->end() ) + { + aPtr = (*aFItr).second; + } + else + { + ; // do nothing + } + } + else + { + + } + + return aPtr; + } + // // Initialize all ontologies by domain name (namespaces) *************** *** 149,152 **** --- 178,182 ---- MetaSpaceLinkPtr aLink = (MetaSpaceLinkPtr)MetaSpace::theHead; + MetaSpace::theHead = NULLPTR; // *************** *** 166,170 **** if( aFItr == theMap->end() ) { ! OntologyPtr aOntology = new Ontology( aMT->getDomainName() ); (*theMap)[aOntology->getDomainName()] = aOntology; } --- 196,200 ---- if( aFItr == theMap->end() ) { ! aOntology = new Ontology( aMT->getDomainName() ); (*theMap)[aOntology->getDomainName()] = aOntology; } *************** *** 174,191 **** } ! aOntology->addMetaType( aMT ); MetaSpaceLinkPtr aTmp = aLink; aLink = (MetaSpaceLinkPtr)aLink->next; delete aTmp; } // // Now go and initialize the corelinux first before the others // aFItr = theMap->find(MetaSpace::theDefaultDomain); ! if( aFItr != theMap->end() ) { ! } else --- 204,235 ---- } ! aOntology->seedMetaType( aMT ); ! MetaSpaceLinkPtr aTmp = aLink; + aLink = (MetaSpaceLinkPtr)aLink->next; + delete aTmp; } // + // Setup for initialization and checks + // + + MetaSpace::theHead = (VoidPtr)theMap; + aOntology = NULLPTR ; + + + // // Now go and initialize the corelinux first before the others // + OntologyMapIterator aEnd(theMap->end()); + aFItr = theMap->find(MetaSpace::theDefaultDomain); ! if( aFItr != aEnd ) { ! aOntology = (*aFItr).second; ! aOntology->initialize(); } else *************** *** 195,202 **** aFItr = theMap->begin(); ! while( aFItr != theMap->end() ) { } } --- 239,256 ---- aFItr = theMap->begin(); ! while( aFItr != aEnd ) { + if( (*aFItr).second != aOntology ) + { + (*aFItr).second->initialize(); + } + else + { + ; // do nothing + } + ++aFItr; } + } Index: MetaType.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/MetaType.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** MetaType.cpp 2000/11/11 17:45:54 1.14 --- MetaType.cpp 2000/11/15 01:14:32 1.15 *************** *** 171,179 **** // Get the list of parents ! MetaTypeCptr *const MetaType::getParentTypes( void ) const { return theBaseClasses; } // Get the list of data members --- 171,195 ---- // Get the list of parents ! MetaTypeCptr *const MetaType::getParentTypes( void ) const { return theBaseClasses; } + // Get the count of parents + + Count MetaType::getParentCount( void ) const + { + Count aValue(0); + MetaTypeCptr *pMt( this->getParentTypes() ); + + while(*pMt++ != NULLPTR ) + { + ++aValue; + } + + return aValue; + } + + // Get the list of data members *************** *** 183,186 **** --- 199,217 ---- } + // Get the count of members declared + + Count MetaType::getInstanceMemberCount( void ) const + { + Count aValue(0); + MemberDescriptorCptr *pMt( this->getInstanceMembers() ); + + while(*pMt++ != NULLPTR ) + { + ++aValue; + } + + return aValue; + } + // Get the list of function dispatch descriptors *************** *** 188,191 **** --- 219,237 ---- { return theDispatchFunctions; + } + + // Get the count of members declared + + Count MetaType::getInstanceFunctionCount( void ) const + { + Count aValue(0); + DispatchDescriptorCptr *pMt( this->getInstanceFunctions() ); + + while(*pMt++ != NULLPTR ) + { + ++aValue; + } + + return aValue; } Index: Ontology.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/Ontology.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Ontology.cpp 2000/11/12 03:22:06 1.3 --- Ontology.cpp 2000/11/15 01:14:32 1.4 *************** *** 27,30 **** --- 27,42 ---- #endif + #if !defined(__METASPACE_HPP) + #include <MetaSpace.hpp> + #endif + + #if !defined(__METACLASS_HPP) + #include <MetaClass.hpp> + #endif + + #if !defined(__CORELINUXASSOCIATIVEITERATOR_HPP) + #include <corelinux/CoreLinuxAssociativeIterator.hpp> + #endif + #include <cstring> *************** *** 32,38 **** { Ontology::Ontology( CharCptr aDomain ) : ! theDomainName( NULLPTR ) { if( aDomain == NULLPTR || (*aDomain == Char( 0 )) ) --- 44,55 ---- { + // + // Default constructor requires a name + // + Ontology::Ontology( CharCptr aDomain ) : ! theDomainName( NULLPTR ), ! theInitializedFlag( false ) { if( aDomain == NULLPTR || (*aDomain == Char( 0 )) ) *************** *** 47,60 **** --- 64,95 ---- } + // + // Unused constructor + // + Ontology::Ontology( void ) + : + theDomainName( NULLPTR ), + theInitializedFlag( false ) { } + // + // Unused copy constructor + // + Ontology::Ontology( OntologyCref ) + : + theDomainName( NULLPTR ), + theInitializedFlag( false ) { } + // + // Virtual destructor + // + Ontology::~Ontology( void ) { *************** *** 67,94 **** ; // do nothing } } OntologyRef Ontology::operator=( OntologyCref ) { return ( *this ); } ! bool Ontology::operator==( OntologyCref ) const { ! return true; } void Ontology::addMetaType( MetaTypeCptr aMetaType ) { } ! void Ontology::addAsChild( MetaTypeCptr , MetaTypeCptr ) { ! ; // do nothing } CharCptr Ontology::getDomainName( void ) const { return theDomainName; } } --- 102,413 ---- ; // do nothing } + + // + // Because all the allocations for the meta classes + // are in the class map, we delete only from here + // + + for( ClassMapIterator begin = theClassMap.begin() ; + begin != theClassMap.end(); + ++begin ) + { + delete (*begin).second; + } + + theClassMap.clear(); + theRootMap.clear(); + + theInitializedFlag = false; } + // + // Assignment operator not used + // + OntologyRef Ontology::operator=( OntologyCref ) { return ( *this ); } + + // + // Equality operator not used + // ! bool Ontology::operator==( OntologyCref aRef ) const { ! return ( this == &aRef ); } + // + // Add a new type to the ontology + // + void Ontology::addMetaType( MetaTypeCptr aMetaType ) { + if( aMetaType == NULLPTR ) + { + throw NullPointerException( LOCATION ); + } + else + { + MetaClassPtr aClass( new MetaClass( aMetaType ) ); + theClassMap[aMetaType] = aClass; + this->insertType( aMetaType, aClass ); + } + } + + // + // Add a child reference to a member of this ontology + // + + void Ontology::addAsChild( MetaTypeCptr aParent, MetaClassCptr aChild ) + throw ( NullPointerException ) + { + if( aParent == NULLPTR || aChild == NULLPTR ) + { + throw NullPointerException( LOCATION ); + } + else + { + ClassMapIterator aFItr( theClassMap.find(aParent) ); + if( aFItr != theClassMap.end() ) + { + (*aFItr).second->addComponent( aChild ); + } + else + { + throw NullPointerException( LOCATION ); + } + } } ! // ! // Using the identifier, add a child reference ! // ! ! void Ontology::addAsChild ! ( ! UniversalIdentifierCref aParentId, ! MetaTypeCptr aChild ! ) ! throw ( NullPointerException ) { ! if( aChild == NULLPTR ) ! { ! throw NullPointerException( LOCATION ); ! } ! else ! { ! // ! // Find the parent by identifier ! // ! ! for( ClassMapIterator begin = theClassMap.begin() ; ! begin != theClassMap.end(); ! ++begin ) ! { ! if( (*begin).first->getIdentifier() == aParentId ) ! { ! (*begin).second->addComponent( this->getClass( aChild ) ); ! break; ! } ! else ! { ! ; // need some exception here ! } ! } ! } } + // + // Fetch the domain name + // + CharCptr Ontology::getDomainName( void ) const { return theDomainName; + } + // + // Get the iterator + // + + Iterator<MetaClassCptr> *Ontology::createIterator( void ) + { + return new CoreLinuxAssociativeIterator<ClassMapIterator,MetaTypeCptr,MetaClassCptr> + ( + theClassMap.begin(), + theClassMap.end() + ); + } + + Iterator<MetaClassCptr> *Ontology::createRootIterator( void ) + { + return new CoreLinuxAssociativeIterator<ClassMapIterator,MetaTypeCptr,MetaClassCptr> + ( + theRootMap.begin(), + theRootMap.end() + ); + } + // + // Return the iterator + // + + void Ontology::destroyIterator( Iterator<MetaClassCptr> *anIterator ) + { + delete (CoreLinuxAssociativeIterator<ClassMapIterator,MetaTypeCptr,MetaClassCptr>*)anIterator; + } + + + // + // Prepare for our type hierarchy + // + + void Ontology::seedMetaType( MetaTypeCptr aMetaType ) + { + if( aMetaType == NULLPTR ) + { + throw NullPointerException( LOCATION ); + } + else + { + theClassMap[aMetaType] = new MetaClass( aMetaType ); + } + } + + // + // Initialize the state + // + + void Ontology::initialize( void ) + { + if( this->theInitializedFlag == false ) + { + // + // Iterate through the class map + // + + for( ClassMapIterator begin = theClassMap.begin() ; + begin != theClassMap.end(); + ++begin ) + { + + this->insertType( (*begin).first, (*begin).second ); + } + + } + else + { + ; // do nothing + } + + } + + // + // Used by all to fix the type in the ontology + // + + void Ontology::insertType( MetaTypeCptr aType, MetaClassPtr aClass ) + { + Count parentCount( aType->getParentCount() ); + // + // If the target has no parent (a root) then + // add to the root map + // + + if( parentCount == 0 ) + { + printf("Adding root %s\n",aType->getMetaTypeName() ); + theRootMap[aType] = aClass; + } + + // + // Else, we go through the parents and check each + // for linkages + // + + else + { + Count nonLocal(0); + MetaTypeCptr *parents( aType->getParentTypes() ); + + while( *parents != NULLPTR ) + { + CharCptr aDomainName((*parents)->getDomainName()); + // + // If parent is local to this ontology + // + + if( strcmp(theDomainName,aDomainName) == 0 ) + { + this->addAsChild( *parents, aClass ); + } + + // + // Otherwise, nonlocal and we get the ontology to add + // to from the MetaSpace + // + + else + { + OntologyPtr aOntology( MetaSpace::getOntology( aDomainName ) ); + + if( aOntology != NULLPTR ) + { + aOntology->addAsChild( *parents, aClass ); + } + else + { + throw NullPointerException( LOCATION ); + } + ++nonLocal; + } + ++parents; + } + + // + // If all our parents are non local, then we are a + // root member of this ontology lattice + // + + if( nonLocal == parentCount ) + { + printf("Adding root %s\n",aType->getMetaTypeName() ); + theRootMap[aType] = aClass; + } + else + { + ; // do nothing + } + } + + } + + // + // Extract the class from the appropriate ontology + // + + MetaClassCptr Ontology::getClass( MetaTypeCptr aType ) const + { + MetaClassCptr aClass( NULLPTR ); + + if( strcmp( theDomainName, aType->getDomainName() ) == 0 ) + { + ClassMapConstIterator aFItr( theClassMap.find(aType) ); + if( aFItr != theClassMap.end() ) + { + aClass = (*aFItr).second; + } + else + { + throw NullPointerException( LOCATION ); + } + + } + else + { + OntologyPtr aOntology( MetaSpace::getOntology( aType->getDomainName() ) ); + aClass = aOntology->getClass( aType ); + } + return aClass; } } |