|
From: Frank V. C. <fr...@us...> - 2000-11-21 16:26:07
|
Update of /cvsroot/corelinux/clfll/src/testdrivers/exfl1 In directory slayer.i.sourceforge.net:/tmp/cvs-serv5190/src/testdrivers/exfl1 Modified Files: Makefile.am examp1.cpp Added Files: OutputPlugIn.cpp mylib.c walker.cpp Log Message: 112702 FunctionLibraryLoad ***** Error reading new file: (2, 'No such file or directory') --- NEW FILE --- /* CoreLinux++ Copyright (C) 1999 CoreLinux Consortium The CoreLinux++ Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The CoreLinux++ Library Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** Dummy routine for showing off the FunctionLoadLibrary implementation */ extern "C" { #include <stdio.h> } void pushOut( char *aString ) { printf("%s\n", aString); } ***** Error reading new file: (2, 'No such file or directory') Index: Makefile.am =================================================================== RCS file: /cvsroot/corelinux/clfll/src/testdrivers/exfl1/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Makefile.am 2000/11/18 20:10:11 1.1 --- Makefile.am 2000/11/21 16:26:04 1.2 *************** *** 12,21 **** SUFFIXES = .cpp .hpp .c .h .f .F .o .moc ! #SUBDIRS = include bin_PROGRAMS = exfl1 ! exfl1_SOURCES = examp1.cpp exfl1_LDADD = ${top_builddir}/src/clfll/libclfll++.la # Common rcs information do not modify --- 12,26 ---- SUFFIXES = .cpp .hpp .c .h .f .F .o .moc ! SUBDIRS = include bin_PROGRAMS = exfl1 ! exfl1_SOURCES = examp1.cpp walker.cpp OutputPlugIn.cpp ! exfl1_LDADD = ${top_builddir}/src/clfll/libclfll++.la + + lib_LTLIBRARIES = libmylib.la + libmylib_la_SOURCES = mylib.c + libmylib_la_LDFLAGS = -version-info 0:0:0 # Common rcs information do not modify Index: examp1.cpp =================================================================== RCS file: /cvsroot/corelinux/clfll/src/testdrivers/exfl1/examp1.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** examp1.cpp 2000/11/20 05:26:35 1.3 --- examp1.cpp 2000/11/21 16:26:04 1.4 *************** *** 22,34 **** This example is to show use of the FunctionLoader library ! */ // ! // ClfwCommon.hpp included before anything else. This is not // required but it makes things consistent. You can also // wrap it with: // ! // #if !defined(_CLFWCOMMON_HPP) ! // #include <ClfwCommon.hpp> // #endif // --- 22,36 ---- This example is to show use of the FunctionLoader library ! We supply a number of shared libraries to allow the user to ! experience a "plug-in" capability defined in some way ! */ // ! // ClfllCommon.hpp included before anything else. This is not // required but it makes things consistent. You can also // wrap it with: // ! // #if !defined(_CLFLLCOMMON_HPP) ! // #include <ClfllCommon.hpp> // #endif // *************** *** 46,59 **** #endif ! #if !defined(__METACLASS_HPP) ! #include <clfw/MetaClass.hpp> #endif ! #if !defined(__ONTOLOGY_HPP) ! #include <clfw/Ontology.hpp> #endif ! #include INCL_Library ! #include INCL_LibraryInstance using namespace corelinux; --- 48,62 ---- #endif ! #if !defined(__LIBRARY_HPP) ! #include INCL_Library #endif ! #if !defined(__LIBRARYINSTANCE_HPP) ! #include INCL_LibraryInstance #endif ! #if !defined(__OUTPUTPLUGIN_HPP) ! #include <OutputPlugIn.hpp> ! #endif using namespace corelinux; *************** *** 63,90 **** #include <exception> - - // - // In module function prototypes - // - - int main( void ); - - // - // MetaType information dump - // - - void dumpFundementals( void ); - void dumpMetaTypeInformation( MetaTypePtr ); - void dumpTypeInformation( FrameworkEntityPtr ); - - void walkOntology( MetaClassPtr , int ); - void dumpOntology( void ); - - // - // Assertion and Exception handlers - // - void handleAssertion( AssertionCref aAssert ); - void handleException( ExceptionCref ); - // // Templated function --- 66,69 ---- *************** *** 118,239 **** } - // MetaType or MetaClass parents - - template < class T > void dumpParents( T *aMPtr ) - { - cout << endl << "Meta Parent List : " << endl; - - if( aMPtr->getParentCount() != 0 ) - { - Iterator<T *> *aIterator(aMPtr->createParentIterator()); - - while( aIterator->isValid() ) - { - cout - << "\tClass = " << - aIterator->getElement()->getInstanceTypeName() << endl - << "\tMetaType = " - << aIterator->getElement()->getMetaTypeName() << endl; - aIterator->setNext(); - } - - aMPtr->destroyIterator( aIterator ); - } - else - { - ; // do nothing - } - } - // ! // MetaType or MetaClass Attribute Control Blocks // ! template < class T > void dumpInstanceMembers( T *aMPtr ) ! { ! if( aMPtr->getInstanceMemberCount() != 0 ) ! { ! Iterator<MemberDescriptorPtr> *aIterator ! ( ! aMPtr->createMemberIterator() ! ); ! ! while( aIterator->isValid() ) ! { ! MemberDescriptorCptr anElement( aIterator->getElement() ); ! ! cout << "\tVar name = " << anElement->theTypeVariableName ! << endl; ! cout << "\tVar type = " << anElement->theTypeName ! << endl; ! cout << "\tVar size = " << anElement->theSizeInBytes ! << endl; ! ! if( anElement->theTypePointer != NULLPTR ) ! { ! cout << "\tClass type = " ! << anElement->theTypePointer->getInstanceTypeName() ! << endl; ! } ! else ! { ! cout << "\tNot a FrameworkEntity" << endl; ! } ! ! if( anElement->theGetter != NULLPTR ) ! { ! cout << "\tHas getter " << endl; ! } ! else ! { ! ; // do nothing ! } ! if( anElement->theSetter != NULLPTR ) ! { ! cout << "\tHas setter " << endl; ! } ! else ! { ! ; // do nothing ! } ! aIterator->setNext(); ! } ! ! aMPtr->destroyIterator( aIterator ); ! } ! else ! { ! ; // do nothing ! } ! } // ! // MetaType or MetaClass Dispatch Control Blocks // ! template < class T > void dumpInstanceFunctions( T *aMPtr ) ! { ! if( aMPtr->getInstanceFunctionCount() != 0 ) ! { ! Iterator<DispatchDescriptorPtr> *aIterator ! ( ! aMPtr->createMethodIterator() ! ); ! ! while( aIterator->isValid() ) ! { ! cout << "\tFunction name = " << ! aIterator->getElement()->theClassMethodName << endl; ! aIterator->setNext(); ! } ! aMPtr->destroyIterator( aIterator ); ! } ! else ! { ! ; // do nothing ! } ! } --- 97,120 ---- } // ! // In module function prototypes // ! int main( void ); ! void executePlugIn( LibraryInstancePtr ); // ! // MetaType information dump functions in walker.cpp // ! void dumpTypeInformation( FrameworkEntityPtr ); ! void dumpOntology( void ); ! // ! // Assertion and Exception handlers ! // ! void handleAssertion( AssertionCref aAssert ); ! void handleException( ExceptionCref ); *************** *** 251,260 **** try { ! MetaSpace::initialize(); ! dumpOntology(); ! Library aLibrary; ! LibraryInstancePtr aLibInst = aLibrary.load( "libm.so" ); if( aLibInst == NULLPTR ) --- 132,157 ---- try { ! // ! // ALWAYS initialize the MetaSpace ontologies !!! ! // ! ! MetaSpace::initialize(); ! Library aLibrary; // Standard issue library ! ! // ! // The library resolves loaders based on what is registered and can ! // handle the type specified in the argument. The FunctionLoader ! // checks for ".so" extensions ! // ! ! LibraryInstancePtr aLibInst ! ( ! aLibrary.load( "./.libs/libmylib.so" ) ! ); ! // ! // Begin the test ! // if( aLibInst == NULLPTR ) *************** *** 264,270 **** else { ! cout << "Library " << aLibInst->getLibraryName() << " loaded" << endl; } } catch( AssertionRef aAssert ) --- 161,168 ---- else { ! executePlugIn( aLibInst ); } + // dumpOntology(); } catch( AssertionRef aAssert ) *************** *** 288,408 **** } ! ! void walkOntology( MetaClassPtr aMetaClass, int indent ) { - for( int x = 0; x != indent ; ++x ) - { - cout << "\t"; - } - - cout << aMetaClass->getMetaTypeName() << " (" - << aMetaClass->getDomainName() << ")" << endl; ! Iterator<MetaClassPtr> *aIterator( aMetaClass->createIterator()); ! ! while( aIterator->isValid() == true ) ! { ! walkOntology( aIterator->getElement(), indent+1 ); ! aIterator->setNext(); ! } ! aMetaClass->destroyIterator( aIterator ); ! } - void dumpOntology( void ) - { // ! // We start by resolving the root of roots :) // ! cout << endl; ! Ontology *aOntology( MetaSpace::getOntology("corelinux") ); ! ! if( aOntology != NULLPTR ) { ! cout << "Dumping ontology " << aOntology->getDomainName() << endl; ! Iterator<MetaClassCptr> *aIterator( aOntology->createRootIterator()); ! while( aIterator->isValid() == true ) ! { ! walkOntology( (MetaClassPtr)aIterator->getElement(),0 ); ! aIterator->setNext(); ! } ! aOntology->destroyIterator( aIterator ); ! } ! else ! { ! throw NullPointerException( LOCATION ); ! } ! } ! // ! // Dump info on meta types ! // ! void dumpMetaTypeInformation( MetaTypePtr aMTPtr ) ! { ! // ! // Standard stuff ! // ! cout << endl ! << "Analyzing class [" << aMTPtr->getInstanceTypeName() ! << "] MetaType [" << aMTPtr->getMetaTypeName() << "]" << endl ! << "Namespace = " << aMTPtr->getDomainName() << endl ! << "Description = " << aMTPtr->getTypeDescription() << ! endl; ! cout << endl ! << "type class version = " << aMTPtr->getTypeVersion() << endl ! << "instance size = " << aMTPtr->getTypeSize() << endl ! << "abstract type = " << ! ( aMTPtr->isAbstractType() ? "true" : "false" ) << ! endl; ! if( aMTPtr->isAbstractType() == false ) ! { ! AllocatorPtr aAPtr( aMTPtr->getAllocator() ); ! cout ! << "number allocs = " << aAPtr->getAllocateCount() ! << endl ! << "number deallocs = " << aAPtr->getDeallocateCount() ! << endl; } else { ! ; // do nothing } - - // - // Parent Dump - // - - dumpParents<MetaType>( aMTPtr ); - - // - // Data Member dump - // - - dumpInstanceMembers<MetaType>( aMTPtr ); - - // - // Dump dispatch table - // - - dumpInstanceFunctions<MetaType>( aMTPtr ); - } - // - // Dump info on types - // - - void dumpTypeInformation( FrameworkEntityPtr anFEPtr ) - { - dumpMetaTypeInformation( anFEPtr->getType() ); - } // --- 186,263 ---- } ! void executePlugIn( LibraryInstancePtr aLibInst ) { ! cout << endl ! << aLibInst->getLibraryName() ! << " loaded" ! << endl; // ! // Invoke the instance to get the object from the object registry // ! LibraryObjectPtr aObj( aLibInst->getObject("OutputPlugIn") ); ! if( aObj != NULLPTR ) { ! cout << endl ! << "Function object loaded, we can now execute the plugin:" ! << endl << endl; ! // ! // Here is an easy way when you know the object type, of course ! // we could have made a simple interface execute( char * ) which ! // set the output and called the plug-in, but hey ! // ! OutputPlugInPtr myType( OutputPlugIn::castDown( aObj ) ); + cout << "executing :" << endl; + myType->setOutputString("When the type is known"); + myType->execute(); + cout << endl; ! // ! // Here is another way to do things, when you know the type and ! // the attributes to be used in the execute ! // ! cout << "executing :" << endl; ! setValue<CharPtr> ! ( ! "OutputString", ! "With output string set prior to execute", ! aObj ! ); ! myType->execute(); ! cout << endl; ! // ! // And here is the output assuming you have done the ! // reasoning with the attributes of the MetaClass (grin) ! // ! cout << "executing :" << endl; ! aObj->getType()->dispatch ! ( ! aObj, ! "execute", ! (void **)"When there is not much known about the type", ! (void *)NULLPTR ! ); ! cout << endl; ! ! // dumpTypeInformation( aObj ); ! aLibInst->returnObject( aObj ); ! cout << endl; } else { ! cout << "Can't resolve object" << endl; } } // |