From 8f10285773c0b83bbac36984a6cbf307acafee07 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Thu, 26 Apr 2018 10:33:37 +0800 Subject: [PATCH] Add synthetic files --- CMakeLists.txt | 1 + src/api/api.cc | 74 +++++++++++++++++++++++++++++++++++++++++++- src/api/api.h | 34 ++++++++++++++++++++ src/api/synthetic.cc | 17 ++++++++++ src/api/synthetic.h | 22 +++++++++++++ 5 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 src/api/synthetic.cc create mode 100644 src/api/synthetic.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d6e440..0e9ce9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,7 @@ set(MYNTEYE_SRCS if(WITH_API) list(APPEND MYNTEYE_SRCS src/api/api.cc + src/api/synthetic.cc ) endif() diff --git a/src/api/api.cc b/src/api/api.cc index 543bcb4..d6585c1 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -4,11 +4,13 @@ #include "mynteye/utils.h" +#include "api/synthetic.h" #include "device/device.h" MYNTEYE_BEGIN_NAMESPACE -API::API(std::shared_ptr device) : device_(device) { +API::API(std::shared_ptr device) + : device_(device), synthetic_(new Synthetic(this)) { VLOG(2) << __func__; } @@ -24,4 +26,74 @@ std::shared_ptr API::Create(std::shared_ptr device) { return std::make_shared(device); } +Model API::GetModel() const { + return device_->GetModel(); +} + +bool API::Supports(const Stream &stream) const { + return device_->Supports(stream); +} + +bool API::Supports(const Capabilities &capability) const { + return device_->Supports(capability); +} + +bool API::Supports(const Option &option) const { + return device_->Supports(option); +} + +const std::vector &API::GetStreamRequests( + const Capabilities &capability) const { + return device_->GetStreamRequests(capability); +} + +void API::ConfigStreamRequest( + const Capabilities &capability, const StreamRequest &request) { + device_->ConfigStreamRequest(capability, request); +} + +std::string API::GetInfo(const Info &info) const { + return device_->GetInfo(info); +} + +Intrinsics API::GetIntrinsics(const Stream &stream) const { + return device_->GetIntrinsics(stream); +} + +Extrinsics API::GetExtrinsics(const Stream &from, const Stream &to) const { + return device_->GetExtrinsics(from, to); +} + +MotionIntrinsics API::GetMotionIntrinsics() const { + return device_->GetMotionIntrinsics(); +} + +Extrinsics API::GetMotionExtrinsics(const Stream &from) const { + return device_->GetMotionExtrinsics(from); +} + +void API::LogOptionInfos() const { + device_->LogOptionInfos(); +} + +OptionInfo API::GetOptionInfo(const Option &option) const { + return device_->GetOptionInfo(option); +} + +std::int32_t API::GetOptionValue(const Option &option) const { + return device_->GetOptionValue(option); +} + +void API::SetOptionValue(const Option &option, std::int32_t value) { + device_->SetOptionValue(option, value); +} + +bool API::RunOptionAction(const Option &option) const { + return device_->RunOptionAction(option); +} + +std::shared_ptr API::device() { + return device_; +} + MYNTEYE_END_NAMESPACE diff --git a/src/api/api.h b/src/api/api.h index db1c925..7a45f9f 100644 --- a/src/api/api.h +++ b/src/api/api.h @@ -3,12 +3,16 @@ #pragma once #include +#include +#include #include "mynteye/mynteye.h" +#include "mynteye/types.h" MYNTEYE_BEGIN_NAMESPACE class Device; +class Synthetic; class MYNTEYE_API API { public: @@ -18,8 +22,38 @@ class MYNTEYE_API API { static std::shared_ptr Create(); static std::shared_ptr Create(std::shared_ptr device); + Model GetModel() const; + + bool Supports(const Stream &stream) const; + bool Supports(const Capabilities &capability) const; + bool Supports(const Option &option) const; + + const std::vector &GetStreamRequests( + const Capabilities &capability) const; + void ConfigStreamRequest( + const Capabilities &capability, const StreamRequest &request); + + std::string GetInfo(const Info &info) const; + + Intrinsics GetIntrinsics(const Stream &stream) const; + Extrinsics GetExtrinsics(const Stream &from, const Stream &to) const; + MotionIntrinsics GetMotionIntrinsics() const; + Extrinsics GetMotionExtrinsics(const Stream &from) const; + + void LogOptionInfos() const; + OptionInfo GetOptionInfo(const Option &option) const; + + std::int32_t GetOptionValue(const Option &option) const; + void SetOptionValue(const Option &option, std::int32_t value); + + bool RunOptionAction(const Option &option) const; + + std::shared_ptr device(); + private: std::shared_ptr device_; + + std::unique_ptr synthetic_; }; MYNTEYE_END_NAMESPACE diff --git a/src/api/synthetic.cc b/src/api/synthetic.cc new file mode 100644 index 0000000..446d06e --- /dev/null +++ b/src/api/synthetic.cc @@ -0,0 +1,17 @@ +#include "api/synthetic.h" + +#include + +#include "api/api.h" + +MYNTEYE_BEGIN_NAMESPACE + +Synthetic::Synthetic(API *api) : api_(api) { + VLOG(2) << __func__; +} + +Synthetic::~Synthetic() { + VLOG(2) << __func__; +} + +MYNTEYE_END_NAMESPACE diff --git a/src/api/synthetic.h b/src/api/synthetic.h new file mode 100644 index 0000000..6c3a1ae --- /dev/null +++ b/src/api/synthetic.h @@ -0,0 +1,22 @@ +#ifndef MYNTEYE_SYNTHETIC_H_ // NOLINT +#define MYNTEYE_SYNTHETIC_H_ +#pragma once + +#include "mynteye/mynteye.h" + +MYNTEYE_BEGIN_NAMESPACE + +class API; + +class Synthetic { + public: + explicit Synthetic(API *api); + ~Synthetic(); + + private: + API *api_; +}; + +MYNTEYE_END_NAMESPACE + +#endif // MYNTEYE_SYNTHETIC_H_ NOLINT