|
From: Frank V. C. <fr...@us...> - 2000-10-30 05:01:29
|
Update of /cvsroot/corelinux/clfw/src/testdrivers/exf1 In directory slayer.i.sourceforge.net:/tmp/cvs-serv14134/src/testdrivers/exf1 Modified Files: Makefile.am examp1.cpp Added Files: UserType.cpp Log Message: 119678 Completed dispatch table functionality with example ***** Error reading new file: (2, 'No such file or directory') Index: Makefile.am =================================================================== RCS file: /cvsroot/corelinux/clfw/src/testdrivers/exf1/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Makefile.am 2000/10/03 02:14:04 1.1 --- Makefile.am 2000/10/30 05:01:26 1.2 *************** *** 12,20 **** SUFFIXES = .cpp .hpp .c .h .f .F .o .moc ! #SUBDIRS = include ! bin_PROGRAMS = exf1 ! exf1_SOURCES = examp1.cpp exf1_LDADD = ${top_builddir}/src/libs/clfw/libclfw++.la --- 12,20 ---- SUFFIXES = .cpp .hpp .c .h .f .F .o .moc ! SUBDIRS = include ! bin_PROGRAMS = exf1 ! exf1_SOURCES = examp1.cpp UserType.cpp exf1_LDADD = ${top_builddir}/src/libs/clfw/libclfw++.la Index: examp1.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/testdrivers/exf1/examp1.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** examp1.cpp 2000/10/29 17:09:53 1.16 --- examp1.cpp 2000/10/30 05:01:26 1.17 *************** *** 69,72 **** --- 69,76 ---- #endif + #if !defined(__USERTYPE_HPP) + #include <UserType.hpp> + #endif + using namespace corelinux; *************** *** 82,85 **** --- 86,94 ---- int main( void ); + // + // MetaType information dump + // + + void dumpFundementals( void ); void dumpMetaTypeInformation( MetaTypeCptr ); void dumpTypeInformation( FrameworkEntityPtr ); *************** *** 88,91 **** --- 97,102 ---- void dumpParents( MetaTypeCptr ); + void testDispatch( void ); + // // Assertion and Exception handlers *************** *** 134,214 **** try { ! // ! // Because the root (and a number of support classes) are abstract, ! // we can't allocate them, but we can reason with them ! // ! ! dumpMetaTypeInformation( FrameworkEntity::getTypeDescriptor() ); ! dumpMetaTypeInformation( Number::getTypeDescriptor() ); ! dumpMetaTypeInformation( UnsignedNumber::getTypeDescriptor() ); ! dumpMetaTypeInformation( SignedNumber::getTypeDescriptor() ); ! ! // ! // Now we sweeten the pot with showing the factory methods, ! // introspection, getters, setters, and destructors ! // ! ! // bool ! ! BooleanPtr aBoolean = new Boolean(true); ! dumpTypeInformation( aBoolean ); ! cout << "Value of aBoolean = " << ! getValue<bool>("Value",aBoolean) << endl; ! delete aBoolean; ! ! // real ! ! RealNumberPtr aReal = RealNumber::create(); ! setValue<Real>("Value",9.7,aReal); ! dumpTypeInformation( aReal ); ! cout << "Value of aReal = " << ! getValue<Real>("Value",aReal) << endl; ! RealNumber::destroy( aReal ); ! ! // signed Integer ! ! IntegerPtr aInteger = Integer::create(); ! setValue<Int>("Value",8,aInteger); ! dumpTypeInformation( aInteger ); ! cout << "Value of aInteger = " << ! getValue<Int>("Value",aInteger) << endl; ! Integer::destroy( aInteger ); ! ! // Show that new is overriden even for constructors with ! // values by dumping the allocation information after ! // destructor ! ! IntegerPtr anotherInteger = new Integer(7); ! cout << "Value of anotherInteger = " << ! anotherInteger->getValue() << endl; ! delete anotherInteger; ! dumpMetaTypeInformation( Integer::getTypeDescriptor() ); ! ! // signed Short ! ! ShortIntegerPtr aShort = ShortInteger::create(); ! setValue<Short>("Value",3,aShort); ! dumpTypeInformation( aShort ); ! cout << "Value of aShort = " ! << getValue<Short>("Value",aShort) << endl; ! ShortInteger::destroy( aShort ); ! ! // unsigned Integer ! ! UnsignedIntegerPtr aUnsigned = new UnsignedInteger; ! setValue<UnsignedInt>( "Value",(UnsignedInt)-1,aUnsigned ); ! dumpTypeInformation( aUnsigned ); ! cout << "Value of aUnsigned = " ! << getValue<UnsignedInt>("Value",aUnsigned) << endl; ! delete aUnsigned; ! ! // unsigned short integer ! ! UnsignedShortIntegerPtr aUnsignedShort = new UnsignedShortInteger; ! setValue<Word>( "Value",(Word)-2,aUnsignedShort); ! dumpTypeInformation( aUnsignedShort ); ! cout << "Value of aUnsignedShort = " ! << getValue<UnsignedInt>("Value",aUnsigned) << endl; ! delete aUnsignedShort; } --- 145,150 ---- try { ! testDispatch(); ! //dumpFundementals(); } *************** *** 233,236 **** --- 169,310 ---- } + void testDispatch( void ) + { + UserTypePtr aType( new UserType ); + UnsignedShortIntegerPtr aValue( new UnsignedShortInteger(8) ); + + dumpTypeInformation( aType ); + + // + // Dispatch the method + // + + // + // Get the accumulator data member of UserType, + // and get it's value + // + + cout << "Value of Accumulator before = " + << getValue<UnsignedInt> + ( + "Value", + getValue<UnsignedIntegerPtr> + ( + "Accumulator", + aType + ) + ) << endl; + + aType->getType()->dispatch + ( + aType, + "addToAccumulator", + (void **)aValue, + (void *) 0 + ); + + // + // Get the accumulator data member of UserType, + // and get it's value + // + + cout << "Value of Accumulator after = " + << getValue<UnsignedInt> + ( + "Value", + getValue<UnsignedIntegerPtr> + ( + "Accumulator", + aType + ) + ) << endl; + + delete aType; + delete aValue; + } + + void dumpFundementals( void ) + { + // + // Because the root (and a number of support classes) are abstract, + // we can't allocate them, but we can reason with them + // + + dumpMetaTypeInformation( FrameworkEntity::getTypeDescriptor() ); + dumpMetaTypeInformation( Number::getTypeDescriptor() ); + dumpMetaTypeInformation( UnsignedNumber::getTypeDescriptor() ); + dumpMetaTypeInformation( SignedNumber::getTypeDescriptor() ); + dumpMetaTypeInformation( UserType::getTypeDescriptor() ); + + // + // Now we sweeten the pot with showing the factory methods, + // introspection, getters, setters, and destructors + // + + // bool + + BooleanPtr aBoolean = new Boolean(true); + dumpTypeInformation( aBoolean ); + cout << "Value of aBoolean = " << + getValue<bool>("Value",aBoolean) << endl; + delete aBoolean; + + // real + + RealNumberPtr aReal = RealNumber::create(); + setValue<Real>("Value",9.7,aReal); + dumpTypeInformation( aReal ); + cout << "Value of aReal = " << + getValue<Real>("Value",aReal) << endl; + RealNumber::destroy( aReal ); + + // signed Integer + + IntegerPtr aInteger = Integer::create(); + setValue<Int>("Value",8,aInteger); + dumpTypeInformation( aInteger ); + cout << "Value of aInteger = " << + getValue<Int>("Value",aInteger) << endl; + Integer::destroy( aInteger ); + + // Show that new is overriden even for constructors with + // values by dumping the allocation information after + // destructor + + IntegerPtr anotherInteger = new Integer(7); + cout << "Value of anotherInteger = " << + anotherInteger->getValue() << endl; + delete anotherInteger; + dumpMetaTypeInformation( Integer::getTypeDescriptor() ); + + // signed Short + + ShortIntegerPtr aShort = ShortInteger::create(); + setValue<Short>("Value",3,aShort); + dumpTypeInformation( aShort ); + cout << "Value of aShort = " + << getValue<Short>("Value",aShort) << endl; + ShortInteger::destroy( aShort ); + + // unsigned Integer + + UnsignedIntegerPtr aUnsigned = new UnsignedInteger; + setValue<UnsignedInt>( "Value",(UnsignedInt)-1,aUnsigned ); + dumpTypeInformation( aUnsigned ); + cout << "Value of aUnsigned = " + << getValue<UnsignedInt>("Value",aUnsigned) << endl; + delete aUnsigned; + + // unsigned short integer + + UnsignedShortIntegerPtr aUnsignedShort = new UnsignedShortInteger; + setValue<Word>( "Value",(Word)-2,aUnsignedShort); + dumpTypeInformation( aUnsignedShort ); + cout << "Value of aUnsignedShort = " + << getValue<UnsignedInt>("Value",aUnsigned) << endl; + delete aUnsignedShort; + + } + // // Dump info on meta types *************** *** 259,264 **** AllocatorPtr aAPtr( aMTPtr->getAllocator() ); cout ! << "number allocs = " << aAPtr->getAllocateCount() << endl ! << "number deallocs = " << aAPtr->getDeallocateCount() << endl; } else --- 333,340 ---- AllocatorPtr aAPtr( aMTPtr->getAllocator() ); cout ! << "number allocs = " << aAPtr->getAllocateCount() ! << endl ! << "number deallocs = " << aAPtr->getDeallocateCount() ! << endl; } else *************** *** 316,321 **** { cout ! << "\tClass = " << parents[x]->getInstanceTypeName() << endl ! << "\tMetaType = " << parents[x]->getMetaTypeName() << endl; } } --- 392,399 ---- { cout ! << "\tClass = " << parents[x]->getInstanceTypeName() ! << endl ! << "\tMetaType = " << parents[x]->getMetaTypeName() ! << endl; } } *************** *** 348,354 **** for( int x = 0; aMDescs[x] != NULLPTR; ++x ) { ! cout << "\tVar name = " << aMDescs[x]->theTypeVariableName << endl; ! cout << "\tVar type = " << aMDescs[x]->theTypeName << endl; ! cout << "\tVar size = " << aMDescs[x]->theSizeInBytes << endl; if( aMDescs[x]->theGetter != NULLPTR ) { --- 426,447 ---- for( int x = 0; aMDescs[x] != NULLPTR; ++x ) { ! cout << "\tVar name = " << aMDescs[x]->theTypeVariableName ! << endl; ! cout << "\tVar type = " << aMDescs[x]->theTypeName ! << endl; ! cout << "\tVar size = " << aMDescs[x]->theSizeInBytes ! << endl; ! ! if( aMDescs[x]->theTypePointer != NULLPTR ) ! { ! cout << "\tClass type = " ! << aMDescs[x]->theTypePointer->getInstanceTypeName() ! << endl; ! } ! else ! { ! cout << "\tNot a FrameworkEntity" << endl; ! } ! if( aMDescs[x]->theGetter != NULLPTR ) { *************** *** 393,398 **** for( int x = 0; aMDescs[x] != NULLPTR; ++x ) { ! cout << "\tFunction name = " << aMDescs[x]->theClassMethodName << endl ! << "\tFunction address = " << aMDescs[x]->theFunction << endl; } } --- 486,491 ---- for( int x = 0; aMDescs[x] != NULLPTR; ++x ) { ! cout << "\tFunction name = " << ! aMDescs[x]->theClassMethodName << endl; } } |