X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=ModuleCall%2FGenSrc%2FbbSlicerCommandLineModuleTest.cxx;fp=ModuleCall%2FGenSrc%2FbbSlicerCommandLineModuleTest.cxx;h=4b63cfb3ef2942bf5a4a019ec8cb8778dab9c112;hb=e7b4e2c9254e9e431f74acc92e3f0d40fc5e7ef6;hp=0000000000000000000000000000000000000000;hpb=cd590ce5fff20d69c7060340235a35e9c2a9ef86;p=creaCLI.git diff --git a/ModuleCall/GenSrc/bbSlicerCommandLineModuleTest.cxx b/ModuleCall/GenSrc/bbSlicerCommandLineModuleTest.cxx new file mode 100644 index 0000000..4b63cfb --- /dev/null +++ b/ModuleCall/GenSrc/bbSlicerCommandLineModuleTest.cxx @@ -0,0 +1,58 @@ +#include "bbSlicerCommandLineModuleTest.h" +#include "bbSlicerPackage.h" + +namespace bbSlicer { + BBTK_ADD_BLACK_BOX_TO_PACKAGE ( Slicer, CommandLineModuleTest ) + BBTK_BLACK_BOX_IMPLEMENTATION ( CommandLineModuleTest, bbtk::AtomicBlackBox ); + + void CommandLineModuleTest::Process ( ) { + + // GENERATED + +int _argc =4; +std::string lib = "/home/riveros/.slicer/Slicer4-bin/Slicer-build/lib/Slicer-4.0/cli-modules/libCLIModule4TestLib.so"; +char * _argv[ ] = { Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--inputvalue1" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputInputValue1( ) ) ) ,"@@@@@"," --inputvalue1 ") ), +Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--inputvalue2" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputInputValue2( ) ) ) ,"@@@@@"," --inputvalue2 ") ), +Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--operationtype" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputOperationType( ) ) ) ,"@@@@@"," --operationtype ") ), +Mthd::Aux::toCharArrray( Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputOutputFile( ) ) ) ,"@@@@@","") ) }; + + // EO GENERATED + this->execute( lib, _argc, _argv ); + + } + + void CommandLineModuleTest::execute ( std::string lib, int _argc, char * _argv[] ) { + void* handle = dlopen( lib.c_str( ), RTLD_NOW | RTLD_GLOBAL ); + if ( ! handle ) { + std::cerr << "CAN'T OPEN LIBRARY: " << dlerror( ) << '\n'; + return; + } + typedef int (*method_t )( int argc, char * argv[] ); + // RESET ERROR + dlerror( ); + // PROTOTYPE + method_t myMethod = ( method_t ) dlsym( handle, "ModuleEntryPoint" ); + const char *dlsym_error = dlerror( ); + if ( dlsym_error ) { + std::cerr << "CAN'T LOAD SYMBOL 'ModuleEntryPoint':" << dlsym_error << '\n'; + dlclose( handle ); + return; + } + // METHOD CALL + myMethod( _argc, _argv ); + // CLOSING LIB + dlclose( handle ); + } + + void CommandLineModuleTest::bbUserSetDefaultValues ( ) { + } + + void CommandLineModuleTest::bbUserInitializeProcessing ( ) { + } + + void CommandLineModuleTest::bbUserFinalizeProcessing ( ) { + } +} +// EO namespace bbSlicer + +