Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use aliases to hide pointer details #3949

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions io/include/pcl/io/real_sense/real_sense_device_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ namespace pcl

class PCL_EXPORTS RealSenseDeviceManager : boost::noncopyable
{

public:
using Ptr = pcl::shared_ptr<RealSenseDeviceManager>;

using Ptr = std::shared_ptr<RealSenseDeviceManager>;

static Ptr&
static RealSenseDeviceManagerPtr&
getInstance ()
{
static Ptr instance;
static RealSenseDeviceManagerPtr instance;
if (!instance)
{
std::lock_guard<std::mutex> lock (mutex_);
Expand All @@ -90,18 +88,20 @@ namespace pcl
return (device_list_.size ());
}

std::shared_ptr<RealSenseDevice>
RealSenseDevicePtr
captureDevice ();

std::shared_ptr<RealSenseDevice>
RealSenseDevicePtr
captureDevice (std::size_t index);

std::shared_ptr<RealSenseDevice>
RealSenseDevicePtr
captureDevice (const std::string& sn);

~RealSenseDeviceManager ();

private:
using PXCSessionPtr = pcl::shared_ptr<PXCSession>;
using PXCCaptureManagerPtr = pcl::shared_ptr<PXCCaptureManager>;

struct DeviceInfo
{
Expand All @@ -113,7 +113,7 @@ namespace pcl
};

/** If the device is already captured returns a pointer. */
std::shared_ptr<RealSenseDevice>
RealSenseDevicePtr
capture (DeviceInfo& device_info);

RealSenseDeviceManager ();
Expand All @@ -123,18 +123,17 @@ namespace pcl
void
populateDeviceList ();

std::shared_ptr<PXCSession> session_;
std::shared_ptr<PXCCaptureManager> capture_manager_;
PXCSessionPtr session_;
PXCCaptureManagerPtr capture_manager_;

std::vector<DeviceInfo> device_list_;

static std::mutex mutex_;

};


class PCL_EXPORTS RealSenseDevice : boost::noncopyable
{

public:
using Ptr = pcl::shared_ptr<RealSenseDevice>;

Expand All @@ -146,27 +145,29 @@ namespace pcl

/** Reset the state of given device by releasing and capturing again. */
static void
reset (RealSenseDevice::Ptr& device)
reset (RealSenseDevicePtr& device)
{
std::string id = device->getSerialNumber ();
device.reset ();
device = RealSenseDeviceManager::getInstance ()->captureDevice (id);
}

private:
using PXCCapturePtr = pcl::shared_ptr<PXCCapture>;
using PXCCaptureDevicePtr = pcl::shared_ptr<PXCCapture::Device>;

friend class RealSenseDeviceManager;

std::string device_id_;
std::shared_ptr<PXCCapture> capture_;
std::shared_ptr<PXCCapture::Device> device_;
PXCCapturePtr capture_;
PXCCaptureDevicePtr device_;

RealSenseDevice (const std::string& id) : device_id_ (id) { };

};

} // namespace real_sense

} // namespace io

} // namespace pcl