NxLibDynamic

The purpose of NxLibDynamic is to provide a bundle of all necessary dlsym/GetProcAdress 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 – The error code of the operation. It is set to

    • NxLibOperationSucceeded if NxLib was loaded successfully,

    • NxLibLibraryAlreadyLoaded if nxLibLoadDynamic has been called successfully before, without a subsequent call of nxLibFreeDynamic or

    • NxLibCouldNotLoadLibrary if anything went wrong calling dlopen/LoadLibrary.

  • dllPath – The path to the NxLib to load.

void nxLibLoadDynamic(std::string const &dllPath)

See

nxLibLoadDynamic(NXLIBERR*,NXLIBSTR)

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 – The error code of the operation. Will be set to NxLibOperationSucceeded.

void nxLibFreeDynamic()

See

nxLibFreeDynamic(NXLIBERR*)

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()

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.