|
From: Frank V. C. <fr...@us...> - 2000-11-15 12:29:34
|
Update of /cvsroot/corelinux/clfw/src/libs/clfw In directory slayer.i.sourceforge.net:/tmp/cvs-serv6176/src/libs/clfw Modified Files: MetaClass.cpp MetaType.cpp Log Message: 116737 Ontology Support - Added Iterators to MetaType Index: MetaClass.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/MetaClass.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** MetaClass.cpp 2000/11/15 04:33:01 1.2 --- MetaClass.cpp 2000/11/15 12:29:31 1.3 *************** *** 37,153 **** 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> --- 37,41 ---- *************** *** 337,341 **** // Fetch the type name ! CharCptr MetaClass::getTypeName( void ) const { return theType->getInstanceTypeName(); --- 225,229 ---- // Fetch the type name ! CharCptr MetaClass::getInstanceTypeName( void ) const { return theType->getInstanceTypeName(); *************** *** 344,348 **** // Fetch the meta class name ! CharCptr MetaClass::getMetaName( void ) const { return theType->getMetaTypeName(); --- 232,236 ---- // Fetch the meta class name ! CharCptr MetaClass::getMetaTypeName( void ) const { return theType->getMetaTypeName(); *************** *** 436,444 **** throw( InvalidCompositeException ) { ! return new FixedIterator<MemberDescriptorCptr> ! ( ! theType->getInstanceMembers(), ! theType->getInstanceMemberCount() ! ); } --- 324,328 ---- throw( InvalidCompositeException ) { ! return MetaTypePtr(theType)->createMemberIterator(); } *************** *** 450,459 **** throw( InvalidCompositeException ) { ! return new FixedIterator<DispatchDescriptorCptr> ! ( ! theType->getInstanceFunctions(), ! theType->getInstanceFunctionCount() ! ); ! } --- 334,338 ---- throw( InvalidCompositeException ) { ! return MetaTypePtr(theType)->createMethodIterator(); } *************** *** 476,480 **** throw( InvalidCompositeException ) { ! delete anIterator; } --- 355,359 ---- throw( InvalidCompositeException ) { ! MetaTypePtr(theType)->destroyIterator(anIterator); } *************** *** 486,490 **** throw( InvalidCompositeException ) { ! delete anIterator; } --- 365,369 ---- throw( InvalidCompositeException ) { ! MetaTypePtr(theType)->destroyIterator(anIterator); } Index: MetaType.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/MetaType.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** MetaType.cpp 2000/11/15 01:14:32 1.15 --- MetaType.cpp 2000/11/15 12:29:31 1.16 *************** *** 38,41 **** --- 38,45 ---- #endif + #if !defined(__METATYPEFIXEDITERATOR_HPP) + #include <MetaTypeFixedIterator.hpp> + #endif + #include <cstring> *************** *** 573,576 **** --- 577,646 ---- ; // do nothing } + } + // + // Get the parent iterator + // + + Iterator<MetaTypeCptr> *MetaType::createParentIterator( void ) + { + return new MetaTypeFixedIterator<MetaTypeCptr> + ( + this->getParentTypes(), + this->getParentCount() + ); + } + + // + // Get the member iterator + // + + Iterator<MemberDescriptorCptr> *MetaType::createMemberIterator( void ) + { + return new MetaTypeFixedIterator<MemberDescriptorCptr> + ( + this->getInstanceMembers(), + this->getInstanceMemberCount() + ); + } + + // + // Get the method iterator + // + + Iterator<DispatchDescriptorCptr> *MetaType::createMethodIterator( void ) + { + return new MetaTypeFixedIterator<DispatchDescriptorCptr> + ( + this->getInstanceFunctions(), + this->getInstanceFunctionCount() + ); + } + + // + // Return the child or parent iterator + // + + void MetaType::destroyIterator( Iterator<MetaTypeCptr> *anIterator ) + { + delete anIterator; + + } + + // + // Return the member iterator + // + + void MetaType::destroyIterator( Iterator<MemberDescriptorCptr> *anIterator ) + { + delete anIterator; + } + + // + // Return the method iterator + // + + void MetaType::destroyIterator( Iterator<DispatchDescriptorCptr> *anIterator ) + { + delete anIterator; } } |