Index: src/ch/TTaskConfiguration.h =================================================================== diff -u -N -r98791237b8511ff19aa54dc3c6901222287d9914 -r1d7d79169d480a02e335b8b0a4919f9c78d58325 --- src/ch/TTaskConfiguration.h (.../TTaskConfiguration.h) (revision 98791237b8511ff19aa54dc3c6901222287d9914) +++ src/ch/TTaskConfiguration.h (.../TTaskConfiguration.h) (revision 1d7d79169d480a02e335b8b0a4919f9c78d58325) @@ -23,233 +23,97 @@ #ifndef __TTASKCONFIGURATION_H__ #define __TTASKCONFIGURATION_H__ -#include "FileInfo.h" -#include "FileFilter.h" -#include "DataBuffer.h" +class TConfig; -/////////////////////////////////////////////////////////////////////////// -// TSubTaskCommonConfig -class TSubTaskCommonConfig +enum ETaskOptions { -public: - TSubTaskCommonConfig(); - TSubTaskCommonConfig(const TSubTaskCommonConfig& rSrc); - ~TSubTaskCommonConfig(); + eTO_UseOnlyDefaultBuffer, + eTO_DefaultBufferSize, + eTO_OneDiskBufferSize, + eTO_TwoDisksBufferSize, + eTO_CDBufferSize, + eTO_LANBufferSize, + eTO_DisableBuffering, + eTO_DisableBufferingMinSize, - TSubTaskCommonConfig& operator=(const TSubTaskCommonConfig& rSrc); + eTO_SetDestinationAttributes, + eTO_SetDestinationDateTime, + eTO_ProtectReadOnlyFiles, + eTO_ScanDirectoriesBeforeBlocking, + eTO_ThreadPriority, + eTO_DisablePriorityBoost, + eTO_DeleteInSeparateSubTask, - void SetPriority(int iPriority); - int GetPriority() const; - - void SetDeleteAllFilesAfterAllCopyings(bool bSeparateDelete); - bool GetDeleteAllFilesAfterAllCopyings() const; - - void SetIgnoreReadOnlyAttributes(bool bIgnoreReadOnlyAttributes); - bool GetIgnoreReadOnlyAttributes() const; - - template - void load(Archive& ar, unsigned int /*uiVersion*/) - { - boost::unique_lock lock(m_lock); - - ar >> m_nPriority; - ar >> m_bDeleteAllFilesAfterAllCopyings; - ar >> m_bIgnoreReadOnlyAttributes; - } - - template - void save(Archive& ar, unsigned int /*uiVersion*/) const - { - boost::shared_lock lock(m_lock); - - ar << m_nPriority; - ar << m_bDeleteAllFilesAfterAllCopyings; - ar << m_bIgnoreReadOnlyAttributes; - } - - BOOST_SERIALIZATION_SPLIT_MEMBER(); - -private: - int m_nPriority; // task priority (really processing thread priority) - bool m_bDeleteAllFilesAfterAllCopyings; ///< Delete mode; true means that deleting files is a separate sub-operation launched after copying, false states that file is deleted immediately after being copied - bool m_bIgnoreReadOnlyAttributes; // ignore read-only attributes on files (delete/overwrite) -> this should be handled by feedback requests probably - - mutable boost::shared_mutex m_lock; + eTO_CreateEmptyFiles, + eTO_CreateDirectoriesRelativeToRoot, + eTO_IgnoreDirectories, }; -/////////////////////////////////////////////////////////////////////////// -// TSubTaskScanDirectoriesConfig +///////////////////////////////////////////////////////////////////////////////////////////// +// Properties definitions -class TSubTaskScanDirectoriesConfig -{ -public: - TSubTaskScanDirectoriesConfig(); - TSubTaskScanDirectoriesConfig(const TSubTaskScanDirectoriesConfig& rSrc); - ~TSubTaskScanDirectoriesConfig(); +template struct TaskPropData; - TSubTaskScanDirectoriesConfig& operator=(const TSubTaskScanDirectoriesConfig& rSrc); +#define TASK_PROPERTY(enum_id, val_type, val_name, def_value)\ + template<> struct TaskPropData\ +{\ + typedef val_type value_type;\ + static value_type GetDefaultValue() { return def_value; }\ + static const wchar_t* GetPropertyName() { return val_name; }\ +} - // filtering rules - void SetFilters(const CFiltersArray& rFilters); - const CFiltersArray& GetFilters() const { return m_afFilters; } +#define TASK_PROPERTY_MINMAX(enum_id, val_type, val_name, def_value, min_val, max_val)\ + template<> struct TaskPropData\ +{\ + typedef val_type value_type;\ + static value_type GetDefaultValue() { return def_value; }\ + static const wchar_t* GetPropertyName() { return val_name; }\ +} - template - void load(Archive& ar, unsigned int /*uiVersion*/) - { - boost::unique_lock lock(m_lock); - ar >> m_afFilters; - } +TASK_PROPERTY(eTO_UseOnlyDefaultBuffer, bool, _T("Buffer.UseOnlyDefaultBuffer"), false); +TASK_PROPERTY_MINMAX(eTO_DefaultBufferSize, unsigned int, _T("Buffer.DefaultBufferSize"), 2097152, 1, 0xffffffff); +TASK_PROPERTY_MINMAX(eTO_OneDiskBufferSize, unsigned int, _T("Buffer.OnePhysicalDiskSize"), 4194304, 1, 0xffffffff); +TASK_PROPERTY_MINMAX(eTO_TwoDisksBufferSize, unsigned int, _T("Buffer.TwoPhysicalDisksSize"), 524288, 1, 0xffffffff); +TASK_PROPERTY_MINMAX(eTO_CDBufferSize, unsigned int, _T("Buffer.CDSize"), 262144, 1, 0xffffffff); +TASK_PROPERTY_MINMAX(eTO_LANBufferSize, unsigned int, _T("Buffer.LANSize"), 131072, 1, 0xffffffff); - template - void save(Archive& ar, unsigned int /*uiVersion*/) const - { - boost::shared_lock lock(m_lock); - ar << m_afFilters; - } +TASK_PROPERTY(eTO_DisableBuffering, bool, _T("Operation.Buffering.DisableBufferingForLargeFiles"), true); +TASK_PROPERTY_MINMAX(eTO_DisableBufferingMinSize, int, _T("Operation.Buffering.MinSizeOfFileToDisableBuffering"), 2097152, 1, 0xffffffff); - BOOST_SERIALIZATION_SPLIT_MEMBER(); +TASK_PROPERTY(eTO_SetDestinationAttributes, bool, _T("Operation.SetDestinationAttributes"), true); +TASK_PROPERTY(eTO_SetDestinationDateTime, bool, _T("Operation.SetDestinationTime"), true); +TASK_PROPERTY(eTO_ProtectReadOnlyFiles, bool, _T("Operation.ProtectReadOnlyFiles"), true); +TASK_PROPERTY(eTO_ScanDirectoriesBeforeBlocking, bool, _T("Operation.ScanForFilesBeforeBlocking"), true); -private: - CFiltersArray m_afFilters; // filtering settings for files (will be filtered according to the rules inside when searching for files) +TASK_PROPERTY(eTO_ThreadPriority, int, _T("Operation.Thread.Priority"), THREAD_PRIORITY_NORMAL); +TASK_PROPERTY(eTO_DisablePriorityBoost, bool, _T("Operation.Thread.DisablePriorityBoost"), false); - mutable boost::shared_mutex m_lock; -}; +TASK_PROPERTY(eTO_DeleteInSeparateSubTask, bool, _T("Operation.DeleteFilesInSeparateOperation"), true); -/////////////////////////////////////////////////////////////////////////// -// TSubTaskCopyMoveConfig +TASK_PROPERTY(eTO_CreateEmptyFiles, bool, _T("Operation.CreateEmptyFiles"), false); +TASK_PROPERTY(eTO_CreateDirectoriesRelativeToRoot, bool, _T("Operation.CreateDirectoriesRelativeToRoot"), false); +TASK_PROPERTY(eTO_IgnoreDirectories, bool, _T("Operation.IgnoreDirectories"), false); -class TSubTaskCopyMoveConfig +///////////////////////////////////////////////////////////////////////////////////////////// +// Properties retrieval +template +typename TaskPropData::value_type GetTaskPropValue(const TConfig& rConfig) { -public: - TSubTaskCopyMoveConfig(); - TSubTaskCopyMoveConfig(const TSubTaskCopyMoveConfig& rSrc); - ~TSubTaskCopyMoveConfig(); + typename TaskPropData::value_type tValue; + rConfig.GetValue(TaskPropData::GetPropertyName(), tValue, TaskPropData::GetDefaultValue()); + return tValue; +} - TSubTaskCopyMoveConfig& operator=(const TSubTaskCopyMoveConfig& rSrc); - - void SetDisableSystemBuffering(bool bDisableBuffering); - bool GetDisableSystemBuffering() const; - - void SetMinSizeToDisableBuffering(unsigned long long ullMinSize); - unsigned long long GetMinSizeToDisableBuffering() const; - - void SetPreserveFileDateTime(bool bPreserve); - bool GetPreserveFileDateTime() const; - - void SetPreserveFileAttributes(bool bPreserve); - bool GetPreserveFileAttributes() const; - - void SetBufferSizes(const BUFFERSIZES& bsSizes); - BUFFERSIZES GetBufferSizes() const; - - void SetIgnoreDirectories(bool bIgnore); - bool GetIgnoreDirectories() const; - - void SetCreateEmptyFiles(bool bCreateEmpty); - bool GetCreateEmptyFiles() const; - - void SetCreateOnlyDirectories(bool bCreateOnlyDirs); - bool GetCreateOnlyDirectories() const; - - template - void load(Archive& ar, unsigned int /*uiVersion*/) - { - boost::unique_lock lock(m_lock); - - ar & m_bDisableSystemBuffering; - ar & m_ullMinSizeToDisableBuffering; - - ar & m_bPreserveFileDateTime; - ar & m_bPreserveFileAttributes; - - ar & m_bsSizes; - - ar & m_bIgnoreDirectories; - ar & m_bCreateEmptyFiles; - ar & m_bCreateOnlyDirectories; - } - - template - void save(Archive& ar, unsigned int /*uiVersion*/) const - { - boost::shared_lock lock(m_lock); - - ar & m_bDisableSystemBuffering; - ar & m_ullMinSizeToDisableBuffering; - - ar & m_bPreserveFileDateTime; - ar & m_bPreserveFileAttributes; - - ar & m_bsSizes; - - ar & m_bIgnoreDirectories; - ar & m_bCreateEmptyFiles; - ar & m_bCreateOnlyDirectories; - } - - BOOST_SERIALIZATION_SPLIT_MEMBER(); - -private: - bool m_bDisableSystemBuffering; ///< Disables system buffering of files - unsigned long long m_ullMinSizeToDisableBuffering; ///< Minimal file size to disable system buffering - - bool m_bPreserveFileDateTime; - bool m_bPreserveFileAttributes; - - BUFFERSIZES m_bsSizes; // sizes of buffers used to copy - - bool m_bIgnoreDirectories; - bool m_bCreateEmptyFiles; - bool m_bCreateOnlyDirectories; - - mutable boost::shared_mutex m_lock; -}; - -/////////////////////////////////////////////////////////////////////////// -// TSubTaskDeleteConfig - -/* -class TSubTaskDeleteConfig +template +bool GetTaskPropValue(const TConfig& rConfig, typename TaskPropData::value_type& rValue) { -private: - mutable boost::shared_mutex m_lock; -}; -*/ + return rConfig.GetValue(TaskPropData::GetPropertyName(), rValue, TaskPropData::GetDefaultValue()); +} -/////////////////////////////////////////////////////////////////////////// -// TTaskConfiguration - -class TTaskConfiguration +template +void SetTaskPropValue(TConfig& rConfig, const typename TaskPropData::value_type& rValue) { -public: - TTaskConfiguration(); - ~TTaskConfiguration(); + rConfig.SetValue(TaskPropData::GetPropertyName(), rValue); +} - const TSubTaskCommonConfig& GetCommonConfig() const { return m_tCommonConfig; } - TSubTaskCommonConfig& GetCommonConfig() { return m_tCommonConfig; } - - const TSubTaskScanDirectoriesConfig& GetScanDirectoriesConfig() const { return m_tScanDirectoriesConfig; } - TSubTaskScanDirectoriesConfig& GetScanDirectoriesConfig() { return m_tScanDirectoriesConfig; } - - const TSubTaskCopyMoveConfig& GetCopyMoveConfig() const { return m_tCopyMoveConfig; } - TSubTaskCopyMoveConfig& GetCopyMoveConfig() { return m_tCopyMoveConfig; } - - // const TSubTaskDeleteConfig& GetDeleteConfig() const { return m_tDeleteConfig; } - - template - void serialize(Archive& ar, unsigned int /*uiVersion*/) - { - ar & m_tCommonConfig; - ar & m_tScanDirectoriesConfig; - ar & m_tCopyMoveConfig; -// ar & m_tDeleteConfig; - } - -private: - TSubTaskCommonConfig m_tCommonConfig; - TSubTaskScanDirectoriesConfig m_tScanDirectoriesConfig; - TSubTaskCopyMoveConfig m_tCopyMoveConfig; -// TSubTaskDeleteConfig m_tDeleteConfig; -}; - #endif