From 40b64bdd838c178bebc77352bcc1171d244278d1 Mon Sep 17 00:00:00 2001
From: Jussi Lindgren <jussi.lindgren@inria.fr>
Date: Mon, 23 Oct 2017 15:45:07 +0200
Subject: [PATCH] Server: Use std for pointers instead of boost

---
 .../gtec-gipsa/src/ovasCDriverGTecGUSBamp.h         |  5 ++---
 .../mbt-smarting/src/ovasCDriverMBTSmarting.h       |  3 +--
 .../mbt-smarting/src/ovasCSmartingAmp.cpp           |  5 +++--
 .../mbt-smarting/src/ovasCSmartingAmp.h             |  8 +++++---
 .../ovasCPluginExternalStimulations.h               |  4 +---
 .../tcp-tagging/ovasCPluginTCPTagging.h             |  4 +---
 .../server-extensions/tcp-tagging/ovasCTagStream.h  | 13 +++++--------
 7 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/contrib/plugins/server-drivers/gtec-gipsa/src/ovasCDriverGTecGUSBamp.h b/contrib/plugins/server-drivers/gtec-gipsa/src/ovasCDriverGTecGUSBamp.h
index 674c7b10e..a29477a55 100755
--- a/contrib/plugins/server-drivers/gtec-gipsa/src/ovasCDriverGTecGUSBamp.h
+++ b/contrib/plugins/server-drivers/gtec-gipsa/src/ovasCDriverGTecGUSBamp.h
@@ -20,8 +20,7 @@
 #include <thread>
 #include <mutex>
 #include <condition_variable>
-
-#include <boost\scoped_ptr.hpp>
+#include <memory> // unique_ptr
 
 #include <deque>
 using namespace std;
@@ -134,7 +133,7 @@ namespace OpenViBEAcquisitionServer
 
 		OpenViBE::uint32 m_ui32CurrentQueueIndex;
 
-		boost::scoped_ptr<std::thread> m_ThreadPtr;
+		std::unique_ptr<std::thread> m_ThreadPtr;
 		OpenViBE::boolean m_bIsThreadRunning;
 
 		std::mutex m_io_mutex;
diff --git a/contrib/plugins/server-drivers/mbt-smarting/src/ovasCDriverMBTSmarting.h b/contrib/plugins/server-drivers/mbt-smarting/src/ovasCDriverMBTSmarting.h
index be257191d..3b3a5ec0a 100755
--- a/contrib/plugins/server-drivers/mbt-smarting/src/ovasCDriverMBTSmarting.h
+++ b/contrib/plugins/server-drivers/mbt-smarting/src/ovasCDriverMBTSmarting.h
@@ -8,7 +8,6 @@
 #include "../ovasCSettingsHelper.h"
 #include "../ovasCSettingsHelperOperators.h"
 
-#include <boost/shared_ptr.hpp>
 #include "ovasCSmartingAmp.h"
 
 namespace OpenViBEAcquisitionServer
@@ -73,7 +72,7 @@ namespace OpenViBEAcquisitionServer
 		 * Example :
 		 */
 		OpenViBE::uint32 m_ui32ConnectionID;
-		boost::shared_ptr< SmartingAmp > m_pSmartingAmp;
+		std::shared_ptr< SmartingAmp > m_pSmartingAmp;
 		std::vector< unsigned char > m_byteArray;
 		int sample_number;
 		int latency;
diff --git a/contrib/plugins/server-drivers/mbt-smarting/src/ovasCSmartingAmp.cpp b/contrib/plugins/server-drivers/mbt-smarting/src/ovasCSmartingAmp.cpp
index 316d837f0..5ef8e62f0 100644
--- a/contrib/plugins/server-drivers/mbt-smarting/src/ovasCSmartingAmp.cpp
+++ b/contrib/plugins/server-drivers/mbt-smarting/src/ovasCSmartingAmp.cpp
@@ -256,7 +256,8 @@ bool SmartingAmp::start()
 
 	acquire();
 
-	auto f = boost::bind(&boost::asio::io_service::run, &m_io);
+	auto f = [this]() { this->m_io.run(); };
+	// auto f = boost::bind(&boost::asio::io_service::run, &m_io);
 
 	acquire_t.reset(new std::thread( f ));
 
@@ -370,7 +371,7 @@ void SmartingAmp::read_with_timeout(int size, size_t timeout)
 
 	m_bytes_readed = 0;
 
-	m_port->async_read_some( 
+	m_port->async_read_some(
 		boost::asio::buffer(m_commandReceiveBuffer, size),
 		boost::bind(
 			&SmartingAmp::read_complete,
diff --git a/contrib/plugins/server-drivers/mbt-smarting/src/ovasCSmartingAmp.h b/contrib/plugins/server-drivers/mbt-smarting/src/ovasCSmartingAmp.h
index d146187ff..9883bd98b 100644
--- a/contrib/plugins/server-drivers/mbt-smarting/src/ovasCSmartingAmp.h
+++ b/contrib/plugins/server-drivers/mbt-smarting/src/ovasCSmartingAmp.h
@@ -21,6 +21,8 @@
 #include <boost/bind.hpp>
 #include <boost/utility.hpp>
 
+#include <memory> // shared_ptr
+
 #include <mutex>
 #include <thread>
 
@@ -109,7 +111,7 @@ private:
    
 	boost::asio::io_service m_io;
     
-	boost::shared_ptr< boost::asio::serial_port > m_port;
+	std::shared_ptr< boost::asio::serial_port > m_port;
 
 	unsigned char m_receiveBuffer[MAX_PACKAGE_SIZE];
 	
@@ -133,9 +135,9 @@ private:
 	
 	int m_receivedSamples;
 
-	boost::shared_ptr< std::thread > acquire_t;
+	std::shared_ptr< std::thread > acquire_t;
 
-	boost::shared_ptr< boost::asio::deadline_timer > m_timer;
+	std::shared_ptr< boost::asio::deadline_timer > m_timer;
 
 	// read with timeout
 	int m_bytes_readed;
diff --git a/contrib/plugins/server-extensions/external-stimulations/ovasCPluginExternalStimulations.h b/contrib/plugins/server-extensions/external-stimulations/ovasCPluginExternalStimulations.h
index 76d1cd3dd..5931ac958 100644
--- a/contrib/plugins/server-extensions/external-stimulations/ovasCPluginExternalStimulations.h
+++ b/contrib/plugins/server-extensions/external-stimulations/ovasCPluginExternalStimulations.h
@@ -15,8 +15,6 @@
 #include <mutex>
 #include <condition_variable>
 
-#include <boost/scoped_ptr.hpp>
-
 #include <sys/timeb.h>
 
 #include "ovasIAcquisitionServerPlugin.h"
@@ -75,7 +73,7 @@ namespace OpenViBEAcquisitionServer
 				int m_iDebugStimulationsBuffered;
 
 				//added for acquiring external stimulations
-				boost::scoped_ptr<std::thread> m_ESthreadPtr;
+				std::unique_ptr<std::thread> m_ESthreadPtr;
 				OpenViBE::boolean m_bIsESThreadRunning;
 				std::mutex m_es_mutex;
 				std::condition_variable  m_esAvailable;
diff --git a/contrib/plugins/server-extensions/tcp-tagging/ovasCPluginTCPTagging.h b/contrib/plugins/server-extensions/tcp-tagging/ovasCPluginTCPTagging.h
index fb12db4d6..14030c46b 100644
--- a/contrib/plugins/server-extensions/tcp-tagging/ovasCPluginTCPTagging.h
+++ b/contrib/plugins/server-extensions/tcp-tagging/ovasCPluginTCPTagging.h
@@ -23,8 +23,6 @@
 #include "ovasIAcquisitionServerPlugin.h"
 #include "ovasCTagStream.h"
 
-#include <boost/scoped_ptr.hpp>
-
 namespace OpenViBEAcquisitionServer
 {
 	namespace OpenViBEAcquisitionServerPlugins
@@ -49,7 +47,7 @@ namespace OpenViBEAcquisitionServer
 			private:
 				OpenViBE::uint64 m_previousPosixTime;
 				OpenViBE::uint64 m_previousSampleTime;
-				boost::scoped_ptr<CTagStream> m_scopedTagStream;
+				std::unique_ptr<CTagStream> m_scopedTagStream;
 				OpenViBE::CString m_port;
 		};
 
diff --git a/contrib/plugins/server-extensions/tcp-tagging/ovasCTagStream.h b/contrib/plugins/server-extensions/tcp-tagging/ovasCTagStream.h
index ee0e8d430..50c00f88c 100644
--- a/contrib/plugins/server-extensions/tcp-tagging/ovasCTagStream.h
+++ b/contrib/plugins/server-extensions/tcp-tagging/ovasCTagStream.h
@@ -3,9 +3,6 @@
 
 #include <queue>
 #include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/scoped_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
 #include <boost/asio.hpp>
 
 #include <mutex>
@@ -39,10 +36,10 @@ class CTagSession; // forward declaration of CTagSession to define SharedSession
 class CTagQueue; // forward declaration of CTagQueue to define SharedQueuePtr
 class CTagServer; // forward declaration of CTagServer to define ScopedServerPtr
 
-typedef boost::shared_ptr<CTagQueue> SharedQueuePtr;
-typedef boost::shared_ptr<CTagSession> SharedSessionPtr;
-typedef boost::scoped_ptr<CTagServer> ScopedServerPtr;
-typedef boost::scoped_ptr<std::thread> ScopedThreadPtr;
+typedef std::shared_ptr<CTagQueue> SharedQueuePtr;
+typedef std::shared_ptr<CTagSession> SharedSessionPtr;
+typedef std::unique_ptr<CTagServer> ScopedServerPtr;
+typedef std::unique_ptr<std::thread> ScopedThreadPtr;
 
 // A trivial implementation of a queue to store Tags with exclusive locking
 class CTagQueue
@@ -62,7 +59,7 @@ private:
 
 // An instance of CTagSession is associated to every client connecting to the Tagging Server.
 // It contains a connection handle and data buffer.
-class CTagSession : public boost::enable_shared_from_this<CTagSession>
+class CTagSession : public std::enable_shared_from_this<CTagSession>
 {
 public:
 	CTagSession(boost::asio::io_service& io_service, const SharedQueuePtr& queue);
-- 
GitLab