From c30c86e62f88e6d58e2a3c08621eab0e02e9648e Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sun, 7 Jun 2020 10:40:07 +0300
Subject: [PATCH] Move and rename source files

---
 .../rgbd-sources/include/ftl/rgbd/camera.hpp       |  8 ++++++++
 .../rgbd-sources/include/ftl/rgbd/source.hpp       | 14 ++++++--------
 .../rgbd/detail/source.hpp => src/basesource.hpp}  |  9 ---------
 components/rgbd-sources/src/source.cpp             | 10 ++++++++++
 .../rgbd-sources/src/sources/image/image.hpp       |  2 ++
 .../src/sources/middlebury/middlebury_source.hpp   |  2 +-
 .../rgbd-sources/src/sources/pylon/pylon.hpp       |  2 +-
 .../src/sources/realsense/realsense_source.hpp     |  2 +-
 .../src/sources/screencapture/screencapture.hpp    |  2 +-
 .../src/sources/stereovideo/stereovideo.hpp        |  2 +-
 components/rgbd-sources/test/source_unit.cpp       |  1 +
 11 files changed, 32 insertions(+), 22 deletions(-)
 rename components/rgbd-sources/{include/ftl/rgbd/detail/source.hpp => src/basesource.hpp} (73%)

diff --git a/components/rgbd-sources/include/ftl/rgbd/camera.hpp b/components/rgbd-sources/include/ftl/rgbd/camera.hpp
index edcff30bd..804a0c2d3 100644
--- a/components/rgbd-sources/include/ftl/rgbd/camera.hpp
+++ b/components/rgbd-sources/include/ftl/rgbd/camera.hpp
@@ -20,6 +20,14 @@ enum class Projection {
 	EQUIRECTANGULAR = 2
 };
 
+typedef unsigned int capability_t;
+
+static const capability_t kCapMovable	= 0x0001;	// A movable virtual cam
+static const capability_t kCapVideo		= 0x0002;	// Is a video feed
+static const capability_t kCapActive	= 0x0004;	// An active depth sensor
+static const capability_t kCapStereo	= 0x0008;	// Has right RGB
+static const capability_t kCapDepth		= 0x0010;	// Has depth capabilities
+
 /**
  * All properties associated with cameras. This structure is designed to
  * operate on CPU and GPU.
diff --git a/components/rgbd-sources/include/ftl/rgbd/source.hpp b/components/rgbd-sources/include/ftl/rgbd/source.hpp
index b0bec3cf1..868e1a9a0 100644
--- a/components/rgbd-sources/include/ftl/rgbd/source.hpp
+++ b/components/rgbd-sources/include/ftl/rgbd/source.hpp
@@ -7,8 +7,6 @@
 #include <ftl/net/universe.hpp>
 #include <ftl/uri.hpp>
 #include <ftl/rgbd/camera.hpp>
-#include <ftl/rgbd/detail/source.hpp>
-#include <ftl/codecs/packet.hpp>
 #include <opencv2/core/mat.hpp>
 #include <Eigen/Eigen>
 #include <string>
@@ -25,6 +23,9 @@ class Universe;
 
 namespace rgbd {
 
+class BaseSourceImpl;
+typedef std::function<void(int64_t,ftl::rgbd::Frame&)> FrameCallback;
+
 static inline bool isValidDepth(float d) { return (d > 0.01f) && (d < 39.99f); }
 
 /**
@@ -58,7 +59,7 @@ class Source : public ftl::Configurable {
 	/**
 	 * Is this source valid and ready to grab?.
 	 */
-	bool isReady() { return (impl_) ? impl_->isReady() : false; }
+	bool isReady();
 
 	/**
 	 * Change the second channel source.
@@ -105,10 +106,7 @@ class Source : public ftl::Configurable {
 	/**
 	 * Get the source's camera intrinsics.
 	 */
-	const Camera &parameters() const {
-		if (impl_) return impl_->params_;
-		else throw FTL_Error("Cannot get parameters for bad source");
-	}
+	const Camera &parameters() const;
 
 	/**
 	 * Get camera intrinsics for another channel. For example the right camera
@@ -141,7 +139,7 @@ class Source : public ftl::Configurable {
 
 	std::string getURI() { return value("uri", std::string("")); }
 
-	ftl::rgbd::FrameState &state() { return impl_->state_; }
+	ftl::rgbd::FrameState &state();
 
 	SHARED_MUTEX &mutex() { return mutex_; }
 
diff --git a/components/rgbd-sources/include/ftl/rgbd/detail/source.hpp b/components/rgbd-sources/src/basesource.hpp
similarity index 73%
rename from components/rgbd-sources/include/ftl/rgbd/detail/source.hpp
rename to components/rgbd-sources/src/basesource.hpp
index dc910068b..80cda5be6 100644
--- a/components/rgbd-sources/include/ftl/rgbd/detail/source.hpp
+++ b/components/rgbd-sources/src/basesource.hpp
@@ -11,15 +11,6 @@ namespace ftl{
 namespace rgbd {
 
 class Source;
-typedef std::function<void(int64_t,ftl::rgbd::Frame&)> FrameCallback;
-
-typedef unsigned int capability_t;
-
-static const capability_t kCapMovable	= 0x0001;	// A movable virtual cam
-static const capability_t kCapVideo		= 0x0002;	// Is a video feed
-static const capability_t kCapActive	= 0x0004;	// An active depth sensor
-static const capability_t kCapStereo	= 0x0008;	// Has right RGB
-static const capability_t kCapDepth		= 0x0010;	// Has depth capabilities
 
 class BaseSourceImpl {
 	public:
diff --git a/components/rgbd-sources/src/source.cpp b/components/rgbd-sources/src/source.cpp
index 77efb6b5d..ed3b856c6 100644
--- a/components/rgbd-sources/src/source.cpp
+++ b/components/rgbd-sources/src/source.cpp
@@ -1,5 +1,6 @@
 #include <loguru.hpp>
 #include <ftl/rgbd/source.hpp>
+#include "basesource.hpp"
 #include <ftl/threads.hpp>
 
 //#include "sources/net/net.hpp"
@@ -74,6 +75,15 @@ Source::~Source() {
 	if (impl_) delete impl_;
 }
 
+bool Source::isReady() { return (impl_) ? impl_->isReady() : false; }
+
+const Camera &Source::parameters() const {
+	if (impl_) return impl_->params_;
+	else throw FTL_Error("Cannot get parameters for bad source");
+}
+
+ftl::rgbd::FrameState &Source::state() { return impl_->state_; }
+
 cv::Mat Source::cameraMatrix() const {
 	cv::Mat m = (cv::Mat_<float>(3,3) << parameters().fx, 0.0, -parameters().cx, 0.0, parameters().fy, -parameters().cy, 0.0, 0.0, 1.0);
 	return m;
diff --git a/components/rgbd-sources/src/sources/image/image.hpp b/components/rgbd-sources/src/sources/image/image.hpp
index 18212ce87..9bf4f4f69 100644
--- a/components/rgbd-sources/src/sources/image/image.hpp
+++ b/components/rgbd-sources/src/sources/image/image.hpp
@@ -1,6 +1,8 @@
 #ifndef _FTL_RGBD_IMAGE_HPP_
 #define _FTL_RGBD_IMAGE_HPP_
 
+#include "../../basesource.hpp"
+
 namespace ftl {
 namespace rgbd {
 namespace detail {
diff --git a/components/rgbd-sources/src/sources/middlebury/middlebury_source.hpp b/components/rgbd-sources/src/sources/middlebury/middlebury_source.hpp
index f89bfd665..d102dbeba 100644
--- a/components/rgbd-sources/src/sources/middlebury/middlebury_source.hpp
+++ b/components/rgbd-sources/src/sources/middlebury/middlebury_source.hpp
@@ -4,7 +4,7 @@
 
 #include <loguru.hpp>
 
-#include <ftl/rgbd/source.hpp>
+#include "../../basesource.hpp"
 #include <ftl/cuda_common.hpp>
 
 namespace ftl {
diff --git a/components/rgbd-sources/src/sources/pylon/pylon.hpp b/components/rgbd-sources/src/sources/pylon/pylon.hpp
index fe6be490c..df80e70a7 100644
--- a/components/rgbd-sources/src/sources/pylon/pylon.hpp
+++ b/components/rgbd-sources/src/sources/pylon/pylon.hpp
@@ -2,7 +2,7 @@
 #ifndef _FTL_RGBD_PYLON_HPP_
 #define _FTL_RGBD_PYLON_HPP_
 
-#include <ftl/rgbd/detail/source.hpp>
+#include "../../basesource.hpp"
 #include <string>
 
 namespace Pylon {
diff --git a/components/rgbd-sources/src/sources/realsense/realsense_source.hpp b/components/rgbd-sources/src/sources/realsense/realsense_source.hpp
index a0b730e8e..83274aecc 100644
--- a/components/rgbd-sources/src/sources/realsense/realsense_source.hpp
+++ b/components/rgbd-sources/src/sources/realsense/realsense_source.hpp
@@ -2,7 +2,7 @@
 #ifndef _FTL_RGBD_REALSENSE_HPP_
 #define _FTL_RGBD_REALSENSE_HPP_
 
-#include <ftl/rgbd/detail/source.hpp>
+#include "../../basesource.hpp"
 #include <librealsense2/rs.hpp>
 #include <string>
 
diff --git a/components/rgbd-sources/src/sources/screencapture/screencapture.hpp b/components/rgbd-sources/src/sources/screencapture/screencapture.hpp
index d753ada43..163ab106c 100644
--- a/components/rgbd-sources/src/sources/screencapture/screencapture.hpp
+++ b/components/rgbd-sources/src/sources/screencapture/screencapture.hpp
@@ -1,7 +1,7 @@
 #ifndef _FTL_RGBD_SCREENCAPTURE_HPP_
 #define _FTL_RGBD_SCREENCAPTURE_HPP_
 
-#include <ftl/rgbd/detail/source.hpp>
+#include "../../basesource.hpp"
 #include <ftl/config.h>
 
 namespace ftl {
diff --git a/components/rgbd-sources/src/sources/stereovideo/stereovideo.hpp b/components/rgbd-sources/src/sources/stereovideo/stereovideo.hpp
index 54f2d5e12..2b6fc3a83 100644
--- a/components/rgbd-sources/src/sources/stereovideo/stereovideo.hpp
+++ b/components/rgbd-sources/src/sources/stereovideo/stereovideo.hpp
@@ -2,7 +2,7 @@
 #ifndef _FTL_RGBD_STEREOVIDEO_HPP_
 #define _FTL_RGBD_STEREOVIDEO_HPP_
 
-#include <ftl/rgbd/source.hpp>
+#include "../../basesource.hpp"
 #include <ftl/operators/operator.hpp>
 #include <string>
 
diff --git a/components/rgbd-sources/test/source_unit.cpp b/components/rgbd-sources/test/source_unit.cpp
index 365088c42..bf45f5623 100644
--- a/components/rgbd-sources/test/source_unit.cpp
+++ b/components/rgbd-sources/test/source_unit.cpp
@@ -3,6 +3,7 @@
 //---- Mocks -------------------------------------------------------------------
 
 #include <ftl/rgbd/source.hpp>
+#include "../src/basesource.hpp"
 #include <ftl/config.h>
 
 #include <nlohmann/json.hpp>
-- 
GitLab