|
From: Frank V. C. <fr...@us...> - 2000-11-15 04:33:04
|
Update of /cvsroot/corelinux/clfw/src/libs/clfw In directory slayer.i.sourceforge.net:/tmp/cvs-serv1096/src/libs/clfw Modified Files: MetaClass.cpp MetaSpace.cpp Ontology.cpp Log Message: 116737 Ontology work Index: MetaClass.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/MetaClass.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** MetaClass.cpp 2000/11/15 01:14:32 1.1 --- MetaClass.cpp 2000/11/15 04:33:01 1.2 *************** *** 23,26 **** --- 23,30 ---- #endif + #if !defined(__METASPACE_HPP) + #include <MetaSpace.hpp> + #endif + #if !defined(__METACLASS_HPP) #include <MetaClass.hpp> *************** *** 33,36 **** --- 37,267 ---- namespace corelinux { + template< class T > + class FixedIterator : public Iterator<T> + { + public: + + FixedIterator( void ) + : + Iterator<T>(), + theBase( NULLPTR ), + theCurrent( NULLPTR ), + theCount( 0 ) + { + ; // do nothing + } + + FixedIterator( T *a, Count aCount ) + : + Iterator<T>(), + theBase( a ), + theCurrent( a ), + theCount( aCount ) + { + ; // do nothing + } + + FixedIterator( FixedIterator const & aRef ) + : + Iterator<T>( aRef ), + theBase( aRef.theBase ), + theCurrent( theBase ), + theCount( aRef.theCount ) + { + ; // do nothing + } + + virtual ~FixedIterator( void ) + { + theBase = theCurrent = NULLPTR; + theCount = 0; + } + + virtual bool isValid( void ) const + { + return !(*theCurrent == NULLPTR); + } + + + virtual T getElement( void ) + const throw(IteratorBoundsException) + { + if( this->isValid() == false ) + { + throw IteratorBoundsException(LOCATION); + } + else + { + ; // do nothing + } + return (*theCurrent); + } + + virtual void setFirst( void ) + { + theCurrent = theBase; + } + + + virtual void setNext( void ) + throw(IteratorBoundsException) + { + if( *theCurrent != NULLPTR ) + { + ++theCurrent; + } + else + { + throw IteratorBoundsException(LOCATION); + } + } + + + virtual void setPrevious( void ) + throw(IteratorBoundsException) + { + if( theCurrent != theBase && + *theBase != NULLPTR ) + { + --theCurrent; + } + else + { + throw IteratorBoundsException(LOCATION); + } + } + + /// Set iterator to last element + + virtual void setLast( void ) + throw(IteratorBoundsException) + { + theCurrent = theBase; + for( Count x = 0; x < theCount; ++x, ++theCurrent ); + } + + protected: + private: + + T *theBase; + T *theCurrent; + Count theCount; + + }; + + template< class T > + class FixedParentIterator : public Iterator<T> + { + + public: + FixedParentIterator( void ) + : + Iterator<T>(), + theBase( NULLPTR ), + theCurrent( NULLPTR ), + theCount( 0 ) + { + ; // do nothing + } + + FixedParentIterator( MetaTypeCptr *a, Count aCount ) + : + Iterator<T>(), + theBase( a ), + theCurrent( a ), + theCount( aCount ) + { + ; // do nothing + } + + FixedParentIterator( FixedParentIterator const & aRef ) + : + Iterator<T>( aRef ), + theBase( aRef.theBase ), + theCurrent( theBase ), + theCount( aRef.theCount ) + { + ; // do nothing + } + + virtual ~FixedParentIterator( void ) + { + theBase = theCurrent = NULLPTR; + theCount = 0; + } + + virtual bool isValid( void ) const + { + return !(*theCurrent == NULLPTR); + } + + + virtual MetaClassCptr getElement( void ) + const throw(IteratorBoundsException) + { + MetaClassCptr aClass( NULLPTR ); + + if( this->isValid() == false ) + { + throw IteratorBoundsException(LOCATION); + } + else + { + aClass = MetaSpace::getClassForType( *theCurrent ); + } + return aClass; + } + virtual void setFirst( void ) + { + theCurrent = theBase; + } + + + virtual void setNext( void ) + throw(IteratorBoundsException) + { + if( *theCurrent != NULLPTR ) + { + ++theCurrent; + } + else + { + throw IteratorBoundsException(LOCATION); + } + } + + + virtual void setPrevious( void ) + throw(IteratorBoundsException) + { + if( theCurrent != theBase && + *theBase != NULLPTR ) + { + --theCurrent; + } + else + { + throw IteratorBoundsException(LOCATION); + } + } + + /// Set iterator to last element + + virtual void setLast( void ) + throw(IteratorBoundsException) + { + theCurrent = theBase; + for( Count x = 0; x < theCount; ++x, ++theCurrent ); + } + + protected: + private: + + MetaTypeCptr *theBase; + MetaTypeCptr *theCurrent; + Count theCount; + + }; + // // Constructor not used *************** *** 104,107 **** --- 335,353 ---- } + // Fetch the type name + + CharCptr MetaClass::getTypeName( void ) const + { + return theType->getInstanceTypeName(); + } + + // Fetch the meta class name + + CharCptr MetaClass::getMetaName( void ) const + { + return theType->getMetaTypeName(); + + } + // // Fetch the base type *************** *** 156,160 **** // ! // Get the iterator // --- 402,406 ---- // ! // Get the children iterator // *************** *** 169,182 **** } // ! // Return the iterator // void MetaClass::destroyIterator( Iterator<MetaClassCptr> *anIterator ) throw( InvalidCompositeException ) { ! delete (CoreLinuxIterator<ChildrenIterator,MetaClassCptr>*)anIterator; } } --- 415,492 ---- } + // + // Get the parent iterator + // + + Iterator<MetaClassCptr> *MetaClass::createParentIterator( void ) + throw( InvalidCompositeException ) + { + return new FixedParentIterator<MetaClassCptr> + ( + theType->getParentTypes(), + theType->getParentCount() + ); + } + + // + // Get the member iterator + // + + Iterator<MemberDescriptorCptr> *MetaClass::createMemberIterator( void ) + throw( InvalidCompositeException ) + { + return new FixedIterator<MemberDescriptorCptr> + ( + theType->getInstanceMembers(), + theType->getInstanceMemberCount() + ); + } + // ! // Get the method iterator // + Iterator<DispatchDescriptorCptr> *MetaClass::createMethodIterator( void ) + throw( InvalidCompositeException ) + { + return new FixedIterator<DispatchDescriptorCptr> + ( + theType->getInstanceFunctions(), + theType->getInstanceFunctionCount() + ); + + } + + // + // Return the child or parent iterator + // + void MetaClass::destroyIterator( Iterator<MetaClassCptr> *anIterator ) throw( InvalidCompositeException ) + { + delete anIterator; + + } + + // + // Return the member iterator + // + + void MetaClass::destroyIterator( Iterator<MemberDescriptorCptr> *anIterator ) + throw( InvalidCompositeException ) { ! delete anIterator; ! } + // + // Return the method iterator + // + + void MetaClass::destroyIterator( Iterator<DispatchDescriptorCptr> *anIterator ) + throw( InvalidCompositeException ) + { + delete anIterator; } + } Index: MetaSpace.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/MetaSpace.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** MetaSpace.cpp 2000/11/15 01:14:32 1.3 --- MetaSpace.cpp 2000/11/15 04:33:01 1.4 *************** *** 32,35 **** --- 32,39 ---- #endif + #if !defined(__METACLASS_HPP) + #include <MetaClass.hpp> + #endif + #if !defined(__MAP_HPP) #include <corelinux/Map.hpp> *************** *** 105,108 **** --- 109,145 ---- // + // Retrieves the class for a metatype + // + + MetaClassCptr MetaSpace::getClassForType( MetaTypeCptr aType ) + { + MetaClassCptr aClass( NULLPTR ); + + if( MetaSpace::theInitializedFlag == true ) + { + OntologyPtr aOntology + ( + MetaSpace::getOntology(aType->getDomainName()) + ); + + if( aOntology != NULLPTR ) + { + aClass = aOntology->getClass(aType); + } + else + { + ; // do nothing + } + } + else + { + ; // do nothing + } + + return aClass; + } + + + // // Store intermediate // *************** *** 129,135 **** { // ! // Because we are initialized, either ! // this type has a domain waiting for it, ! // or we need to create one. // } --- 166,171 ---- { // ! // At this point, the user can add types ! // via the ontology // } Index: Ontology.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/Ontology.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Ontology.cpp 2000/11/15 01:14:32 1.4 --- Ontology.cpp 2000/11/15 04:33:01 1.5 *************** *** 291,295 **** ++begin ) { - this->insertType( (*begin).first, (*begin).second ); } --- 291,294 ---- *************** *** 317,321 **** if( parentCount == 0 ) { - printf("Adding root %s\n",aType->getMetaTypeName() ); theRootMap[aType] = aClass; } --- 316,319 ---- *************** *** 372,376 **** if( nonLocal == parentCount ) { - printf("Adding root %s\n",aType->getMetaTypeName() ); theRootMap[aType] = aClass; } --- 370,373 ---- *************** *** 412,415 **** --- 409,413 ---- } } + /* Common rcs information do not modify |