Public Member Functions | Private Member Functions | Private Attributes | List of all members
librealsense::device_hub Class Reference

#include <device_hub.h>

Public Member Functions

 device_hub (std::shared_ptr< librealsense::context > ctx, int mask=RS2_PRODUCT_LINE_ANY, int vid=0, bool register_device_notifications=true)
 
std::shared_ptr< librealsense::contextget_context ()
 
bool is_connected (const device_interface &dev)
 
std::shared_ptr< device_interfacewait_for_device (const std::chrono::milliseconds &timeout=std::chrono::milliseconds(std::chrono::hours(1)), bool loop_through_devices=true, const std::string &serial="")
 
 ~device_hub ()
 

Private Member Functions

std::shared_ptr< device_interfacecreate_device (const std::string &serial, bool cycle_devices=true)
 

Private Attributes

int _camera_index = 0
 
std::shared_ptr< librealsense::context_ctx
 
std::condition_variable _cv
 
uint64_t _device_changes_callback_id
 
std::vector< std::shared_ptr< device_info > > _device_list
 
std::mutex _mutex
 
bool _register_device_notifications
 
int _vid = 0
 

Detailed Description

device_hub class - encapsulate the handling of connect and disconnect events

Definition at line 15 of file device_hub.h.

Constructor & Destructor Documentation

librealsense::device_hub::device_hub ( std::shared_ptr< librealsense::context ctx,
int  mask = RS2_PRODUCT_LINE_ANY,
int  vid = 0,
bool  register_device_notifications = true 
)
explicit

Definition at line 43 of file device_hub.cpp.

librealsense::device_hub::~device_hub ( )

Definition at line 68 of file device_hub.cpp.

Member Function Documentation

std::shared_ptr< device_interface > librealsense::device_hub::create_device ( const std::string serial,
bool  cycle_devices = true 
)
private

Definition at line 76 of file device_hub.cpp.

std::shared_ptr< librealsense::context > librealsense::device_hub::get_context ( )

Definition at line 159 of file device_hub.cpp.

bool librealsense::device_hub::is_connected ( const device_interface dev)

Checks if device is still connected

Definition at line 153 of file device_hub.cpp.

std::shared_ptr< device_interface > librealsense::device_hub::wait_for_device ( const std::chrono::milliseconds &  timeout = std::chrono::milliseconds(std::chrono::hours(1)),
bool  loop_through_devices = true,
const std::string serial = "" 
)

The function implements both blocking and non-blocking device generation functionality based on the input parameters: Calling the function with zero timeout results in searching and fetching the device specified by the serial parameter from a list of connected devices. Calling the function with a valid timeout will block till the resulted device is found or the timeout expires.

Parameters
[in]timeout_msThe waiting period for the requested device to be reconnected (milliseconds). Due to an implementation issue both in MSVC and GCC the timeout equals to 1 hour to avoid generation of negative durations. .
[in]loop_through_devices- promote internal index to the next available device that will be retrieved on successive call Note that selection of the next device is deterministic but not predictable, and therefore is recommended for specific use-cases only , such as tutorials or unit-tests where no assumptions as to the device ordering are made.
[in]serialThe serial number of the requested device. Use empty pattern ("") to request for "any RealSense" device.
Returns
a shared pointer to the device_interface that satisfies the search criteria. In case the request was not resloved the call will throw an exception

If any device is connected return it, otherwise wait until next RealSense device connects. Calling this method multiple times will cycle through connected devices

Definition at line 120 of file device_hub.cpp.

Member Data Documentation

int librealsense::device_hub::_camera_index = 0
private

Definition at line 54 of file device_hub.h.

std::shared_ptr<librealsense::context> librealsense::device_hub::_ctx
private

Definition at line 50 of file device_hub.h.

std::condition_variable librealsense::device_hub::_cv
private

Definition at line 52 of file device_hub.h.

uint64_t librealsense::device_hub::_device_changes_callback_id
private

Definition at line 56 of file device_hub.h.

std::vector<std::shared_ptr<device_info> > librealsense::device_hub::_device_list
private

Definition at line 53 of file device_hub.h.

std::mutex librealsense::device_hub::_mutex
private

Definition at line 51 of file device_hub.h.

bool librealsense::device_hub::_register_device_notifications
private

Definition at line 57 of file device_hub.h.

int librealsense::device_hub::_vid = 0
private

Definition at line 55 of file device_hub.h.


The documentation for this class was generated from the following files:


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:37