From 2dadace9e02644dc06d0d94c25f8b2da76291420 Mon Sep 17 00:00:00 2001 From: Vladimir Gorshenkov Date: Fri, 9 Jul 2021 14:01:14 +0300 Subject: [PATCH] [Common][Network] change typedef style func to c++11 std::function --- .../FileTransporter/include/FileTransporter.h | 17 +++++++++-------- .../FileTransporter/src/FileTransporter.cpp | 8 ++++---- .../src/FileTransporter_private.h | 4 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Common/Network/FileTransporter/include/FileTransporter.h b/Common/Network/FileTransporter/include/FileTransporter.h index d7ef0052e3..3ed6ec61ca 100644 --- a/Common/Network/FileTransporter/include/FileTransporter.h +++ b/Common/Network/FileTransporter/include/FileTransporter.h @@ -32,15 +32,16 @@ #pragma once #include +#include #include "../../../kernel_config.h" namespace NSNetwork { namespace NSFileTransport { - typedef void (*CFileTransporter_OnComplete)(int error); + //typedef void (*CFileTransporter_OnComplete)(int error); // cancel: 1, else 0 - typedef int (*CFileTransporter_OnProgress)(int percent); + //typedef int (*CFileTransporter_OnProgress)(int percent); class KERNEL_DECL IFileTransporter { @@ -58,8 +59,8 @@ namespace NSNetwork virtual int IsRunned() = 0; //events - virtual void SetEvent_OnProgress(CFileTransporter_OnProgress) = 0; - virtual void SetEvent_OnComplete(CFileTransporter_OnComplete) = 0; + virtual void SetEvent_OnProgress(std::function) = 0; + virtual void SetEvent_OnComplete(std::function) = 0; }; #ifdef _MAC @@ -92,8 +93,8 @@ namespace NSNetwork virtual void Resume(); virtual void Stop(); virtual int IsRunned(); - virtual void SetEvent_OnProgress(CFileTransporter_OnProgress); - virtual void SetEvent_OnComplete(CFileTransporter_OnComplete); + virtual void SetEvent_OnProgress(std::function); + virtual void SetEvent_OnComplete(std::function); private: CFileTransporter_private* m_pInternal; @@ -122,8 +123,8 @@ namespace NSNetwork virtual void Resume(); virtual void Stop(); virtual int IsRunned(); - virtual void SetEvent_OnProgress(CFileTransporter_OnProgress); - virtual void SetEvent_OnComplete(CFileTransporter_OnComplete); + virtual void SetEvent_OnProgress(std::function); + virtual void SetEvent_OnComplete(std::function); private: CFileTransporter_private* m_pInternal; diff --git a/Common/Network/FileTransporter/src/FileTransporter.cpp b/Common/Network/FileTransporter/src/FileTransporter.cpp index 7b5dbbdbcf..86771a1022 100644 --- a/Common/Network/FileTransporter/src/FileTransporter.cpp +++ b/Common/Network/FileTransporter/src/FileTransporter.cpp @@ -103,11 +103,11 @@ namespace NSNetwork void CFileDownloader::Stop() { m_pInternal->Stop(); } int CFileDownloader::IsRunned() { return m_pInternal->IsRunned(); } - void CFileDownloader::SetEvent_OnProgress(CFileTransporter_OnProgress func) + void CFileDownloader::SetEvent_OnProgress(std::function func) { m_pInternal->GetInternal()->m_func_onProgress = func; } - void CFileDownloader::SetEvent_OnComplete(CFileTransporter_OnComplete func) + void CFileDownloader::SetEvent_OnComplete(std::function func) { m_pInternal->GetInternal()->m_func_onComplete = func; } @@ -166,11 +166,11 @@ namespace NSNetwork void CFileUploader::Stop() { m_pInternal->Stop(); } int CFileUploader::IsRunned() { return m_pInternal->IsRunned(); } - void CFileUploader::SetEvent_OnProgress(CFileTransporter_OnProgress func) + void CFileUploader::SetEvent_OnProgress(std::function func) { m_pInternal->GetInternal()->m_func_onProgress = func; } - void CFileUploader::SetEvent_OnComplete(CFileTransporter_OnComplete func) + void CFileUploader::SetEvent_OnComplete(std::function func) { m_pInternal->GetInternal()->m_func_onComplete = func; } diff --git a/Common/Network/FileTransporter/src/FileTransporter_private.h b/Common/Network/FileTransporter/src/FileTransporter_private.h index 12f78c87d3..32dc83fbbb 100644 --- a/Common/Network/FileTransporter/src/FileTransporter_private.h +++ b/Common/Network/FileTransporter/src/FileTransporter_private.h @@ -141,8 +141,8 @@ namespace NSNetwork std::wstring m_sResponse; // Ответ сервера - CFileTransporter_OnComplete m_func_onComplete; - CFileTransporter_OnProgress m_func_onProgress; + std::function m_func_onComplete; + std::function m_func_onProgress; }; class CFileTransporter_private : public NSThreads::CBaseThread