NxLibDynamic¶
The purpose of NxLibDynamic is to provide a bundle of all necessary dlsym/GetProcAddress calls to make the NxLib interface callable after loading the library at runtime.
The NxLibDynamic.h will be used as a replacement header for NxLib.h to access the NxLib interface. To use it, one has to include it in exactly one translation unit of the target application with the NXLIB_DYNAMIC_IMPLEMENTATION preprocessor definition set.
Usage¶
Including the implemention into a unique translation unit:
#define NXLIB_DYNAMIC_IMPLEMENTATION
#include "nxLibDynamic.h"
#undef NXLIB_DYNAMIC_IMPLEMENTATION
Exemplary usage:
#include "nxLibDynamic.h"
void some_function()
{
int result;
nxLibLoadDynamic(&result, "/path/to/NxLib.(dll/so)");
if (result != NxLibOperationSucceeded)
{
// error handling
}
nxLibInitialize(&result, false);
if (result != NxLibOperationSucceeded)
{
// error handling
}
// do stuff ...
// e.g. nxLibGetString(&error, "/Cameras/BySerialNo/\\0/Type");
nxLibFinalize(&result);
if (result != NxLibOperationSucceeded)
{
// error handling
}
nxLibFinalize(&result);
if (result != NxLibOperationSucceeded)
{
// error handling
}
nxLibFreeDynamic(&result)
if (result != NxLibOperationSucceeded)
{
// error handling
}
}
nxLibLoadDynamic¶
-
void nxLibLoadDynamic(NXLIBERR *result, NXLIBSTR dllPath)¶
Loads the NxLib located at dllPath via the Dynamic Link Loader methods dlopen (under Unix) or LoadLibrary (under Windows) and tries to resolve each NxLib and NxLibRemote API function handle.
Calling an API function loaded by nxLibLoadDynamic may result in an
NxLibCouldNotLoadFunction
error code if it could not be resolved, otherwise a standard API call will be executed.- Parameters
result – A pointer to a variable for the return code of the operation. The following return codes can occur:
NxLibOperationSucceeded
- The operation completed successfully. No error occurred.NxLibInvalidParameters
- One, multiple, or a combination of parameters are invalid.NxLibLibraryAlreadyLoaded
- The function has been called successfully before, without a subsequent call ofnxLibFreeDynamic()
.NxLibCouldNotLoadLibrary
- Something went wrong during loading NxLibDynamic.
dllPath – The path to the NxLib to load.
-
void nxLibLoadDynamic(std::string const &dllPath)¶
-
Note
C++ only This function is an overload accessible only in C++. Instead of returning the result code as an output parameter like its C counterpart, it throws an NxLibException in case of an error.
nxLibFreeDynamic¶
-
void nxLibFreeDynamic(NXLIBERR *result)¶
Unmap and close the NxLib loaded with nxLibLoadDynamic().
All subsequent API calls set error code to
NxLibCouldNotLoadFunction
in their result argument until an NxLib is loaded again.Note
Make sure you call nxLibFinalize() first.
- Parameters
result – A pointer to a variable for the return code of the operation. The following return codes can occur:
NxLibOperationSucceeded
- The operation completed successfully. No error occurred.
-
void nxLibFreeDynamic()¶
-
Note
C++ only This function is an overload accessible only in C++. Instead of returning the result code as an output parameter like its C counterpart, it throws an NxLibException in case of an error.
nxLibIsRemoteLoaded¶
-
NXLIBBOOL nxLibIsRemoteLoaded(void)¶
Indicates if the loaded NxLib is a remote NxLib and implements the Remote interface.
- Returns
NXLIBTRUE if the loaded NxLib is a remote lib, NXLIBFALSE otherwise.