JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/Core/DynamicLoader.H>
Class to open shared object (.so) files and load functions contained in them.
This class allows one to open a shared library (.so file) and to invoke functions or classes that are in that library.
Engine uses DynamicLoader to load the appropriate vision processing Module each time the user selects a new VideoMapping (i.e., changes image resolution in a USB webcam program running on a host computer, or invokes the setmapping
command over Serial port).
This class is modified from DynamicLoader in the Neuromorphic Robotics Toolkit (NRT).
Definition at line 69 of file DynamicLoader.H.
Public Member Functions | |
DynamicLoader (std::string const &filename, bool closeOnDestroy) | |
Open the shared object located at filename, throws if fail. | |
std::string const & | sopath () const |
Retrieve the path to the .so file of this loader, useful to avoid closing and re-loading the same .so file. | |
~DynamicLoader () | |
Destructor, may close the object on destroy (see constructor arguments) | |
void | close () |
Close the shared object file. | |
template<class Signature > | |
std::function< Signature > | load (std::string const &functionName) |
Load the symbol named functionName. | |
jevois::DynamicLoader::DynamicLoader | ( | std::string const & | filename, |
bool | closeOnDestroy | ||
) |
Open the shared object located at filename, throws if fail.
If closeOnDestroy is true, the .so file will be closed when the DynamicLoader object is destroyed. If you want to maintain access to the functions and classes in a .so file after the loader has run out of scope, set closeOnDestroy to false (and you will then have no way of ever unloading that .so file until termination of your program).
jevois::DynamicLoader::~DynamicLoader | ( | ) |
Destructor, may close the object on destroy (see constructor arguments)
void jevois::DynamicLoader::close | ( | ) |
Close the shared object file.
Beware that closing the object file will remove all links to any objects/functions/etc that have been created from the shared object. Use this function only if you want nothing more to do with anything created from this object file.
std::function< Signature > jevois::DynamicLoader::load | ( | std::string const & | functionName | ) |
Load the symbol named functionName.
This method returns an std::function that points to the requested name in the shared object opened by this DynamicLoader. For example, to load the function int foo(double x, bool y)
from the file "mySharedObject.so" you should write:
You should not try to use anything returned by load() after the DynamicLoader has been close()'d (or destroyed, see constructor arguments).
Throws if the requested symbol could not be found in the opened shared object.
std::string const & jevois::DynamicLoader::sopath | ( | ) | const |
Retrieve the path to the .so file of this loader, useful to avoid closing and re-loading the same .so file.