Index: src/ch/ClipboardMonitor.cpp =================================================================== diff -u -N -r8dd3566d66a35a662872eaaa45eef5049e71c3dc -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision 8dd3566d66a35a662872eaaa45eef5049e71c3dc) +++ src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -84,7 +84,7 @@ UINT nCount=DragQueryFile(static_cast(handle), 0xffffffff, NULL, 0); - TTaskDefinition tTaskDefinition; + chcore::TTaskDefinition tTaskDefinition; // list of files for(UINT stIndex = 0; stIndex < nCount; stIndex++) @@ -95,7 +95,7 @@ } // operation type - EOperationType eOperation = eOperation_Copy; + chcore::EOperationType eOperation = chcore::eOperation_Copy; if(IsClipboardFormatAvailable(nFormat)) { @@ -104,14 +104,14 @@ DWORD dwData=((DWORD*)addr)[0]; if(dwData & DROPEFFECT_COPY) - eOperation = eOperation_Copy; // copy + eOperation = chcore::eOperation_Copy; // copy else if(dwData & DROPEFFECT_MOVE) - eOperation = eOperation_Move; // move + eOperation = chcore::eOperation_Move; // move GlobalUnlock(handle); } else - eOperation = eOperation_Copy; // default - copy + eOperation = chcore::eOperation_Copy; // default - copy tTaskDefinition.SetOperationType(eOperation); // copy @@ -135,9 +135,9 @@ dlg.m_bdData.strInitialDir=(dlg.m_bdData.cvRecent.size() > 0) ? dlg.m_bdData.cvRecent.at(0) : _T(""); - if(eOperation == eOperation_Copy) + if(eOperation == chcore::eOperation_Copy) dlg.m_bdData.strCaption = GetResManager().LoadString(IDS_TITLECOPY_STRING); - else if(eOperation == eOperation_Move) + else if(eOperation == chcore::eOperation_Move) dlg.m_bdData.strCaption = GetResManager().LoadString(IDS_TITLEMOVE_STRING); else dlg.m_bdData.strCaption = GetResManager().LoadString(IDS_TITLEUNKNOWNOPERATION_STRING); Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -r8dd3566d66a35a662872eaaa45eef5049e71c3dc -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 8dd3566d66a35a662872eaaa45eef5049e71c3dc) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -551,7 +551,7 @@ } // create new task - TTaskDefinition tTaskDefinition; + chcore::TTaskDefinition tTaskDefinition; tTaskDefinition.SetDestinationPath(chcore::PathFromString(strDstPath)); // files @@ -560,7 +560,7 @@ tTaskDefinition.AddSourcePath(chcore::PathFromString(astrFiles.GetAt(i))); } - tTaskDefinition.SetOperationType(bMove ? eOperation_Move : eOperation_Copy); + tTaskDefinition.SetOperationType(bMove ? chcore::eOperation_Move : chcore::eOperation_Copy); // set the default options for task GetConfig().ExtractSubConfig(BRANCH_TASK_SETTINGS, tTaskDefinition.GetConfiguration()); @@ -633,7 +633,7 @@ // save recent paths dlg.m_ccData.m_vRecent.push_back((PCTSTR)dlg.m_ccData.m_strDestPath); - TTaskDefinition tTaskDefinition; + chcore::TTaskDefinition tTaskDefinition; for (int iIndex = 0; iIndex < dlg.m_ccData.m_astrPaths.GetSize(); iIndex++) { @@ -642,7 +642,7 @@ tTaskDefinition.SetDestinationPath(chcore::PathFromString(dlg.m_ccData.m_strDestPath)); - tTaskDefinition.SetOperationType((dlg.m_ccData.m_iOperation == 1) ? eOperation_Move : eOperation_Copy); + tTaskDefinition.SetOperationType((dlg.m_ccData.m_iOperation == 1) ? chcore::eOperation_Move : chcore::eOperation_Copy); // set the default options for task GetConfig().ExtractSubConfig(BRANCH_TASK_SETTINGS, tTaskDefinition.GetConfiguration()); Index: src/ch/StatusDlg.cpp =================================================================== diff -u -N -r33e0019aa01f9104d0127bad9dab6868d795114e -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision 33e0019aa01f9104d0127bad9dab6868d795114e) +++ src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -1016,13 +1016,13 @@ // second part - if(rTaskDisplayData.m_eSubOperationType == eSubOperation_Deleting) + if(rTaskDisplayData.m_eSubOperationType == chcore::eSubOperation_Deleting) strStatusText += GetResManager().LoadString(IDS_STATUS_DELETING_STRING); - else if(rTaskDisplayData.m_eSubOperationType == eSubOperation_Scanning) + else if(rTaskDisplayData.m_eSubOperationType == chcore::eSubOperation_Scanning) strStatusText += GetResManager().LoadString(IDS_STATUS_SEARCHING_STRING); - else if(rTaskDisplayData.m_eOperationType == eOperation_Copy) + else if(rTaskDisplayData.m_eOperationType == chcore::eOperation_Copy) strStatusText += GetResManager().LoadString(IDS_STATUS_COPYING_STRING); - else if(rTaskDisplayData.m_eOperationType == eOperation_Move) + else if(rTaskDisplayData.m_eOperationType == chcore::eOperation_Move) strStatusText += GetResManager().LoadString(IDS_STATUS_MOVING_STRING); else strStatusText += GetResManager().LoadString(IDS_STATUS_UNKNOWN_STRING); Index: src/ch/TSubTaskBase.cpp =================================================================== diff -u -N -r886c32a98f09ae8dc24ceb6b27e5c8a75104954e -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision 886c32a98f09ae8dc24ceb6b27e5c8a75104954e) +++ src/ch/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -25,7 +25,7 @@ #include "TBasePathData.h" #include "TLocalFilesystem.h" #include "TSubTaskContext.h" -#include "TTaskDefinition.h" +#include "../libchcore/TTaskDefinition.h" #include "TTaskConfiguration.h" /////////////////////////////////////////////////////////////////////////// @@ -108,7 +108,7 @@ // finds another name for a copy of src file(folder) in dest location chcore::TSmartPath TSubTaskBase::FindFreeSubstituteName(chcore::TSmartPath pathSrcPath, chcore::TSmartPath pathDstPath) const { - const TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); + const chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); // get the name from srcpath pathSrcPath.StripSeparatorAtEnd(); Index: src/ch/TSubTaskContext.cpp =================================================================== diff -u -N -r6e8aa26e2428e3bc71099255c5911f57bc722100 -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 6e8aa26e2428e3bc71099255c5911f57bc722100) +++ src/ch/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -23,7 +23,7 @@ #include "stdafx.h" #include "TSubTaskContext.h" -TSubTaskContext::TSubTaskContext(TTaskDefinition& rTaskDefinition, TBasePathDataContainer& rBasePathDataContainer, CFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, +TSubTaskContext::TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, TBasePathDataContainer& rBasePathDataContainer, CFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, TTaskBasicProgressInfo& rTaskBasicProgressInfo, TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, chcore::IFeedbackHandler* piFeedbackHandler, TWorkerThreadController& rThreadController) : m_rTaskDefinition(rTaskDefinition), m_rBasePathDataContainer(rBasePathDataContainer), Index: src/ch/TSubTaskContext.h =================================================================== diff -u -N -r6e8aa26e2428e3bc71099255c5911f57bc722100 -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/TSubTaskContext.h (.../TSubTaskContext.h) (revision 6e8aa26e2428e3bc71099255c5911f57bc722100) +++ src/ch/TSubTaskContext.h (.../TSubTaskContext.h) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -25,8 +25,12 @@ #include "FileInfo.h" -class TTaskDefinition; -namespace chcore { class IFeedbackHandler; } +namespace chcore +{ + class IFeedbackHandler; + class TTaskDefinition; +} + class TWorkerThreadController; class TBasePathDataContainer; class TTaskLocalStats; @@ -39,13 +43,13 @@ class TSubTaskContext { public: - TSubTaskContext(TTaskDefinition& rTaskDefinition, TBasePathDataContainer& rBasePathDataContainer, CFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, + TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, TBasePathDataContainer& rBasePathDataContainer, CFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, TTaskBasicProgressInfo& rTaskBasicProgressInfo, TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, chcore::IFeedbackHandler* piFeedbackHandler, TWorkerThreadController& rThreadController); ~TSubTaskContext(); - TTaskDefinition& GetTaskDefinition() { return m_rTaskDefinition; } - const TTaskDefinition& GetTaskDefinition() const { return m_rTaskDefinition; } + chcore::TTaskDefinition& GetTaskDefinition() { return m_rTaskDefinition; } + const chcore::TTaskDefinition& GetTaskDefinition() const { return m_rTaskDefinition; } TBasePathDataContainer& GetBasePathDataContainer() { return m_rBasePathDataContainer; } const TBasePathDataContainer& GetBasePathDataContainer() const { return m_rBasePathDataContainer; } @@ -72,7 +76,7 @@ const TWorkerThreadController& GetThreadController() const { return m_rThreadController; } private: - TTaskDefinition& m_rTaskDefinition; + chcore::TTaskDefinition& m_rTaskDefinition; // information about input paths TBasePathDataContainer& m_rBasePathDataContainer; Index: src/ch/TSubTaskCopyMove.cpp =================================================================== diff -u -N -r886c32a98f09ae8dc24ceb6b27e5c8a75104954e -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 886c32a98f09ae8dc24ceb6b27e5c8a75104954e) +++ src/ch/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -24,7 +24,7 @@ #include "TSubTaskCopyMove.h" #include "TSubTaskContext.h" #include "TTaskConfiguration.h" -#include "TTaskDefinition.h" +#include "../libchcore/TTaskDefinition.h" #include "task.h" #include "TLocalFilesystem.h" #include "FeedbackHandler.h" @@ -53,7 +53,7 @@ { icpf::log_file& rLog = GetContext().GetLog(); CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); - TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); + chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); @@ -132,7 +132,7 @@ // are the files/folders lie on the same partition ? int iDstDriveNumber = 0; - bool bMove = rTaskDefinition.GetOperationType() == eOperation_Move; + bool bMove = rTaskDefinition.GetOperationType() == chcore::eOperation_Move; if(bMove) TLocalFilesystem::GetDriveData(rTaskDefinition.GetDestinationPath(), &iDstDriveNumber, NULL); if(bMove && iDstDriveNumber != -1 && iDstDriveNumber == GetDriveNumber(spFileInfo) && GetMove(spFileInfo)) @@ -277,7 +277,7 @@ int TSubTaskCopyMove::GetBufferIndex(const CFileInfoPtr& spFileInfo) { TBasePathDataContainer& rSrcPathsInfo = GetContext().GetBasePathDataContainer(); - TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); + chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); if(!spFileInfo) THROW(_T("Invalid pointer"), 0, 0, 0); @@ -325,7 +325,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::CustomCopyFileFB(CUSTOM_COPY_PARAMS* pData) { - TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); + chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); TTaskLocalStats& rLocalStats = GetContext().GetTaskLocalStats(); Index: src/ch/TSubTaskDelete.cpp =================================================================== diff -u -N -ra3800c2f65fa66354e072b34c9e9970af49236b6 -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision a3800c2f65fa66354e072b34c9e9970af49236b6) +++ src/ch/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -26,7 +26,7 @@ #include "TBasicProgressInfo.h" #include "TWorkerThreadController.h" #include "TTaskConfiguration.h" -#include "TTaskDefinition.h" +#include "../libchcore/TTaskDefinition.h" #include "FeedbackHandler.h" #include "TLocalFilesystem.h" @@ -40,7 +40,7 @@ // log icpf::log_file& rLog = GetContext().GetLog(); CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); - TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); + chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); Index: src/ch/TSubTaskScanDirectory.cpp =================================================================== diff -u -N -r7749d67cd70821fef9cc51303d42625fbcc2aa9d -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 7749d67cd70821fef9cc51303d42625fbcc2aa9d) +++ src/ch/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -24,7 +24,7 @@ #include "TSubTaskScanDirectory.h" #include "TSubTaskContext.h" #include "TTaskConfiguration.h" -#include "TTaskDefinition.h" +#include "../libchcore/TTaskDefinition.h" #include "FeedbackHandler.h" #include "TLocalFilesystem.h" #include "..\libchcore\FeedbackHandlerBase.h" @@ -46,7 +46,7 @@ // log icpf::log_file& rLog = GetContext().GetLog(); CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); - TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); + chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); const TBasePathDataContainer& rarrSourcePathsInfo = GetContext().GetBasePathDataContainer(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); @@ -66,7 +66,7 @@ bool bIgnoreDirs = GetTaskPropValue(rTaskDefinition.GetConfiguration()); bool bForceDirectories = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bool bMove = rTaskDefinition.GetOperationType() == eOperation_Move; + bool bMove = rTaskDefinition.GetOperationType() == chcore::eOperation_Move; // add everything ictranslate::CFormat fmt; @@ -215,7 +215,7 @@ int TSubTaskScanDirectories::ScanDirectory(chcore::TSmartPath pathDirName, size_t stSrcIndex, bool bRecurse, bool bIncludeDirs, CFiltersArray& afFilters) { CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); - TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); + chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); TLocalFilesystemFind finder = TLocalFilesystem::CreateFinderObject(pathDirName, chcore::PathFromString(_T("*"))); Index: src/ch/ch.vc90.vcproj =================================================================== diff -u -N -r8dd3566d66a35a662872eaaa45eef5049e71c3dc -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision 8dd3566d66a35a662872eaaa45eef5049e71c3dc) +++ src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -515,22 +515,6 @@ > - - - - - - - - Index: src/ch/task.cpp =================================================================== diff -u -N -r8dd3566d66a35a662872eaaa45eef5049e71c3dc -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/task.cpp (.../task.cpp) (revision 8dd3566d66a35a662872eaaa45eef5049e71c3dc) +++ src/ch/task.cpp (.../task.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -62,7 +62,7 @@ m_piFeedbackHandler->Delete(); } -void CTask::SetTaskDefinition(const TTaskDefinition& rTaskDefinition) +void CTask::SetTaskDefinition(const chcore::TTaskDefinition& rTaskDefinition) { m_tTaskDefinition = rTaskDefinition; @@ -143,7 +143,7 @@ //////////////////////////////// // First load task description - m_tTaskDefinition.Load(strPath); + m_tTaskDefinition.Load((PCTSTR)strPath); m_strFilePath = strPath; // update members according to the task definition @@ -207,11 +207,11 @@ if(m_strFilePath.IsEmpty()) { boost::upgrade_to_unique_lock upgraded_lock(lock); - m_strFilePath = m_strTaskDirectory + m_tTaskDefinition.GetTaskUniqueID() + _T(".cht"); + m_strFilePath = m_strTaskDirectory + m_tTaskDefinition.GetTaskUniqueID().c_str() + _T(".cht"); } // store task definition only if changed - m_tTaskDefinition.Store(GetRelatedPathNL(ePathType_TaskDefinition), true); + m_tTaskDefinition.Store((PCTSTR)GetRelatedPathNL(ePathType_TaskDefinition), true); // rarely changing data if(m_bRareStateModified) @@ -242,8 +242,8 @@ m_arrSourcePathsInfo.Store(ar, 0, false); - ESubOperationType eSubOperation = m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(m_tTaskBasicProgressInfo.GetSubOperationIndex()); - if(eSubOperation != eSubOperation_Scanning) + chcore::ESubOperationType eSubOperation = m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(m_tTaskBasicProgressInfo.GetSubOperationIndex()); + if(eSubOperation != chcore::eSubOperation_Scanning) m_files.Store(ar, 0, true); else { @@ -389,7 +389,7 @@ pData->m_ullProcessedSize = m_localStats.GetProcessedSize(); pData->m_stSize=m_files.GetSize(); pData->m_ullSizeAll = m_localStats.GetTotalSize(); - pData->m_strUniqueName = m_tTaskDefinition.GetTaskUniqueID(); + pData->m_strUniqueName = m_tTaskDefinition.GetTaskUniqueID().c_str(); pData->m_eOperationType = m_tTaskDefinition.GetOperationType(); pData->m_eSubOperationType = m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(m_tTaskBasicProgressInfo.GetSubOperationIndex()); @@ -678,7 +678,7 @@ // wait for permission to really start (but only if search for files is not allowed to start regardless of the lock) size_t stSubOperationIndex = m_tTaskBasicProgressInfo.GetSubOperationIndex(); - if(!bReadTasksSize || stSubOperationIndex != 0 || m_tTaskDefinition.GetOperationPlan().GetSubOperationsCount() == 0 || m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(0) != eSubOperation_Scanning) + if(!bReadTasksSize || stSubOperationIndex != 0 || m_tTaskDefinition.GetOperationPlan().GetSubOperationsCount() == 0 || m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(0) != chcore::eSubOperation_Scanning) eResult = CheckForWaitState(); // operation limiting // start tracking time for this thread @@ -692,10 +692,10 @@ // set current sub-operation index to allow resuming m_tTaskBasicProgressInfo.SetSubOperationIndex(stSubOperationIndex); - ESubOperationType eSubOperation = m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(stSubOperationIndex); + chcore::ESubOperationType eSubOperation = m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(stSubOperationIndex); switch(eSubOperation) { - case eSubOperation_Scanning: + case chcore::eSubOperation_Scanning: { // get rid of info about processed sizes m_localStats.SetProcessedSize(0); @@ -723,15 +723,15 @@ break; } - case eSubOperation_Copying: + case chcore::eSubOperation_Copying: { TSubTaskCopyMove tSubTaskCopyMove(tSubTaskContext); eResult = tSubTaskCopyMove.Exec(); break; } - case eSubOperation_Deleting: + case chcore::eSubOperation_Deleting: { TSubTaskDelete tSubTaskDelete(tSubTaskContext); eResult = tSubTaskDelete.Exec(); @@ -786,7 +786,7 @@ // perform cleanup dependent on currently executing subtask switch(m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(m_tTaskBasicProgressInfo.GetSubOperationIndex())) { - case eSubOperation_Scanning: + case chcore::eSubOperation_Scanning: m_files.Clear(); // get rid of m_files contents m_bRareStateModified = true; break; @@ -890,7 +890,7 @@ // in all cases we would like to have task definition path defined CString strFilePath = m_strFilePath; if(strFilePath.IsEmpty()) - strFilePath = m_strTaskDirectory + m_tTaskDefinition.GetTaskUniqueID() + _T(".cht"); + strFilePath = m_strTaskDirectory + m_tTaskDefinition.GetTaskUniqueID().c_str() + _T(".cht"); switch(ePathType) { @@ -943,7 +943,7 @@ m_piFeedbackFactory = piFeedbackHandlerFactory; } -CTaskPtr CTaskArray::CreateTask(const TTaskDefinition& tTaskDefinition) +CTaskPtr CTaskArray::CreateTask(const chcore::TTaskDefinition& tTaskDefinition) { CTaskPtr spTask = CreateEmptyTask(); if(spTask) @@ -959,8 +959,8 @@ CTaskPtr CTaskArray::ImportTask(const CString& strTaskPath) { // load task definition from the new location - TTaskDefinition tTaskDefinition; - tTaskDefinition.Load(strTaskPath); + chcore::TTaskDefinition tTaskDefinition; + tTaskDefinition.Load((PCTSTR)strTaskPath); return CreateTask(tTaskDefinition); } Index: src/ch/task.h =================================================================== diff -u -N -r8dd3566d66a35a662872eaaa45eef5049e71c3dc -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/ch/task.h (.../task.h) (revision 8dd3566d66a35a662872eaaa45eef5049e71c3dc) +++ src/ch/task.h (.../task.h) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -25,7 +25,7 @@ #include "DataBuffer.h" #include "../libchcore/FeedbackHandlerBase.h" #include "FileFilter.h" -#include "TTaskDefinition.h" +#include "../libchcore/TTaskDefinition.h" #include "TTaskConfigTracker.h" #include "TBasePathData.h" #include "TSubTaskBase.h" @@ -66,8 +66,8 @@ CFiltersArray* m_pafFilters; ETaskCurrentState m_eTaskState; - EOperationType m_eOperationType; - ESubOperationType m_eSubOperationType; + chcore::EOperationType m_eOperationType; + chcore::ESubOperationType m_eSubOperationType; int m_nPriority; @@ -109,7 +109,7 @@ public: ~CTask(); - const TTaskDefinition& GetTaskDefinition() const { return m_tTaskDefinition; } + const chcore::TTaskDefinition& GetTaskDefinition() const { return m_tTaskDefinition; } void SetTaskState(ETaskCurrentState eTaskState); ETaskCurrentState GetTaskState() const; @@ -152,7 +152,7 @@ protected: CTask(chcore::IFeedbackHandler* piFeedbackHandler, size_t stSessionUniqueID); - void SetTaskDefinition(const TTaskDefinition& rTaskDefinition); + void SetTaskDefinition(const chcore::TTaskDefinition& rTaskDefinition); // methods are called when task is being added or removed from the global task array /// Method is called when this task is being added to a CTaskArray object @@ -210,7 +210,7 @@ private: // task initial information (needed to start a task); might be a bit processed. - TTaskDefinition m_tTaskDefinition; + chcore::TTaskDefinition m_tTaskDefinition; TTaskConfigTracker m_cfgTracker; @@ -270,7 +270,7 @@ void Create(chcore::IFeedbackHandlerFactory* piFeedbackHandlerFactory); - CTaskPtr CreateTask(const TTaskDefinition& tTaskDefinition); + CTaskPtr CreateTask(const chcore::TTaskDefinition& tTaskDefinition); CTaskPtr ImportTask(const CString& strTaskPath); size_t GetSize() const; Index: src/libchcore/ErrorCodes.h =================================================================== diff -u -N -rfbaf42c9e8bd741fce57c1c14f49ffe5ef1304ce -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/libchcore/ErrorCodes.h (.../ErrorCodes.h) (revision fbaf42c9e8bd741fce57c1c14f49ffe5ef1304ce) +++ src/libchcore/ErrorCodes.h (.../ErrorCodes.h) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -26,7 +26,11 @@ enum EGeneralErrors { eNoError = 0, - eBoundsExceeded = 1 + eBoundsExceeded = 1, + eInvalidArgument = 2, + eUnhandledCase = 3, + eMissingData = 4, + eUnsupportedVersion = 5, }; END_CHCORE_NAMESPACE Index: src/libchcore/TCoreException.cpp =================================================================== diff -u -N -r39db7f4bffdd185122d8dab0772bd6fc49a0b675 -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/libchcore/TCoreException.cpp (.../TCoreException.cpp) (revision 39db7f4bffdd185122d8dab0772bd6fc49a0b675) +++ src/libchcore/TCoreException.cpp (.../TCoreException.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -33,6 +33,7 @@ m_eErrorCode(eErrorCode), m_strInternalMessage(pszInternalError ? pszInternalError : _t("")) { + BOOST_ASSERT(false); } // ============================================================================ @@ -53,6 +54,7 @@ m_strLineNumber(stLineNumber), m_strFunction(pszFunction ? pszFunction : _t("")) { + BOOST_ASSERT(false); } END_CHCORE_NAMESPACE Index: src/libchcore/TTaskDefinition.cpp =================================================================== diff -u -N --- src/libchcore/TTaskDefinition.cpp (revision 0) +++ src/libchcore/TTaskDefinition.cpp (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -0,0 +1,251 @@ +// ============================================================================ +// Copyright (C) 2001-2011 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. +// ============================================================================ +/// @file TTaskDefinition.cpp +/// @date 2010/09/18 +/// @brief Contains implementation of class representing task input data. +// ============================================================================ +#include "stdafx.h" +#include "..\common\version.h" +#include +#include +#include +#include +#include "TTaskDefinition.h" + +#define CURRENT_TASK_VERSION (((unsigned long long)PRODUCT_VERSION1) << 48 | ((unsigned long long)PRODUCT_VERSION2) << 32 | ((unsigned long long)PRODUCT_VERSION3) << 16 | ((unsigned long long)PRODUCT_VERSION4)) + +BEGIN_CHCORE_NAMESPACE + +TTaskDefinition::TTaskDefinition() : + m_bModified(false), + m_strTaskUniqueID(), + m_ullTaskVersion(CURRENT_TASK_VERSION) +{ + boost::uuids::random_generator gen; + boost::uuids::uuid u = gen(); + m_strTaskUniqueID = boost::lexical_cast(u).c_str(); +} + +TTaskDefinition::TTaskDefinition(const TTaskDefinition& rSrc) : + m_strTaskUniqueID(rSrc.m_strTaskUniqueID), + m_vSourcePaths(rSrc.m_vSourcePaths), + m_pathDestinationPath(rSrc.m_pathDestinationPath), + m_tOperationPlan(rSrc.m_tOperationPlan), + m_ullTaskVersion(rSrc.m_ullTaskVersion), + m_tConfiguration(rSrc.m_tConfiguration), + m_bModified(rSrc.m_bModified) +{ +} + +TTaskDefinition::~TTaskDefinition() +{ +} + +TTaskDefinition& TTaskDefinition::operator=(const TTaskDefinition& rSrc) +{ + if(this != &rSrc) + { + m_strTaskUniqueID = rSrc.m_strTaskUniqueID; + m_vSourcePaths = rSrc.m_vSourcePaths; + m_pathDestinationPath = rSrc.m_pathDestinationPath; + m_tOperationPlan = rSrc.m_tOperationPlan; + m_ullTaskVersion = rSrc.m_ullTaskVersion; + m_tConfiguration = rSrc.m_tConfiguration; + m_bModified = rSrc.m_bModified; + } + + return *this; +} + +// Task unique id +std::wstring TTaskDefinition::GetTaskUniqueID() const +{ + return m_strTaskUniqueID; +} + +// Source paths +// initialize object with data (get/set, from cfg file?, from string(cmd line options)) +void TTaskDefinition::AddSourcePath(const chcore::TSmartPath& tPath) +{ + m_vSourcePaths.Add(tPath); + m_bModified = true; +} + +chcore::TSmartPath TTaskDefinition::GetSourcePathAt(size_t stIndex) const +{ + return m_vSourcePaths.GetAt(stIndex); +} + +size_t TTaskDefinition::GetSourcePathCount() const +{ + return m_vSourcePaths.GetCount(); +} + +void TTaskDefinition::ClearSourcePaths() +{ + m_vSourcePaths.Clear(); + m_bModified = true; +} + +const chcore::TPathContainer& TTaskDefinition::GetSourcePaths() const +{ + return m_vSourcePaths; +} + +// Destination path +void TTaskDefinition::SetDestinationPath(const chcore::TSmartPath& pathDestination) +{ + m_pathDestinationPath = pathDestination; + m_pathDestinationPath.AppendSeparatorIfDoesNotExist(); + m_bModified = true; +} + +chcore::TSmartPath TTaskDefinition::GetDestinationPath() const +{ + return m_pathDestinationPath; +} + +// Operation type +void TTaskDefinition::SetOperationType(EOperationType eOperation) +{ + m_tOperationPlan.SetOperationType(eOperation); + m_bModified = true; +} + +EOperationType TTaskDefinition::GetOperationType() const +{ + return m_tOperationPlan.GetOperationType(); +} + +const TOperationPlan& TTaskDefinition::GetOperationPlan() const +{ + return m_tOperationPlan; +} + +// Task configuration +void TTaskDefinition::SetConfig(const chcore::TConfig& rConfig) +{ + m_tConfiguration = rConfig; + m_bModified = true; +} + +chcore::TConfig& TTaskDefinition::GetConfiguration() +{ + return m_tConfiguration; +} + +const chcore::TConfig& TTaskDefinition::GetConfiguration() const +{ + return m_tConfiguration; +} + +// Serialization +void TTaskDefinition::Load(const std::wstring& strPath) +{ + // read everything + chcore::TConfig tTaskInfo; + tTaskInfo.Read(strPath.c_str()); + + // clear everything + m_strTaskUniqueID.clear(); + m_vSourcePaths.Clear(); + m_pathDestinationPath.Clear(); + + m_tConfiguration.Clear(); + + m_bModified = false; + + // get information from config file + // task unique id - use if provided, generate otherwise + if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.UniqueID"), m_strTaskUniqueID) || m_strTaskUniqueID.empty()) + { + boost::uuids::random_generator gen; + boost::uuids::uuid u = gen(); + m_strTaskUniqueID = boost::lexical_cast(u).c_str(); + + m_bModified = true; + } + + // basic information + // source paths to be processed + if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.SourcePaths"), m_vSourcePaths) || m_vSourcePaths.IsEmpty()) + THROW_CORE_EXCEPTION_STR(eMissingData, _T("Missing source paths")); + + // destination path + if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.DestinationPath"), m_pathDestinationPath) || m_pathDestinationPath.IsEmpty()) + THROW_CORE_EXCEPTION_STR(eMissingData, _T("Missing destination path")); + + m_pathDestinationPath.AppendSeparatorIfDoesNotExist(); + + // type of the operation + int iOperation = eOperation_None; + if(!tTaskInfo.GetValue(_T("TaskDefinition.OperationType"), iOperation)) + THROW_CORE_EXCEPTION_STR(eMissingData, _T("Missing operation type")); + + m_tOperationPlan.SetOperationType((EOperationType)iOperation); + + // and version of the task + if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.Version"), m_ullTaskVersion)) + THROW_CORE_EXCEPTION_STR(eMissingData, _T("Missing task definition version")); + + if(m_ullTaskVersion < CURRENT_TASK_VERSION) + { + // migrate the task to the newer version + // (nothing to migrate at this point, since 1.40 is the first release with xml-based tasks). + + // then mark it as a newest version task + m_ullTaskVersion = CURRENT_TASK_VERSION; + m_bModified = true; + } + else if(m_ullTaskVersion > CURRENT_TASK_VERSION) + THROW_CORE_EXCEPTION_STR(eUnsupportedVersion, _T("Unsupported task version")); + + tTaskInfo.ExtractSubConfig(_T("TaskDefinition.TaskSettings"), m_tConfiguration); +} + +void TTaskDefinition::Store(const std::wstring& strPath, bool bOnlyIfModified) +{ + if(!bOnlyIfModified || m_bModified || m_tConfiguration.IsModified()) + { + // read everything + chcore::TConfig tTaskInfo; + tTaskInfo.SetFilePath(strPath.c_str()); + + // get information from config file + // task unique id - use if provided, generate otherwise + SetConfigValue(tTaskInfo, _T("TaskDefinition.UniqueID"), m_strTaskUniqueID); + + // basic information + SetConfigValue(tTaskInfo, _T("TaskDefinition.SourcePaths.Path"), m_vSourcePaths); + SetConfigValue(tTaskInfo, _T("TaskDefinition.DestinationPath"), m_pathDestinationPath); + + int iOperation = m_tOperationPlan.GetOperationType(); + SetConfigValue(tTaskInfo, _T("TaskDefinition.OperationType"), iOperation); + + SetConfigValue(tTaskInfo, _T("TaskDefinition.Version"), m_ullTaskVersion); + + tTaskInfo.PutSubConfig(_T("TaskDefinition.TaskSettings"), m_tConfiguration); + + tTaskInfo.Write(); + + m_bModified = false; + } +} + +END_CHCORE_NAMESPACE Index: src/ch/TTaskDefinition.cpp =================================================================== diff -u -N --- src/ch/TTaskDefinition.cpp (revision 8dd3566d66a35a662872eaaa45eef5049e71c3dc) +++ src/ch/TTaskDefinition.cpp (revision 0) @@ -1,245 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2009 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. -// ============================================================================ -/// @file TTaskDefinition.cpp -/// @date 2010/09/18 -/// @brief Contains implementation of class representing task input data. -// ============================================================================ -#include "stdafx.h" -#include "..\common\version.h" -#include -#include -#include -#include -#include "TTaskDefinition.h" - -#define CURRENT_TASK_VERSION (((unsigned long long)PRODUCT_VERSION1) << 48 | ((unsigned long long)PRODUCT_VERSION2) << 32 | ((unsigned long long)PRODUCT_VERSION3) << 16 | ((unsigned long long)PRODUCT_VERSION4)) - -TTaskDefinition::TTaskDefinition() : - m_bModified(false), - m_strTaskUniqueID(), - m_ullTaskVersion(CURRENT_TASK_VERSION) -{ - boost::uuids::random_generator gen; - boost::uuids::uuid u = gen(); - m_strTaskUniqueID = boost::lexical_cast(u).c_str(); -} - -TTaskDefinition::TTaskDefinition(const TTaskDefinition& rSrc) : - m_strTaskUniqueID(rSrc.m_strTaskUniqueID), - m_vSourcePaths(rSrc.m_vSourcePaths), - m_pathDestinationPath(rSrc.m_pathDestinationPath), - m_tOperationPlan(rSrc.m_tOperationPlan), - m_ullTaskVersion(rSrc.m_ullTaskVersion), - m_tConfiguration(rSrc.m_tConfiguration), - m_bModified(rSrc.m_bModified) -{ -} - -TTaskDefinition::~TTaskDefinition() -{ -} - -TTaskDefinition& TTaskDefinition::operator=(const TTaskDefinition& rSrc) -{ - if(this != &rSrc) - { - m_strTaskUniqueID = rSrc.m_strTaskUniqueID; - m_vSourcePaths = rSrc.m_vSourcePaths; - m_pathDestinationPath = rSrc.m_pathDestinationPath; - m_tOperationPlan = rSrc.m_tOperationPlan; - m_ullTaskVersion = rSrc.m_ullTaskVersion; - m_tConfiguration = rSrc.m_tConfiguration; - m_bModified = rSrc.m_bModified; - } - - return *this; -} - -// Task unique id -CString TTaskDefinition::GetTaskUniqueID() const -{ - return m_strTaskUniqueID; -} - -// Source paths -// initialize object with data (get/set, from cfg file?, from string(cmd line options)) -void TTaskDefinition::AddSourcePath(const chcore::TSmartPath& tPath) -{ - m_vSourcePaths.Add(tPath); - m_bModified = true; -} - -chcore::TSmartPath TTaskDefinition::GetSourcePathAt(size_t stIndex) const -{ - return m_vSourcePaths.GetAt(stIndex); -} - -size_t TTaskDefinition::GetSourcePathCount() const -{ - return m_vSourcePaths.GetCount(); -} - -void TTaskDefinition::ClearSourcePaths() -{ - m_vSourcePaths.Clear(); - m_bModified = true; -} - -const chcore::TPathContainer& TTaskDefinition::GetSourcePaths() const -{ - return m_vSourcePaths; -} - -// Destination path -void TTaskDefinition::SetDestinationPath(const chcore::TSmartPath& pathDestination) -{ - m_pathDestinationPath = pathDestination; - m_pathDestinationPath.AppendSeparatorIfDoesNotExist(); - m_bModified = true; -} - -chcore::TSmartPath TTaskDefinition::GetDestinationPath() const -{ - return m_pathDestinationPath; -} - -// Operation type -void TTaskDefinition::SetOperationType(EOperationType eOperation) -{ - m_tOperationPlan.SetOperationType(eOperation); - m_bModified = true; -} - -EOperationType TTaskDefinition::GetOperationType() const -{ - return m_tOperationPlan.GetOperationType(); -} - -const TOperationPlan& TTaskDefinition::GetOperationPlan() const -{ - return m_tOperationPlan; -} - -// Task configuration -void TTaskDefinition::SetConfig(const chcore::TConfig& rConfig) -{ - m_tConfiguration = rConfig; - m_bModified = true; -} - -chcore::TConfig& TTaskDefinition::GetConfiguration() -{ - return m_tConfiguration; -} - -const chcore::TConfig& TTaskDefinition::GetConfiguration() const -{ - return m_tConfiguration; -} - -// Serialization -void TTaskDefinition::Load(const CString& strPath) -{ - // read everything - chcore::TConfig tTaskInfo; - tTaskInfo.Read(strPath); - - // clear everything - m_strTaskUniqueID.Empty(); - m_vSourcePaths.Clear(); - m_pathDestinationPath.Clear(); - - m_tConfiguration.Clear(); - - m_bModified = false; - - // get information from config file - // task unique id - use if provided, generate otherwise - if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.UniqueID"), m_strTaskUniqueID) || m_strTaskUniqueID.IsEmpty()) - { - boost::uuids::random_generator gen; - boost::uuids::uuid u = gen(); - m_strTaskUniqueID = boost::lexical_cast(u).c_str(); - - m_bModified = true; - } - - // basic information - // source paths to be processed - if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.SourcePaths"), m_vSourcePaths) || m_vSourcePaths.IsEmpty()) - THROW(_T("Missing source paths"), 0, 0, 0); - - // destination path - if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.DestinationPath"), m_pathDestinationPath) || m_pathDestinationPath.IsEmpty()) - THROW(_T("Missing destination path"), 0, 0, 0); - - m_pathDestinationPath.AppendSeparatorIfDoesNotExist(); - - // type of the operation - int iOperation = eOperation_None; - if(!tTaskInfo.GetValue(_T("TaskDefinition.OperationType"), iOperation)) - THROW(_T("Missing operation type"), 0, 0, 0); - - m_tOperationPlan.SetOperationType((EOperationType)iOperation); - - // and version of the task - if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.Version"), m_ullTaskVersion)) - THROW(_T("Missing task definition version"), 0, 0, 0); - - if(m_ullTaskVersion < CURRENT_TASK_VERSION) - { - // migrate the task to the newer version - // (nothing to migrate at this point, since 1.40 is the first release with xml-based tasks). - - // then mark it as a newest version task - m_ullTaskVersion = CURRENT_TASK_VERSION; - m_bModified = true; - } - else if(m_ullTaskVersion > CURRENT_TASK_VERSION) - THROW(_T("Unsupported task version"), 0, 0, 0); - - tTaskInfo.ExtractSubConfig(_T("TaskDefinition.TaskSettings"), m_tConfiguration); -} - -void TTaskDefinition::Store(const CString& strPath, bool bOnlyIfModified) -{ - if(!bOnlyIfModified || m_bModified || m_tConfiguration.IsModified()) - { - // read everything - chcore::TConfig tTaskInfo; - tTaskInfo.SetFilePath(strPath); - - // get information from config file - // task unique id - use if provided, generate otherwise - SetConfigValue(tTaskInfo, _T("TaskDefinition.UniqueID"), m_strTaskUniqueID); - - // basic information - SetConfigValue(tTaskInfo, _T("TaskDefinition.SourcePaths.Path"), m_vSourcePaths); - SetConfigValue(tTaskInfo, _T("TaskDefinition.DestinationPath"), m_pathDestinationPath); - - int iOperation = m_tOperationPlan.GetOperationType(); - SetConfigValue(tTaskInfo, _T("TaskDefinition.OperationType"), iOperation); - - tTaskInfo.PutSubConfig(_T("TaskDefinition.TaskSettings"), m_tConfiguration); - - tTaskInfo.Write(); - - m_bModified = false; - } -} Index: src/libchcore/TTaskDefinition.h =================================================================== diff -u -N --- src/libchcore/TTaskDefinition.h (revision 0) +++ src/libchcore/TTaskDefinition.h (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -0,0 +1,94 @@ +// ============================================================================ +// Copyright (C) 2001-2009 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. +// ============================================================================ +/// @file TTaskDefinition.h +/// @date 2010/09/18 +/// @brief Contains declaration of class representing task input data. +// ============================================================================ +#ifndef __TTASKDEFINITION_H__ +#define __TTASKDEFINITION_H__ + +#include "TTaskOperationPlan.h" +#include "TConfig.h" +#include "TPath.h" + +BEGIN_CHCORE_NAMESPACE + +/////////////////////////////////////////////////////////////////////////// +// TTaskDefinition + +class LIBCHCORE_API TTaskDefinition +{ +public: + TTaskDefinition(); + TTaskDefinition(const TTaskDefinition& rSrc); + ~TTaskDefinition(); + + TTaskDefinition& operator=(const TTaskDefinition& rSrc); + + // Task unique ID + std::wstring GetTaskUniqueID() const; + + // Source paths + void AddSourcePath(const chcore::TSmartPath& tPath); + chcore::TSmartPath GetSourcePathAt(size_t stIndex) const; + size_t GetSourcePathCount() const; + const chcore::TPathContainer& GetSourcePaths() const; + + void ClearSourcePaths(); + + // Destination path + void SetDestinationPath(const chcore::TSmartPath& pathDestination); + chcore::TSmartPath GetDestinationPath() const; + + // Operation type + void SetOperationType(EOperationType eOperation); + EOperationType GetOperationType() const; + const TOperationPlan& GetOperationPlan() const; + + // Task configuration + void SetConfig(const chcore::TConfig& rConfig); + chcore::TConfig& GetConfiguration(); + const chcore::TConfig& GetConfiguration() const; + + // Serialization + void Load(const std::wstring& strPath); + void Store(const std::wstring& strPath, bool bOnlyIfModified = false); + +private: + std::wstring m_strTaskUniqueID; ///< Unique ID of the task that will process this request (generated automatically) + + // basic information + chcore::TPathContainer m_vSourcePaths; + chcore::TSmartPath m_pathDestinationPath; + + TOperationPlan m_tOperationPlan; ///< Describes the operation along with sub-operations to be performed on the task input data + + // Task version + unsigned long long m_ullTaskVersion; + + // Global task settings + chcore::TConfig m_tConfiguration; + + // Other info (volatile, not to be saved to xml) + mutable bool m_bModified; ///< Some parameters has been modified and this object needs to be serialized again +}; + +END_CHCORE_NAMESPACE + +#endif // __TTASKDEFINITION_H__ Index: src/ch/TTaskDefinition.h =================================================================== diff -u -N --- src/ch/TTaskDefinition.h (revision 8dd3566d66a35a662872eaaa45eef5049e71c3dc) +++ src/ch/TTaskDefinition.h (revision 0) @@ -1,90 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2009 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. -// ============================================================================ -/// @file TTaskDefinition.h -/// @date 2010/09/18 -/// @brief Contains declaration of class representing task input data. -// ============================================================================ -#ifndef __TTASKDEFINITION_H__ -#define __TTASKDEFINITION_H__ - -#include "TTaskOperationPlan.h" -#include "../libchcore/TConfig.h" -#include "FileInfo.h" - -/////////////////////////////////////////////////////////////////////////// -// TTaskDefinition - -class TTaskDefinition -{ -public: - TTaskDefinition(); - TTaskDefinition(const TTaskDefinition& rSrc); - ~TTaskDefinition(); - - TTaskDefinition& operator=(const TTaskDefinition& rSrc); - - // Task unique ID - CString GetTaskUniqueID() const; - - // Source paths - void AddSourcePath(const chcore::TSmartPath& tPath); - chcore::TSmartPath GetSourcePathAt(size_t stIndex) const; - size_t GetSourcePathCount() const; - const chcore::TPathContainer& GetSourcePaths() const; - - void ClearSourcePaths(); - - // Destination path - void SetDestinationPath(const chcore::TSmartPath& pathDestination); - chcore::TSmartPath GetDestinationPath() const; - - // Operation type - void SetOperationType(EOperationType eOperation); - EOperationType GetOperationType() const; - const TOperationPlan& GetOperationPlan() const; - - // Task configuration - void SetConfig(const chcore::TConfig& rConfig); - chcore::TConfig& GetConfiguration(); - const chcore::TConfig& GetConfiguration() const; - - // Serialization - void Load(const CString& strPath); - void Store(const CString& strPath, bool bOnlyIfModified = false); - -private: - CString m_strTaskUniqueID; ///< Unique ID of the task that will process this request (generated automatically) - - // basic information - chcore::TPathContainer m_vSourcePaths; - chcore::TSmartPath m_pathDestinationPath; - - TOperationPlan m_tOperationPlan; ///< Describes the operation along with sub-operations to be performed on the task input data - - // Task version - unsigned long long m_ullTaskVersion; - - // Global task settings - chcore::TConfig m_tConfiguration; - - // Other info (volatile, not to be saved to xml) - mutable bool m_bModified; ///< Some parameters has been modified and this object needs to be serialized again -}; - -#endif // __TTASKDEFINITION_H__ Index: src/libchcore/TTaskOperationPlan.cpp =================================================================== diff -u -N --- src/libchcore/TTaskOperationPlan.cpp (revision 0) +++ src/libchcore/TTaskOperationPlan.cpp (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -0,0 +1,130 @@ +// ============================================================================ +// Copyright (C) 2001-2009 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. +// ============================================================================ +/// @file TTaskOperationPlan.cpp +/// @date 2010/09/18 +/// @brief File contains implementation of class handling planning of the entire operation +// ============================================================================ +#include "stdafx.h" +#include "TTaskOperationPlan.h" + +BEGIN_CHCORE_NAMESPACE + +//////////////////////////////////////////////////////////////////////////// +// class TOperationPlan + +TOperationPlan::TOperationPlan() : + m_eOperation(eOperation_None) +{ +} + +TOperationPlan::TOperationPlan(const TOperationPlan& rSrc) : +m_eOperation(eOperation_None), + m_vSubOperations() +{ + boost::shared_lock src_lock(rSrc.m_lock); + + m_eOperation = rSrc.m_eOperation; + m_vSubOperations = rSrc.m_vSubOperations; +} + +TOperationPlan::~TOperationPlan() +{ +} + +TOperationPlan& TOperationPlan::operator=(const TOperationPlan& rSrc) +{ + if(this != &rSrc) + { + boost::shared_lock src_lock(rSrc.m_lock); + boost::unique_lock lock(m_lock); + + m_eOperation = rSrc.m_eOperation; + m_vSubOperations = rSrc.m_vSubOperations; + } + + return *this; +} + +void TOperationPlan::SetOperationType(EOperationType eOperation) +{ + switch(eOperation) + { + case eOperation_None: + THROW_CORE_EXCEPTION_STR(eInvalidArgument, _T("Cannot set operation type 'none'")); + break; + + case eOperation_Copy: + { + boost::unique_lock lock(m_lock); + m_vSubOperations.clear(); + m_vSubOperations.push_back(std::make_pair(eSubOperation_Scanning, 0.05)); + m_vSubOperations.push_back(std::make_pair(eSubOperation_Copying, 0.95)); + break; + } + + case eOperation_Move: + { + boost::unique_lock lock(m_lock); + m_vSubOperations.clear(); + m_vSubOperations.push_back(std::make_pair(eSubOperation_Scanning, 0.05)); + m_vSubOperations.push_back(std::make_pair(eSubOperation_Copying, 0.90)); + m_vSubOperations.push_back(std::make_pair(eSubOperation_Deleting, 0.05)); + break; + } + + BOOST_STATIC_ASSERT(eOperation_Move == eOperation_Max - 1); + + default: + THROW_CORE_EXCEPTION_STR(eUnhandledCase, _T("Unhandled case")); + } + + m_eOperation = eOperation; +} + +EOperationType TOperationPlan::GetOperationType() const +{ + boost::shared_lock lock(m_lock); + return m_eOperation; +} + +size_t TOperationPlan::GetSubOperationsCount() const +{ + boost::shared_lock lock(m_lock); + return m_vSubOperations.size(); +} + +ESubOperationType TOperationPlan::GetSubOperationAt(size_t stIndex) const +{ + boost::shared_lock lock(m_lock); + if(stIndex >= m_vSubOperations.size()) + THROW_CORE_EXCEPTION_STR(eBoundsExceeded, _T("Index out of bounds")); + else + return m_vSubOperations[stIndex].first; +} + +double TOperationPlan::GetEstimatedTimeAt(size_t stIndex) const +{ + boost::shared_lock lock(m_lock); + if(stIndex >= m_vSubOperations.size()) + THROW_CORE_EXCEPTION_STR(eBoundsExceeded, _T("Index out of bounds")); + else + return m_vSubOperations[stIndex].second; +} + +END_CHCORE_NAMESPACE Index: src/ch/TTaskOperationPlan.cpp =================================================================== diff -u -N --- src/ch/TTaskOperationPlan.cpp (revision 3fc1109991e7311d6b1e34ef0b730f9b4e1fd42a) +++ src/ch/TTaskOperationPlan.cpp (revision 0) @@ -1,126 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2009 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. -// ============================================================================ -/// @file TSubTasks.cpp -/// @date 2010/09/18 -/// @brief Contains implementation of classes for subtasks management. -// ============================================================================ -#include "stdafx.h" -#include "TTaskOperationPlan.h" - -//////////////////////////////////////////////////////////////////////////// -// class TOperationPlan - -TOperationPlan::TOperationPlan() : - m_eOperation(eOperation_None) -{ -} - -TOperationPlan::TOperationPlan(const TOperationPlan& rSrc) : -m_eOperation(eOperation_None), - m_vSubOperations() -{ - boost::shared_lock src_lock(rSrc.m_lock); - - m_eOperation = rSrc.m_eOperation; - m_vSubOperations = rSrc.m_vSubOperations; -} - -TOperationPlan::~TOperationPlan() -{ -} - -TOperationPlan& TOperationPlan::operator=(const TOperationPlan& rSrc) -{ - if(this != &rSrc) - { - boost::shared_lock src_lock(rSrc.m_lock); - boost::unique_lock lock(m_lock); - - m_eOperation = rSrc.m_eOperation; - m_vSubOperations = rSrc.m_vSubOperations; - } - - return *this; -} - -void TOperationPlan::SetOperationType(EOperationType eOperation) -{ - switch(eOperation) - { - case eOperation_None: - THROW(_T("Cannot set operation type 'none'"), 0, 0, 0); - break; - - case eOperation_Copy: - { - boost::unique_lock lock(m_lock); - m_vSubOperations.clear(); - m_vSubOperations.push_back(std::make_pair(eSubOperation_Scanning, 0.05)); - m_vSubOperations.push_back(std::make_pair(eSubOperation_Copying, 0.95)); - break; - } - - case eOperation_Move: - { - boost::unique_lock lock(m_lock); - m_vSubOperations.clear(); - m_vSubOperations.push_back(std::make_pair(eSubOperation_Scanning, 0.05)); - m_vSubOperations.push_back(std::make_pair(eSubOperation_Copying, 0.90)); - m_vSubOperations.push_back(std::make_pair(eSubOperation_Deleting, 0.05)); - break; - } - - BOOST_STATIC_ASSERT(eOperation_Move == eOperation_Max - 1); - - default: - THROW(_T("Unhandled case"), 0, 0, 0); - } - - m_eOperation = eOperation; -} - -EOperationType TOperationPlan::GetOperationType() const -{ - boost::shared_lock lock(m_lock); - return m_eOperation; -} - -size_t TOperationPlan::GetSubOperationsCount() const -{ - boost::shared_lock lock(m_lock); - return m_vSubOperations.size(); -} - -ESubOperationType TOperationPlan::GetSubOperationAt(size_t stIndex) const -{ - boost::shared_lock lock(m_lock); - if(stIndex >= m_vSubOperations.size()) - THROW(_T("Index out of bounds"), 0, 0, 0); - else - return m_vSubOperations[stIndex].first; -} - -double TOperationPlan::GetEstimatedTimeAt(size_t stIndex) const -{ - boost::shared_lock lock(m_lock); - if(stIndex >= m_vSubOperations.size()) - THROW(_T("Index out of bounds"), 0, 0, 0); - else - return m_vSubOperations[stIndex].second; -} Index: src/libchcore/TTaskOperationPlan.h =================================================================== diff -u -N --- src/libchcore/TTaskOperationPlan.h (revision 0) +++ src/libchcore/TTaskOperationPlan.h (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -0,0 +1,106 @@ +// ============================================================================ +// Copyright (C) 2001-2009 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. +// ============================================================================ +/// @file TTaskOperationPlan.cpp +/// @date 2010/09/18 +/// @brief File contains class handling planning of the entire operation. +// ============================================================================ +#ifndef __TTASKOPERATIONPLAN_H__ +#define __TTASKOPERATIONPLAN_H__ + +#include + +BEGIN_CHCORE_NAMESPACE + +// enum represents type of the operation handled by the task +enum EOperationType +{ + eOperation_None, + eOperation_Copy, + eOperation_Move, + + // add new operation types before this enum value + eOperation_Max +}; + +enum ESubOperationType +{ + eSubOperation_None, + eSubOperation_Scanning, + eSubOperation_Copying, + eSubOperation_Deleting, + + // add new operation types before this one + eSubOperation_Max +}; + +/////////////////////////////////////////////////////////////////////////// +// TOperationPlan + +// class describes the sub-operations to be performed +class LIBCHCORE_API TOperationPlan +{ +public: + TOperationPlan(); + TOperationPlan(const TOperationPlan& rSrc); + ~TOperationPlan(); + + TOperationPlan& operator=(const TOperationPlan& rSrc); + + void SetOperationType(EOperationType eOperation); + EOperationType GetOperationType() const; + + size_t GetSubOperationsCount() const; + ESubOperationType GetSubOperationAt(size_t stIndex) const; + double GetEstimatedTimeAt(size_t stIndex) const; + + template + void load(Archive& ar, unsigned int /*uiVersion*/); + + template + void save(Archive& ar, unsigned int /*uiVersion*/) const; + + BOOST_SERIALIZATION_SPLIT_MEMBER(); + +private: + EOperationType m_eOperation; +#pragma warning(push) +#pragma warning(disable: 4251) + std::vector > m_vSubOperations; ///< Vector of sub-task type and estimated part in the entire task time + + mutable boost::shared_mutex m_lock; +#pragma warning(pop) +}; + +template +void TOperationPlan::load(Archive& ar, unsigned int /*uiVersion*/) +{ + EOperationType eOperation = eOperation_None; + ar >> eOperation; + SetOperationType(eOperation); +} + +template +void TOperationPlan::save(Archive& ar, unsigned int /*uiVersion*/) const +{ + ar << m_eOperation; +} + +END_CHCORE_NAMESPACE + +#endif Index: src/ch/TTaskOperationPlan.h =================================================================== diff -u -N --- src/ch/TTaskOperationPlan.h (revision 3fc1109991e7311d6b1e34ef0b730f9b4e1fd42a) +++ src/ch/TTaskOperationPlan.h (revision 0) @@ -1,97 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2009 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. -// ============================================================================ -/// @file TSubTasks.cpp -/// @date 2010/09/18 -/// @brief File contains classes for handling subtasks. -// ============================================================================ -#ifndef __TSUBTASKS_H__ -#define __TSUBTASKS_H__ - -// enum represents type of the operation handled by the task -enum EOperationType -{ - eOperation_None, - eOperation_Copy, - eOperation_Move, - - // add new operation types before this enum value - eOperation_Max -}; - -enum ESubOperationType -{ - eSubOperation_None, - eSubOperation_Scanning, - eSubOperation_Copying, - eSubOperation_Deleting, - - // add new operation types before this one - eSubOperation_Max -}; - -/////////////////////////////////////////////////////////////////////////// -// TOperationPlan - -// class describes the sub-operations to be performed -class TOperationPlan -{ -public: - TOperationPlan(); - TOperationPlan(const TOperationPlan& rSrc); - ~TOperationPlan(); - - TOperationPlan& operator=(const TOperationPlan& rSrc); - - void SetOperationType(EOperationType eOperation); - EOperationType GetOperationType() const; - - size_t GetSubOperationsCount() const; - ESubOperationType GetSubOperationAt(size_t stIndex) const; - double GetEstimatedTimeAt(size_t stIndex) const; - - template - void load(Archive& ar, unsigned int /*uiVersion*/); - - template - void save(Archive& ar, unsigned int /*uiVersion*/) const; - - BOOST_SERIALIZATION_SPLIT_MEMBER(); - -private: - EOperationType m_eOperation; - std::vector > m_vSubOperations; ///< Vector of sub-task type and estimated part in the entire task time - - mutable boost::shared_mutex m_lock; -}; - -template -void TOperationPlan::load(Archive& ar, unsigned int /*uiVersion*/) -{ - EOperationType eOperation = eOperation_None; - ar >> eOperation; - SetOperationType(eOperation); -} - -template -void TOperationPlan::save(Archive& ar, unsigned int /*uiVersion*/) const -{ - ar << m_eOperation; -} - -#endif Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -N -r541933027e84c7a2acf505547170f5da4d87aa82 -r6dc950d4d76107421ff6eb62069b70f20bcc450e --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 541933027e84c7a2acf505547170f5da4d87aa82) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) @@ -471,6 +471,22 @@ RelativePath=".\TPath.h" > + + + + + + + +