Question: how to integrate the Livox-SDK into a OOP structure?. #37
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi. I am trying to integrate the drivers into my own software and I am having some problems.
The use of global objects for the callbacks (i.e.
SetDeviceStateUpdateCallbackSetBroadcastCallbackLidarStartSampling...) is not viable in my case. I have to put all the global objects as non static members of a class. I have seen that some of the callbacks use a void pointer to pass generic data structures to the callbacks, however some of the others don't. I have tried std::bind (which would be perfect for this case) .For instance:
However this is not working either. Partially because SetDeviceStateUpdateCallback expects the type DeviceStateUpdateCallback only to cast it later into a more flexible std::function (just since today)/boost::function).
Do you have any recommendation for this situation?.
Thank you very much.
Hi @lasdasdas ,
Thank you for your proposal !
We will plan to provide C++ interface which make it easier to intergrate into OOP structure.
Hi @Livox-SDK.
I can suggest apart of make a std::function and std::bind for a Interface OOP (I thinks is the best) other method to implement in C++. You can make a Interface by polling data where we need to request the new data from SDK for any handle, only is a idea.
Best Regards.
Hi @fjserrano ,
Thank you for your suggestion ! we will take it into consideration carefully.
It is a good idea. Also, some of the functions have a free void pointer that can be used to pass anything you need (DeviceInformationCallback, SetDataCallback) however others do not ( DeviceStateUpdateCallback...) Maybe @Livox-SDK can explain the reasons for this interface decision. If all callbacks had a void pointer, using classes would be trivial as the class object itself could be passed as
this