|
From: Frank V. C. <fr...@us...> - 2000-10-22 16:36:04
|
Update of /cvsroot/corelinux/clfw/src/testdrivers/exf1 In directory slayer.i.sourceforge.net:/tmp/cvs-serv7484/src/testdrivers/exf1 Modified Files: examp1.cpp Log Message: 117408 Abstract type support Index: examp1.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/testdrivers/exf1/examp1.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** examp1.cpp 2000/10/21 16:10:18 1.11 --- examp1.cpp 2000/10/22 14:49:16 1.12 *************** *** 28,32 **** // ! // Common.hpp included before anything else. This is not // required but it makes things consistent. You can also // wrap it with: --- 28,32 ---- // ! // ClfwCommon.hpp included before anything else. This is not // required but it makes things consistent. You can also // wrap it with: *************** *** 45,48 **** --- 45,52 ---- #endif + #if !defined(__BOOLEAN_HPP) + #include <clfw/Boolean.hpp> + #endif + #if !defined(__INTEGER_HPP) #include <clfw/Integer.hpp> *************** *** 70,74 **** int main( void ); ! void dumpMetaType( FrameworkEntityPtr ); void dumpInstanceMembers( MetaTypeCptr ); void dumpParents( MetaTypeCptr ); --- 74,79 ---- int main( void ); ! void dumpMetaTypeInformation( MetaTypeCptr ); ! void dumpTypeInformation( FrameworkEntityPtr ); void dumpInstanceMembers( MetaTypeCptr ); void dumpParents( MetaTypeCptr ); *************** *** 84,87 **** --- 89,94 ---- // + // Getter + template < class T > T getValue( char *name, FrameworkEntityPtr aFE ) { *************** *** 92,99 **** return *pval; } ! template < class T > void setValue( char *name, T value, FrameworkEntityPtr aFE ) { ! aFE->getType()->set(name,(VoidPtr)&value,aFE); } --- 99,113 ---- return *pval; } + + // Setter ! template < class T > void setValue ! ( ! char *name, ! T value, ! FrameworkEntityPtr aFE ! ) { ! (aFE->getType())->set(name,(VoidPtr)&value,aFE); } *************** *** 112,159 **** { // ! // The MetaType pointer is the genesis machine! You don't own it, so ! // don't destroy it. // - - // - // First we play around with the root entity - // - - FrameworkEntityPtr aFrameworkEntity = new FrameworkEntity; ! dumpMetaType( aFrameworkEntity ); // - // Now we sweeten the pot with showing the factory methods, getters, setters // IntegerPtr aInteger = Integer::create(); setValue<Int>("Value",8,aInteger); ! dumpMetaType( aInteger ); ! cout << "Value of aInteger = " << getValue<Int>("Value",aInteger) << endl; ShortIntegerPtr aShort = ShortInteger::create(); setValue<Short>("Value",3,aShort); ! dumpMetaType( aShort ); ! cout << "Value of aInteger = " << getValue<Short>("Value",aShort) << endl; ! ! UnsignedIntegerPtr aUnsigned = new UnsignedInteger; ! setValue<UnsignedInt>("Value",(UnsignedInt) -(aInteger->getValue()),aUnsigned ); ! dumpMetaType( aUnsigned ); ! cout << "Value of aInteger = " << getValue<UnsignedInt>("Value",aUnsigned) << endl; ! ! // ! // Call destroy ! // ! ! Integer::destroy( aInteger ); ShortInteger::destroy( aShort ); ! // ! // Call indirect destroy ! // ! delete aFrameworkEntity; delete aUnsigned; } catch( AssertionRef aAssert ) --- 126,175 ---- { // ! // Becuase the root is abstract, we can't allocate it, ! // but we can reason with it // ! dumpMetaTypeInformation( FrameworkEntity::getTypeDescriptor() ); ! dumpMetaTypeInformation( Number::getTypeDescriptor() ); ! dumpMetaTypeInformation( Boolean::getTypeDescriptor() ); // // + // Now we sweeten the pot with showing the factory methods, + // introspection, getters, setters, and destructors + // + + // 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 ); ! ! // signed Short ShortIntegerPtr aShort = ShortInteger::create(); setValue<Short>("Value",3,aShort); ! dumpTypeInformation( aShort ); ! cout << "Value of aInteger = " ! << getValue<Short>("Value",aShort) << endl; ShortInteger::destroy( aShort ); ! // unsigned Integer ! UnsignedIntegerPtr aUnsigned = new UnsignedInteger; ! setValue<UnsignedInt> ! ( ! "Value", ! (UnsignedInt) -(aInteger->getValue()), ! aUnsigned ! ); ! dumpTypeInformation( aUnsigned ); ! cout << "Value of aInteger = " ! << getValue<UnsignedInt>("Value",aUnsigned) << endl; delete aUnsigned; + } catch( AssertionRef aAssert ) *************** *** 178,188 **** // ! // Dump info on types // ! void dumpMetaType( FrameworkEntityPtr anFEPtr ) { - const MetaTypeCptr aMTPtr( anFEPtr->getType() ); - // // Standard stuff --- 194,202 ---- // ! // Dump info on meta types // ! void dumpMetaTypeInformation( MetaTypeCptr aMTPtr ) { // // Standard stuff *************** *** 195,201 **** cout << endl - << "entity address = " << anFEPtr << endl << "type class version = " << aMTPtr->getTypeVersion() << endl ! << "instance size = " << aMTPtr->getTypeSize() << endl; --- 209,216 ---- cout << endl << "type class version = " << aMTPtr->getTypeVersion() << endl ! << "instance size = " << aMTPtr->getTypeSize() << endl ! << "abstract type = " << ! ( aMTPtr->isAbstractType() ? "true" : "false" ) << endl; *************** *** 211,214 **** --- 226,238 ---- dumpInstanceMembers( aMTPtr ); + + } + // + // Dump info on types + // + + void dumpTypeInformation( FrameworkEntityPtr anFEPtr ) + { + dumpMetaTypeInformation( anFEPtr->getType() ); } |