00001
00002
00003 #include "eirods_ms_home.h"
00004 #include "eirods_ms_plugin.h"
00005
00006
00007
00008 #include <iostream>
00009
00010 namespace eirods {
00011
00012
00013
00014 ms_table_entry::ms_table_entry( ) :
00015 action_(""),
00016 numberOfStringArgs_( 0 ),
00017 callAction_( 0 ) {
00018 }
00019
00020 ms_table_entry::ms_table_entry( std::string _s, int _n, ms_func_ptr _fp ) :
00021 action_(_s),
00022 numberOfStringArgs_( _n ),
00023 callAction_( _fp ) {
00024 }
00025
00026 ms_table_entry::ms_table_entry( const ms_table_entry& _rhs ) :
00027 action_( _rhs.action_ ),
00028 numberOfStringArgs_( _rhs.numberOfStringArgs_ ),
00029 callAction_( _rhs.callAction_ ) {
00030 }
00031
00032 ms_table_entry& ms_table_entry::operator=( const ms_table_entry& _rhs ) {
00033 action_ = _rhs.action_;
00034 numberOfStringArgs_ = _rhs.numberOfStringArgs_;
00035 callAction_ = _rhs.callAction_;
00036 return *this;
00037 }
00038
00039 ms_table_entry::~ms_table_entry() {
00040 }
00041
00042 bool ms_table_entry::delay_load( void* _h ) {
00043 if( !_h ) {
00044 return false;
00045 }
00046
00047 callAction_ = reinterpret_cast< ms_func_ptr >( dlsym( _h, action_.c_str() ) );
00048
00049 if( !callAction_ ) {
00050 std::cout << "delay_load :: failed to load msvc function [" << action_ << "]" << std::endl;
00051 return false;
00052 } else {
00053 #ifdef DEBUG
00054 std::cout << "delay_load :: [" << action_ << "]" << std::endl;
00055 #endif
00056 }
00057
00058 return true;
00059 }
00060
00061
00062
00063
00064 bool load_microservice_plugin( ms_table& _table, const std::string _ms ) {
00065
00066 ms_table_entry* entry = dynamic_cast< ms_table_entry* >( load_plugin( _ms, EIRODS_MS_HOME ) );
00067 if( entry ) {
00068 _table[ _ms ] = entry;
00069 return true;
00070 } else {
00071 std::cout << "load_microservice_plugin - Failed to create ms plugin entry." << std::endl;
00072 return false;
00073 }
00074 }
00075
00076 };