Index: src/ch/FeedbackHandler.cpp =================================================================== diff -u -N -r25b3c85ea493809ee084271d5101a015d349da95 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision 25b3c85ea493809ee084271d5101a015d349da95) +++ src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -33,7 +33,6 @@ CFeedbackHandler::~CFeedbackHandler() { - } ull_t CFeedbackHandler::RequestFeedback(ull_t ullFeedbackID, ptr_t pFeedbackParam) @@ -128,22 +127,17 @@ return eFeedbackResult; } -void CFeedbackHandler::Delete() +chcore::IFeedbackHandlerPtr CFeedbackHandlerFactory::Create() { - delete this; + return chcore::IFeedbackHandlerPtr(new CFeedbackHandler); } -chcore::IFeedbackHandler* CFeedbackHandlerFactory::Create() +CFeedbackHandlerFactory::CFeedbackHandlerFactory() { - return new CFeedbackHandler; -} -chcore::IFeedbackHandlerFactory* CFeedbackHandlerFactory::CreateFactory() -{ - return new CFeedbackHandlerFactory; } -void CFeedbackHandlerFactory::Delete() +CFeedbackHandlerFactory::~CFeedbackHandlerFactory() { - delete this; + } Index: src/ch/FeedbackHandler.h =================================================================== diff -u -N -r4d20d0e58f37f06ac91287015b960308db54d47e -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/ch/FeedbackHandler.h (.../FeedbackHandler.h) (revision 4d20d0e58f37f06ac91287015b960308db54d47e) +++ src/ch/FeedbackHandler.h (.../FeedbackHandler.h) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -19,35 +19,35 @@ #ifndef __FEEDBACKHANDLER_H__ #define __FEEDBACKHANDLER_H__ -#include "../libchcore/FeedbackHandlerBase.h" +#include "../libchcore/IFeedbackHandlerFactory.h" class CFeedbackHandler : public chcore::IFeedbackHandler { -protected: +public: CFeedbackHandler(); - ~CFeedbackHandler(); + virtual ~CFeedbackHandler(); public: virtual ull_t RequestFeedback(ull_t ullFeedbackID, ptr_t pFeedbackParam); - virtual void Delete(); protected: EFeedbackResult m_aeFeedbackTypeStatus[eFT_LastType]; friend class CFeedbackHandlerFactory; }; +typedef boost::shared_ptr CFeedbackHandlerPtr; + class CFeedbackHandlerFactory : public chcore::IFeedbackHandlerFactory { -protected: - CFeedbackHandlerFactory() {} - ~CFeedbackHandlerFactory() {} - public: - chcore::IFeedbackHandler* Create(); - virtual void Delete(); + CFeedbackHandlerFactory(); + virtual ~CFeedbackHandlerFactory(); - static IFeedbackHandlerFactory* CreateFactory(); +public: + chcore::IFeedbackHandlerPtr Create(); }; +typedef boost::shared_ptr CFeedbackHandlerFactoryPtr; + #endif Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -r30297d6aab17483da8e7b8323b4d17ff1a9f78d6 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 30297d6aab17483da8e7b8323b4d17ff1a9f78d6) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -73,7 +73,6 @@ ///////////////////////////////////////////////////////////////////////////// // CMainWnd construction/destruction CMainWnd::CMainWnd() : - m_pFeedbackFactory(CFeedbackHandlerFactory::CreateFactory()), m_pdlgStatus(NULL), m_pdlgMiniView(NULL), m_dwLastTime(0), @@ -84,8 +83,6 @@ CMainWnd::~CMainWnd() { - if(m_pFeedbackFactory) - m_pFeedbackFactory->Delete(); } // registers main window class @@ -242,10 +239,11 @@ CString strError; CString strTasksDir = GetTasksDirectory(); TSQLiteSerializerFactoryPtr spSerializerFactory(new TSQLiteSerializerFactory(PathFromString(strTasksDir))); + IFeedbackHandlerFactoryPtr spFeedbackFactory(new CFeedbackHandlerFactory); try { - m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, m_pFeedbackFactory)); + m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, spFeedbackFactory)); } catch(const std::exception& e) { @@ -256,7 +254,7 @@ { if(MsgBox(IDS_TASKMANAGER_LOAD_FAILED, MB_ICONERROR | MB_OKCANCEL) == IDOK) { - m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, m_pFeedbackFactory, true)); + m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, spFeedbackFactory, true)); } else return false; Index: src/ch/MainWnd.h =================================================================== diff -u -N -r30297d6aab17483da8e7b8323b4d17ff1a9f78d6 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/ch/MainWnd.h (.../MainWnd.h) (revision 30297d6aab17483da8e7b8323b4d17ff1a9f78d6) +++ src/ch/MainWnd.h (.../MainWnd.h) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -80,7 +80,6 @@ CTrayIcon m_ctlTray; chcore::TTaskManagerPtr m_spTasks; - chcore::IFeedbackHandlerFactory* m_pFeedbackFactory; chcore::TSharedMemory m_tCHExtharedMemory; CMiniViewDlg* m_pdlgMiniView; Index: src/libchcore/IFeedbackHandler.cpp =================================================================== diff -u -N --- src/libchcore/IFeedbackHandler.cpp (revision 0) +++ src/libchcore/IFeedbackHandler.cpp (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -0,0 +1,28 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "IFeedbackHandler.h" + +BEGIN_CHCORE_NAMESPACE + +IFeedbackHandler::~IFeedbackHandler() +{ +} + +END_CHCORE_NAMESPACE Index: src/libchcore/IFeedbackHandler.h =================================================================== diff -u -N --- src/libchcore/IFeedbackHandler.h (revision 0) +++ src/libchcore/IFeedbackHandler.h (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -0,0 +1,99 @@ +/*************************************************************************** + * Copyright (C) 2001-2008 by J�zef Starosczyk * + * ixen@copyhandler.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License * + * (version 2) as published by the Free Software Foundation; * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __FEEDBACKHANDLERBASE_H__ +#define __FEEDBACKHANDLERBASE_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +class TFileInfo; +typedef boost::shared_ptr TFileInfoPtr; + +enum EFileError +{ + eDeleteError, ///< Problem occured when tried to delete the fs object + eSeekError, ///< Problem occured when tried to set file pointer + eResizeError, ///< Problem occured when tried to change size of the fs object + eReadError, ///< Problem occured when tried to read data from file + eWriteError, ///< Problem occured when tried to write data to a file + eFastMoveError, ///< Problem occured when tried to perform fast move operation (that does not involve copying contents) + eCreateError ///< Problem occured when tried to create the fs object +}; + +struct FEEDBACK_ALREADYEXISTS +{ + TFileInfoPtr spSrcFileInfo; + TFileInfoPtr spDstFileInfo; +}; + +struct FEEDBACK_FILEERROR +{ + const wchar_t* pszSrcPath; + const wchar_t* pszDstPath; + EFileError eFileError; // error type + ulong_t ulError; // system error +}; + +struct FEEDBACK_NOTENOUGHSPACE +{ + ull_t ullRequiredSize; + const wchar_t* pszSrcPath; + const wchar_t* pszDstPath; +}; + +class LIBCHCORE_API IFeedbackHandler +{ +public: + enum EFeedbackType + { + eFT_Unknown = 0, + // requests for use feedback + eFT_FileAlreadyExists, + eFT_FileError, + eFT_NotEnoughSpace, + // notifications + eFT_OperationFinished, ///< Task has finished processing + eFT_OperationError, ///< Error encountered while processing task + eFT_LastType + }; + + enum EFeedbackResult + { + eResult_Unknown = 0, + eResult_Overwrite, + eResult_CopyRest, + eResult_Skip, + eResult_Cancel, + eResult_Pause, + eResult_Retry, + eResult_Ignore + }; + +public: + virtual ~IFeedbackHandler(); + + virtual ull_t RequestFeedback(ull_t ullFeedbackID, ptr_t pFeedbackParam) = 0; +}; + +typedef boost::shared_ptr IFeedbackHandlerPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/FeedbackHandlerBase.h =================================================================== diff -u -N --- src/libchcore/FeedbackHandlerBase.h (revision 1d8d51e0dd4d8ebcf0bd457d01fab984585220c0) +++ src/libchcore/FeedbackHandlerBase.h (revision 0) @@ -1,102 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2001-2008 by J�zef Starosczyk * - * ixen@copyhandler.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License * - * (version 2) as published by the Free Software Foundation; * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#ifndef __FEEDBACKHANDLERBASE_H__ -#define __FEEDBACKHANDLERBASE_H__ - -#include "libchcore.h" -#include "../libicpf/interface.h" - -BEGIN_CHCORE_NAMESPACE - -class TFileInfo; -typedef boost::shared_ptr TFileInfoPtr; - -enum EFileError -{ - eDeleteError, ///< Problem occured when tried to delete the fs object - eSeekError, ///< Problem occured when tried to set file pointer - eResizeError, ///< Problem occured when tried to change size of the fs object - eReadError, ///< Problem occured when tried to read data from file - eWriteError, ///< Problem occured when tried to write data to a file - eFastMoveError, ///< Problem occured when tried to perform fast move operation (that does not involve copying contents) - eCreateError ///< Problem occured when tried to create the fs object -}; - -struct FEEDBACK_ALREADYEXISTS -{ - TFileInfoPtr spSrcFileInfo; - TFileInfoPtr spDstFileInfo; -}; - -struct FEEDBACK_FILEERROR -{ - const wchar_t* pszSrcPath; - const wchar_t* pszDstPath; - EFileError eFileError; // error type - ulong_t ulError; // system error -}; - -struct FEEDBACK_NOTENOUGHSPACE -{ - ull_t ullRequiredSize; - const wchar_t* pszSrcPath; - const wchar_t* pszDstPath; -}; - -class IFeedbackHandler : public icpf::IInterface -{ -public: - enum EFeedbackType - { - eFT_Unknown = 0, - // requests for use feedback - eFT_FileAlreadyExists, - eFT_FileError, - eFT_NotEnoughSpace, - // notifications - eFT_OperationFinished, ///< Task has finished processing - eFT_OperationError, ///< Error encountered while processing task - eFT_LastType - }; - - enum EFeedbackResult - { - eResult_Unknown = 0, - eResult_Overwrite, - eResult_CopyRest, - eResult_Skip, - eResult_Cancel, - eResult_Pause, - eResult_Retry, - eResult_Ignore - }; - -public: - virtual ull_t RequestFeedback(ull_t ullFeedbackID, ptr_t pFeedbackParam) = 0; -}; - -class IFeedbackHandlerFactory : public icpf::IInterface -{ -public: - virtual IFeedbackHandler* Create() = 0; -}; - -END_CHCORE_NAMESPACE - -#endif Index: src/libchcore/IFeedbackHandlerFactory.cpp =================================================================== diff -u -N --- src/libchcore/IFeedbackHandlerFactory.cpp (revision 0) +++ src/libchcore/IFeedbackHandlerFactory.cpp (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -0,0 +1,28 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "IFeedbackHandlerFactory.h" + +BEGIN_CHCORE_NAMESPACE + +IFeedbackHandlerFactory::~IFeedbackHandlerFactory() +{ +} + +END_CHCORE_NAMESPACE Index: src/libchcore/IFeedbackHandlerFactory.h =================================================================== diff -u -N --- src/libchcore/IFeedbackHandlerFactory.h (revision 0) +++ src/libchcore/IFeedbackHandlerFactory.h (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -0,0 +1,39 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __IFEEDBACKHANDLERFACTORY_H__ +#define __IFEEDBACKHANDLERFACTORY_H__ + +#include "libchcore.h" +#include "IFeedbackHandler.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API IFeedbackHandlerFactory +{ +public: + virtual ~IFeedbackHandlerFactory(); + + virtual IFeedbackHandlerPtr Create() = 0; +}; + +typedef boost::shared_ptr IFeedbackHandlerFactoryPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TSubTaskContext.cpp =================================================================== diff -u -N -r9ba9390b8f79c7a3fd1f9d6d9e92038d92222621 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 9ba9390b8f79c7a3fd1f9d6d9e92038d92222621) +++ src/libchcore/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -22,12 +22,14 @@ // ============================================================================ #include "stdafx.h" #include "TSubTaskContext.h" +#include "ErrorCodes.h" +#include "TCoreException.h" BEGIN_CHCORE_NAMESPACE TSubTaskContext::TSubTaskContext(TConfig& rConfig, TBasePathDataContainer& rBasePathDataContainer, TFileInfoArray& rFilesCache, - TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, IFeedbackHandler* piFeedbackHandler, + TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, const IFeedbackHandlerPtr& spFeedbackHandler, TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal) : m_rConfig(rConfig), m_eOperationType(eOperation_None), @@ -36,7 +38,7 @@ m_pathDestination(), m_rCfgTracker(rCfgTracker), m_rLog(rLog), - m_piFeedbackHandler(piFeedbackHandler), + m_spFeedbackHandler(spFeedbackHandler), m_rThreadController(rThreadController), m_rfsLocal(rfsLocal) { @@ -46,4 +48,102 @@ { } +TConfig& TSubTaskContext::GetConfig() +{ + return m_rConfig; +} + +const TConfig& TSubTaskContext::GetConfig() const +{ + return m_rConfig; +} + +chcore::EOperationType TSubTaskContext::GetOperationType() const +{ + return m_eOperationType; +} + +void TSubTaskContext::SetOperationType(chcore::EOperationType eOperationType) +{ + m_eOperationType = eOperationType; +} + +TBasePathDataContainer& TSubTaskContext::GetBasePathDataContainer() +{ + return m_rBasePathDataContainer; +} + +const TBasePathDataContainer& TSubTaskContext::GetBasePathDataContainer() const +{ + return m_rBasePathDataContainer; +} + +TFileInfoArray& TSubTaskContext::GetFilesCache() +{ + return m_rFilesCache; +} + +const TFileInfoArray& TSubTaskContext::GetFilesCache() const +{ + return m_rFilesCache; +} + +chcore::TSmartPath TSubTaskContext::GetDestinationPath() const +{ + return m_pathDestination; +} + +void TSubTaskContext::SetDestinationPath(const TSmartPath& pathDestination) +{ + m_pathDestination = pathDestination; +} + +TTaskConfigTracker& TSubTaskContext::GetCfgTracker() +{ + return m_rCfgTracker; +} + +const TTaskConfigTracker& TSubTaskContext::GetCfgTracker() const +{ + return m_rCfgTracker; +} + +icpf::log_file& TSubTaskContext::GetLog() +{ + return m_rLog; +} + +const icpf::log_file& TSubTaskContext::GetLog() const +{ + return m_rLog; +} + +chcore::IFeedbackHandlerPtr TSubTaskContext::GetFeedbackHandler() +{ + if(!m_spFeedbackHandler) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); + + return m_spFeedbackHandler; +} + +TWorkerThreadController& TSubTaskContext::GetThreadController() +{ + return m_rThreadController; +} + +const TWorkerThreadController& TSubTaskContext::GetThreadController() const +{ + return m_rThreadController; +} + +TLocalFilesystem& TSubTaskContext::GetLocalFilesystem() +{ + return m_rfsLocal; +} + +const TLocalFilesystem& TSubTaskContext::GetLocalFilesystem() const +{ + return m_rfsLocal; +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskContext.h =================================================================== diff -u -N -r9ba9390b8f79c7a3fd1f9d6d9e92038d92222621 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision 9ba9390b8f79c7a3fd1f9d6d9e92038d92222621) +++ src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -26,6 +26,7 @@ #include "libchcore.h" #include "TPath.h" #include "EOperationTypes.h" +#include "IFeedbackHandler.h" namespace icpf { @@ -34,7 +35,6 @@ BEGIN_CHCORE_NAMESPACE -class IFeedbackHandler; class TWorkerThreadController; class TBasePathDataContainer; class TTaskConfigTracker; @@ -53,38 +53,37 @@ TSubTaskContext(TConfig& rConfig, TBasePathDataContainer& rBasePathDataContainer, TFileInfoArray& rFilesCache, TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, - IFeedbackHandler* piFeedbackHandler, TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal); + const IFeedbackHandlerPtr& spFeedbackHandler, TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal); ~TSubTaskContext(); - TConfig& GetConfig() { return m_rConfig; } - const TConfig& GetConfig() const { return m_rConfig; } + TConfig& GetConfig(); + const TConfig& GetConfig() const; - chcore::EOperationType GetOperationType() const { return m_eOperationType; } - void SetOperationType(chcore::EOperationType eOperationType) { m_eOperationType = eOperationType; } + chcore::EOperationType GetOperationType() const; + void SetOperationType(chcore::EOperationType eOperationType); - TBasePathDataContainer& GetBasePathDataContainer() { return m_rBasePathDataContainer; } - const TBasePathDataContainer& GetBasePathDataContainer() const { return m_rBasePathDataContainer; } + TBasePathDataContainer& GetBasePathDataContainer(); + const TBasePathDataContainer& GetBasePathDataContainer() const; - TFileInfoArray& GetFilesCache() { return m_rFilesCache; } - const TFileInfoArray& GetFilesCache() const { return m_rFilesCache; } + TFileInfoArray& GetFilesCache(); + const TFileInfoArray& GetFilesCache() const; - TSmartPath GetDestinationPath() const { return m_pathDestination; } - void SetDestinationPath(const TSmartPath& pathDestination) { m_pathDestination = pathDestination; } + TSmartPath GetDestinationPath() const; + void SetDestinationPath(const TSmartPath& pathDestination); - TTaskConfigTracker& GetCfgTracker() { return m_rCfgTracker; } - const TTaskConfigTracker& GetCfgTracker() const { return m_rCfgTracker; } + TTaskConfigTracker& GetCfgTracker(); + const TTaskConfigTracker& GetCfgTracker() const; - icpf::log_file& GetLog() { return m_rLog; } - const icpf::log_file& GetLog() const { return m_rLog; } + icpf::log_file& GetLog(); + const icpf::log_file& GetLog() const; - IFeedbackHandler* GetFeedbackHandler() { return m_piFeedbackHandler; } - const IFeedbackHandler* GetFeedbackHandler() const { return m_piFeedbackHandler; } + IFeedbackHandlerPtr GetFeedbackHandler(); - TWorkerThreadController& GetThreadController() { return m_rThreadController; } - const TWorkerThreadController& GetThreadController() const { return m_rThreadController; } + TWorkerThreadController& GetThreadController(); + const TWorkerThreadController& GetThreadController() const; - TLocalFilesystem& GetLocalFilesystem() { return m_rfsLocal; } - const TLocalFilesystem& GetLocalFilesystem() const { return m_rfsLocal; } + TLocalFilesystem& GetLocalFilesystem(); + const TLocalFilesystem& GetLocalFilesystem() const; private: TSubTaskContext(const TSubTaskContext& rSrc); @@ -113,7 +112,10 @@ icpf::log_file& m_rLog; // feedback handling - IFeedbackHandler* m_piFeedbackHandler; +#pragma warning(push) +#pragma warning(disable: 4251) + IFeedbackHandlerPtr m_spFeedbackHandler; +#pragma warning(pop) // thread control TWorkerThreadController& m_rThreadController; Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -N -r9ba9390b8f79c7a3fd1f9d6d9e92038d92222621 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 9ba9390b8f79c7a3fd1f9d6d9e92038d92222621) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -30,7 +30,7 @@ #include "TTaskLocalStats.h" #include "TTaskConfigTracker.h" #include "TWorkerThreadController.h" -#include "FeedbackHandlerBase.h" +#include "IFeedbackHandler.h" #include #include "TBasePathData.h" #include @@ -167,14 +167,10 @@ TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); const TConfig& rConfig = GetContext().GetConfig(); TSmartPath pathDestination = GetContext().GetDestinationPath(); - BOOST_ASSERT(piFeedbackHandler != NULL); - if(piFeedbackHandler == NULL) - return eSubResult_Error; - // log rLog.logi(_T("Processing files/folders (ProcessFiles)")); @@ -674,7 +670,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenSourceFileFB(TLocalFilesystemFile& fileSrc, const TSmartPath& spPathToOpen, bool bNoBuffering) { - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); BOOST_ASSERT(!spPathToOpen.IsEmpty()); @@ -694,7 +690,7 @@ DWORD dwLastError = GetLastError(); FEEDBACK_FILEERROR feedStruct = { spPathToOpen.ToString(), NULL, eCreateError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &feedStruct); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &feedStruct); switch(frResult) { @@ -740,7 +736,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenDestinationFileFB(TLocalFilesystemFile& fileDst, const TSmartPath& pathDstFile, bool bNoBuffering, const TFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated) { - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); bool bRetry = false; @@ -778,7 +774,7 @@ // src and dst files are the same FEEDBACK_ALREADYEXISTS feedStruct = { spSrcFileInfo, spDstFileInfo }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileAlreadyExists, &feedStruct); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileAlreadyExists, &feedStruct); // check for dialog result switch(frResult) { @@ -813,7 +809,7 @@ else { FEEDBACK_FILEERROR feedStruct = { pathDstFile.ToString(), NULL, eCreateError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &feedStruct); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &feedStruct); switch(frResult) { case IFeedbackHandler::eResult_Retry: @@ -859,7 +855,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenExistingDestinationFileFB(TLocalFilesystemFile& fileDst, const TSmartPath& pathDstFile, bool bNoBuffering) { - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); bool bRetry = false; @@ -874,7 +870,7 @@ { DWORD dwLastError = GetLastError(); FEEDBACK_FILEERROR feedStruct = { pathDstFile.ToString(), NULL, eCreateError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &feedStruct); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &feedStruct); switch (frResult) { case IFeedbackHandler::eResult_Retry: @@ -919,7 +915,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::SetFilePointerFB(TLocalFilesystemFile& file, long long llDistance, const TSmartPath& pathFile, bool& bSkip) { - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); bSkip = false; @@ -940,7 +936,7 @@ rLog.loge(strFormat); FEEDBACK_FILEERROR ferr = { pathFile.ToString(), NULL, eSeekError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: @@ -970,7 +966,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::SetEndOfFileFB(TLocalFilesystemFile& file, const TSmartPath& pathFile, bool& bSkip) { - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); bSkip = false; @@ -989,7 +985,7 @@ rLog.loge(strFormat); FEEDBACK_FILEERROR ferr = { pathFile.ToString(), NULL, eResizeError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: @@ -1018,7 +1014,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::ReadFileFB(TLocalFilesystemFile& file, chcore::TSimpleDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const TSmartPath& pathFile, bool& bSkip) { - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); bSkip = false; @@ -1039,7 +1035,7 @@ rLog.loge(strFormat); FEEDBACK_FILEERROR ferr = { pathFile.ToString(), NULL, eReadError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: @@ -1069,7 +1065,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::WriteFileFB(TLocalFilesystemFile& file, chcore::TSimpleDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const TSmartPath& pathFile, bool& bSkip) { - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); bSkip = false; @@ -1091,7 +1087,7 @@ rLog.loge(strFormat); FEEDBACK_FILEERROR ferr = { pathFile.ToString(), NULL, eWriteError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: @@ -1187,7 +1183,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::CreateDirectoryFB(const TSmartPath& pathDirectory) { icpf::log_file& rLog = GetContext().GetLog(); - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); bool bRetry = true; DWORD dwLastError = ERROR_SUCCESS; @@ -1201,7 +1197,7 @@ rLog.loge(strFormat); FEEDBACK_FILEERROR ferr = { pathDirectory.ToString(), NULL, eCreateError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: @@ -1230,7 +1226,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::CheckForFreeSpaceFB() { icpf::log_file& rLog = GetContext().GetLog(); - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); TLocalFilesystem& rLocalFilesystem = GetContext().GetLocalFilesystem(); TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); const TPathContainer& rSrcPaths = GetContext().GetBasePathDataContainer().GetBasePaths(); @@ -1259,7 +1255,7 @@ if(!rSrcPaths.IsEmpty()) { FEEDBACK_NOTENOUGHSPACE feedStruct = { ullNeededSize, rSrcPaths.GetAt(0).ToString(), pathDestination.ToString() }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_NotEnoughSpace, &feedStruct); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_NotEnoughSpace, &feedStruct); // default switch(frResult) Index: src/libchcore/TSubTaskDelete.cpp =================================================================== diff -u -N -r9ba9390b8f79c7a3fd1f9d6d9e92038d92222621 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 9ba9390b8f79c7a3fd1f9d6d9e92038d92222621) +++ src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -27,7 +27,7 @@ #include "TTaskConfiguration.h" #include "TLocalFilesystem.h" #include "..\libicpf\log.h" -#include "FeedbackHandlerBase.h" +#include "IFeedbackHandler.h" #include #include "TFileInfoArray.h" #include "TFileInfo.h" @@ -114,7 +114,7 @@ icpf::log_file& rLog = GetContext().GetLog(); TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); const TConfig& rConfig = GetContext().GetConfig(); // log @@ -186,7 +186,7 @@ rLog.loge(strFormat); FEEDBACK_FILEERROR ferr = { spFileInfo->GetFullFilePath().ToString(), NULL, eDeleteError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -N -r9ba9390b8f79c7a3fd1f9d6d9e92038d92222621 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 9ba9390b8f79c7a3fd1f9d6d9e92038d92222621) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -26,7 +26,7 @@ #include "TSubTaskContext.h" #include "TTaskConfiguration.h" #include "TLocalFilesystem.h" -#include "FeedbackHandlerBase.h" +#include "IFeedbackHandler.h" #include "TBasePathData.h" #include "TWorkerThreadController.h" #include "TTaskLocalStats.h" @@ -114,7 +114,7 @@ // log icpf::log_file& rLog = GetContext().GetLog(); - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); TBasePathDataContainer& rBasePathDataContainer = GetContext().GetBasePathDataContainer(); const TConfig& rConfig = GetContext().GetConfig(); @@ -181,7 +181,7 @@ if(!bExists) { FEEDBACK_FILEERROR ferr = { pathCurrent.ToString(), NULL, eFastMoveError, ERROR_FILE_NOT_FOUND }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: @@ -245,7 +245,7 @@ rLog.loge(strFormat); FEEDBACK_FILEERROR ferr = { pathSrc.ToString(), pathDestinationPath.ToString(), eFastMoveError, dwLastError }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: Index: src/libchcore/TSubTaskScanDirectory.cpp =================================================================== diff -u -N -r9ba9390b8f79c7a3fd1f9d6d9e92038d92222621 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 9ba9390b8f79c7a3fd1f9d6d9e92038d92222621) +++ src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -25,7 +25,7 @@ #include "TSubTaskContext.h" #include "TTaskConfiguration.h" #include "TLocalFilesystem.h" -#include "FeedbackHandlerBase.h" +#include "IFeedbackHandler.h" #include "TBasePathData.h" #include "TWorkerThreadController.h" #include "TTaskLocalStats.h" @@ -117,7 +117,7 @@ // log icpf::log_file& rLog = GetContext().GetLog(); TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); - IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); TBasePathDataContainer& rBasePathDataContainer = GetContext().GetBasePathDataContainer(); const TPathContainer& rBasePaths = rBasePathDataContainer.GetBasePaths(); @@ -186,7 +186,7 @@ if(!bExists) { FEEDBACK_FILEERROR ferr = { rBasePaths.GetAt(stIndex).ToString(), NULL, eFastMoveError, ERROR_FILE_NOT_FOUND }; - IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); + IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { case IFeedbackHandler::eResult_Cancel: Index: src/libchcore/TTask.cpp =================================================================== diff -u -N -rb7655a8f0721e5454befd29e3e067748eb0521e9 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision b7655a8f0721e5454befd29e3e067748eb0521e9) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -42,31 +42,29 @@ //////////////////////////////////////////////////////////////////////////// // TTask members -TTask::TTask(const ISerializerPtr& spSerializer, IFeedbackHandler* piFeedbackHandler) : +TTask::TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler) : m_strTaskName(m_bBaseDataChanged), m_eCurrentState(eTaskState_None, m_bBaseDataChanged), m_pathLog(m_bBaseDataChanged), m_pathDestinationPath(m_bBaseDataChanged), m_log(), - m_piFeedbackHandler(piFeedbackHandler), + m_spFeedbackHandler(spFeedbackHandler), m_arrSourcePathsInfo(m_vSourcePaths), m_files(m_vSourcePaths), m_bForce(false), m_bContinue(false), - m_tSubTaskContext(m_tConfiguration, m_arrSourcePathsInfo, m_files, m_cfgTracker, m_log, piFeedbackHandler, m_workerThread, m_fsLocal), + m_tSubTaskContext(m_tConfiguration, m_arrSourcePathsInfo, m_files, m_cfgTracker, m_log, spFeedbackHandler, m_workerThread, m_fsLocal), m_tSubTasksArray(), m_spSerializer(spSerializer), m_bWasSerialized(false) { - if(!piFeedbackHandler || !spSerializer) + if(!spFeedbackHandler || !spSerializer) THROW_CORE_EXCEPTION(eErr_InvalidPointer); } TTask::~TTask() { KillThread(); - if(m_piFeedbackHandler) - m_piFeedbackHandler->Delete(); } void TTask::SetTaskDefinition(const TTaskDefinition& rTaskDefinition) @@ -456,7 +454,7 @@ switch(eResult) { case TSubTaskBase::eSubResult_Error: - m_piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_OperationError, NULL); + m_spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_OperationError, NULL); SetTaskState(eTaskState_Error); break; @@ -475,7 +473,7 @@ break; case TSubTaskBase::eSubResult_Continue: - m_piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_OperationFinished, NULL); + m_spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_OperationFinished, NULL); SetTaskState(eTaskState_Finished); break; @@ -517,7 +515,7 @@ tProcessingGuard.PauseTimeTracking(); // let others know some error happened - m_piFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_OperationError, NULL); + m_spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_OperationError, NULL); SetTaskState(eTaskState_Error); SetContinueFlag(false); Index: src/libchcore/TTask.h =================================================================== diff -u -N -rb7655a8f0721e5454befd29e3e067748eb0521e9 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TTask.h (.../TTask.h) (revision b7655a8f0721e5454befd29e3e067748eb0521e9) +++ src/libchcore/TTask.h (.../TTask.h) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -21,7 +21,7 @@ #include "libchcore.h" #include "TWorkerThreadController.h" -#include "FeedbackHandlerBase.h" +#include "IFeedbackHandler.h" #include "TTaskDefinition.h" #include "TTaskConfigTracker.h" #include "TBasePathData.h" @@ -46,7 +46,7 @@ class LIBCHCORE_API TTask { private: - TTask(const ISerializerPtr& spSerializer, IFeedbackHandler* piFeedbackHandler); + TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler); public: ~TTask(); @@ -131,7 +131,9 @@ #pragma warning(push) #pragma warning(disable: 4251) ISerializerPtr m_spSerializer; + IFeedbackHandlerPtr m_spFeedbackHandler; #pragma warning(pop) + bool m_bWasSerialized; // base data @@ -188,9 +190,6 @@ mutable boost::shared_mutex m_lock; #pragma warning(pop) - /// Pointer to the feedback handler, providing responses to feedback requests - IFeedbackHandler* m_piFeedbackHandler; - friend class TTaskManager; }; Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -N -r30297d6aab17483da8e7b8323b4d17ff1a9f78d6 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 30297d6aab17483da8e7b8323b4d17ff1a9f78d6) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -31,13 +31,13 @@ //////////////////////////////////////////////////////////////////////////////// // TTaskManager members TTaskManager::TTaskManager(const ISerializerFactoryPtr& spSerializerFactory, - IFeedbackHandlerFactory* piFeedbackHandlerFactory, + const IFeedbackHandlerFactoryPtr& spFeedbackHandlerFactory, bool bForceRecreateSerializer) : m_stNextTaskID(NoTaskID + 1), m_spSerializerFactory(spSerializerFactory), - m_piFeedbackFactory(piFeedbackHandlerFactory) + m_spFeedbackFactory(spFeedbackHandlerFactory) { - if(!piFeedbackHandlerFactory || !spSerializerFactory) + if(!spFeedbackHandlerFactory || !spSerializerFactory) THROW_CORE_EXCEPTION(eErr_InvalidPointer); m_spSerializer = m_spSerializerFactory->CreateSerializer(ISerializerFactory::eObj_TaskManager, _T(""), bForceRecreateSerializer); } @@ -49,10 +49,10 @@ TTaskPtr TTaskManager::CreateTask(const TTaskDefinition& tTaskDefinition) { - IFeedbackHandler* piHandler = CreateNewFeedbackHandler(); + IFeedbackHandlerPtr spHandler = m_spFeedbackFactory->Create(); ISerializerPtr spSerializer = m_spSerializerFactory->CreateSerializer(ISerializerFactory::eObj_Task, tTaskDefinition.GetTaskName()); - TTaskPtr spTask(new TTask(spSerializer, piHandler)); + TTaskPtr spTask(new TTask(spSerializer, spHandler)); spTask->SetLogPath(CreateTaskLogPath(tTaskDefinition.GetTaskName())); spTask->SetTaskDefinition(tTaskDefinition); @@ -428,17 +428,6 @@ } } -IFeedbackHandler* TTaskManager::CreateNewFeedbackHandler() -{ - BOOST_ASSERT(m_piFeedbackFactory); - if(!m_piFeedbackFactory) - return NULL; - - IFeedbackHandler* piHandler = m_piFeedbackFactory->Create(); - - return piHandler; -} - void TTaskManager::Store() { ISerializerContainerPtr spContainer = m_spSerializer->GetContainer(_T("tasks")); @@ -475,10 +464,10 @@ if(!rEntry.GetTask()) { - IFeedbackHandler* piHandler = CreateNewFeedbackHandler(); + IFeedbackHandlerPtr spHandler = m_spFeedbackFactory->Create(); ISerializerPtr spSerializer(m_spSerializerFactory->CreateSerializer(ISerializerFactory::eObj_Task, rEntry.GetTaskSerializeLocation().ToWString())); - TTaskPtr spTask(new TTask(spSerializer, piHandler)); + TTaskPtr spTask(new TTask(spSerializer, spHandler)); spTask->Load(); rEntry.SetTask(spTask); Index: src/libchcore/TTaskManager.h =================================================================== diff -u -N -r30297d6aab17483da8e7b8323b4d17ff1a9f78d6 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision 30297d6aab17483da8e7b8323b4d17ff1a9f78d6) +++ src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -20,7 +20,7 @@ #define __TASKMANAGER_H__ #include "libchcore.h" -#include "FeedbackHandlerBase.h" +#include "IFeedbackHandlerFactory.h" #include "TPath.h" #include "TTaskManagerStatsSnapshot.h" #include "TTaskInfo.h" @@ -39,7 +39,7 @@ { public: TTaskManager(const ISerializerFactoryPtr& spSerializerFactory, - IFeedbackHandlerFactory* piFeedbackHandlerFactory, + const IFeedbackHandlerFactoryPtr& spFeedbackHandlerFactory, bool bForceRecreateSerializer = false); ~TTaskManager(); @@ -80,8 +80,6 @@ protected: void StopAllTasksNL(); - IFeedbackHandler* CreateNewFeedbackHandler(); - TSmartPath CreateTaskLogPath(const TString& strTaskUuid) const; private: @@ -95,9 +93,9 @@ TSmartPath m_pathLogDir; // config-based, not serializable taskid_t m_stNextTaskID; // serializable - IFeedbackHandlerFactory* m_piFeedbackFactory; #pragma warning(push) #pragma warning(disable: 4251) + IFeedbackHandlerFactoryPtr m_spFeedbackFactory; ISerializerPtr m_spSerializer; ISerializerFactoryPtr m_spSerializerFactory; #pragma warning(pop) Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -N -rb7655a8f0721e5454befd29e3e067748eb0521e9 -r458af7bf8c35950fdeb4b906950437596324aea1 --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision b7655a8f0721e5454befd29e3e067748eb0521e9) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 458af7bf8c35950fdeb4b906950437596324aea1) @@ -672,10 +672,6 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > - - @@ -1444,6 +1440,26 @@ + + + + + + + + + +