24 #define dlopen LoadLibrary
25 #define dlclose FreeLibrary
26 #define dlsym GetProcAddress
38 using namespace YACS::ENGINE;
53 DEBTRACE(
"CppContainer::CppContainer()");
65 DEBTRACE(
"CppContainer::~CppContainer()");
118 LocalLibrary L = _trueCont->loadComponentLibrary(componentName);
123 std::string mesg =
"CppContainer not started";
131 DEBTRACE(
"CppContainer::createComponentInstance");
136 std::string mesg =
"CppContainer not started";
144 DEBTRACE(
"CppContainer::createInternalInstance");
149 std::string mesg =
"CppContainer not started";
174 throw Exception(
"CppContainer::checkCapabilityToDealWith : CppContainer is not able to deal with this type of ComponentInstance.");
207 std::multimap<std::string, CppComponent *>::iterator iI, iJ;
211 iI->second->setContainer(NULL);
219 std::map<std::string, LocalLibrary>::iterator iL;
221 dlclose(iL->second.handle);
254 _instance_map.insert(std::pair<std::string, CppComponent *>(name, C));
264 std::map<std::string, LocalLibrary>::iterator foundL =
_library_map.find(name);
290 transform (s.begin (), s.end (), s.begin (), (int(*)(int))
toupper);
303 std::map<std::string, LocalLibrary >::iterator itLib
315 std::string s = aCompName +
"_ROOT_DIR";
317 const char *
t = getenv(s.c_str());
322 sprefix +=
"/lib/salome";
328 std::string impl_name = std::string (
"lib") + aCompName + std::string(
"Local.dylib");
330 std::string impl_name = std::string (
"lib") + aCompName + std::string(
"Local.so");
333 impl_name = sprefix + std::string(
"/") + impl_name;
335 std::string impl_name = aCompName + std::string(
"Local.dll");
336 impl_name = sprefix + std::string(
"\\") + impl_name;
338 DEBTRACE(
"impl_name = " << impl_name);
342 handle = dlopen( impl_name.c_str() ) ;
345 handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;
350 sError =
"Not available here !";
357 if ((sError = dlerror()) || !handle)
360 std::stringstream msg;
361 msg <<
"Can't load shared library : " << impl_name
362 <<
" (dlopen error : " << sError <<
") at "
363 << __FILE__ <<
":" << __LINE__;
367 void *ihandle, *rhandle, *phandle = NULL, *thandle = NULL;
369 ihandle = dlsym(handle,
"__init");
373 if (sError = dlerror())
377 std::stringstream msg;
378 msg <<
"Library " << impl_name
379 <<
" doesn't contains initialization function (" << sError <<
") at "
380 << __FILE__ <<
":" << __LINE__;
384 rhandle = dlsym(handle,
"__run");
388 if (sError = dlerror())
392 std::stringstream msg;
393 msg <<
"Library " << impl_name
394 <<
" doesn't contains main switch function (" << sError <<
") at "
395 << __FILE__ <<
":" << __LINE__;
399 thandle = dlsym(handle,
"__terminate");
403 if (sError = dlerror())
407 std::stringstream msg;
408 msg <<
"Library " << impl_name
409 <<
" doesn't contains terminate function (" << sError <<
") at "
410 << __FILE__ <<
":" << __LINE__;
413 phandle = dlsym(handle,
"__ping");
424 std::map<std::string, LocalLibrary >::iterator itLib
429 dlclose(itLib->second.handle);