Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65967816
BackendLoader.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jun 7, 10:04
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Jun 9, 10:04 (2 d)
Engine
blob
Format
Raw Data
Handle
18152762
Attached To
R6622 liboncilla
BackendLoader.cpp
View Options
/**
* \file BackendLoader.cpp
*
* \date Jun 21, 2012
* \author Alexandre Tuleu
*/
#include "BackendLoader.h"
#include <liboncilla/exceptions/LoadingError.h>
#include <biorob-cpp/os/Env.h>
namespace rci {
namespace oncilla {
const char * BackendLoader::FORCE_MODULE_ENV_NAME = "LIBONCILLA_FORCE_BACKEND";
BackendLoader::BackendLoader(){
typedef PluginLoader<OncillaBackend> PL;
d_loader.SetHint((PL::LoadingHint) (PL::IsCMakeModuleObject | PL::ResolveAllSymbols));
if(os::Env::IsSet(FORCE_MODULE_ENV_NAME)){
d_loader.SetFilename(os::Env::Get(FORCE_MODULE_ENV_NAME));
} else {
//adds the different variants. first try to open simulation backend, if not
//found, will try to open HW backend ...
//if not found will fire a std::runtime_error
//library predix and suffix are determined from platform bx biorob-cpp/PluginLoader
d_loader.AppendVariant("oncilla-webots");
d_loader.AppendVariant("oncilla-hw");
// backend should be compiled using the cross-platform MODULE target of CMake
// and to avoid unexpected jitter, we resolve all symbols at opening.
}
}
BackendLoader::~BackendLoader(){}
const OncillaBackend::Ptr & BackendLoader::SuitableBackend(){
if(d_loadedBackend){
return d_loadedBackend;
}
try{
//try to loads backend from constructor order
d_loadedBackend = d_loader.LoadPlugin();
} catch (const std::runtime_error & e) {
//PluginLoader fire a std::runtime error with all the
//dlopen / dlsym error messages, we propagate this error with a nice
//specific wrapper arround std::runtime_error (could be useful
// for higher level to recover from that error)
throw LoadingError(e.what());
}
return d_loadedBackend;
}
} /* namespace oncilla */
} /* namespace rci */
Event Timeline
Log In to Comment