Index: src/libchcore/IColumnsDefinition.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/IColumnsDefinition.h (.../IColumnsDefinition.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/IColumnsDefinition.h (.../IColumnsDefinition.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -21,23 +21,44 @@ #include "libchcore.h" #include "TString.h" +#include BEGIN_CHCORE_NAMESPACE class LIBCHCORE_API IColumnsDefinition { public: + enum ETypes + { + eType_bool, + eType_short, + eType_ushort, + eType_int, + eType_uint, + eType_long, + eType_ulong, + eType_longlong, + eType_ulonglong, + eType_sizet, + eType_double, + eType_string, + eType_path, + + eType_Last + }; + +public: virtual ~IColumnsDefinition(); - virtual size_t AddColumn(const TString& strColumnName) = 0; + virtual size_t AddColumn(const TString& strColumnName, ETypes eColType) = 0; virtual void Clear() = 0; - virtual size_t GetColumnIndex(const TString& strColumnName, bool bAdd = true) = 0; + virtual size_t GetColumnIndex(const TString& strColumnName) = 0; virtual TString GetColumnName(size_t stIndex) const = 0; virtual size_t GetCount() const = 0; virtual bool IsEmpty() const = 0; - virtual IColumnsDefinition& operator%(const TString& strColName) = 0; +// virtual IColumnsDefinition& operator%(const TString& strColName) = 0; }; //typedef boost::shared_ptr IColumnsDefinitionPtr; Index: src/libchcore/ISerializerRowReader.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/ISerializerRowReader.h (.../ISerializerRowReader.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/ISerializerRowReader.h (.../ISerializerRowReader.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -31,8 +31,6 @@ public: virtual ~ISerializerRowReader(); - virtual IColumnsDefinition& GetColumnsDefinitions() const = 0; - virtual bool Next() = 0; virtual void GetValue(const TString& strColName, bool& bValue) = 0; Index: src/libchcore/TBasePathData.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TBasePathData.cpp (.../TBasePathData.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TBasePathData.cpp (.../TBasePathData.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -114,9 +114,12 @@ m_setModifications.reset(); } -void TBasePathData::InitLoader(IColumnsDefinition& rColumnDefs) +void TBasePathData::InitColumns(IColumnsDefinition& rColumns) { - rColumnDefs % _T("id") % _T("src_path") % _T("skip_processing") % _T("dst_path"); + rColumns.AddColumn(_T("id"), IColumnsDefinition::eType_long); + rColumns.AddColumn(_T("src_path"), IColumnsDefinition::eType_path); + rColumns.AddColumn(_T("skip_processing"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("dst_path"), IColumnsDefinition::eType_path); } void TBasePathData::Load(const ISerializerRowReaderPtr& spRowReader) @@ -169,6 +172,8 @@ boost::shared_lock lock(m_lock); + InitColumns(spContainer); + spContainer->DeleteRows(m_setRemovedObjects); m_setRemovedObjects.Clear(); @@ -187,10 +192,9 @@ m_setRemovedObjects.Clear(); m_vEntries.clear(); + InitColumns(spContainer); + ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); - IColumnsDefinition& rColumns = spRowReader->GetColumnsDefinitions(); - if(rColumns.IsEmpty()) - TBasePathData::InitLoader(rColumns); while(spRowReader->Next()) { @@ -281,4 +285,11 @@ return *this; } +void TBasePathDataContainer::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + TBasePathData::InitColumns(rColumns); +} + END_CHCORE_NAMESPACE Index: src/libchcore/TBasePathData.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TBasePathData.h (.../TBasePathData.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TBasePathData.h (.../TBasePathData.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -70,7 +70,7 @@ bool IsDestinationPathSet() const; void Store(const ISerializerContainerPtr& spContainer) const; - static void InitLoader(IColumnsDefinition& rColumnDefs); + static void InitColumns(IColumnsDefinition& rColumnDefs); void Load(const ISerializerRowReaderPtr& spRowReader); private: @@ -116,6 +116,8 @@ void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + private: TBasePathDataContainer(const TBasePathDataContainer& rSrc); TBasePathDataContainer& operator=(const TBasePathDataContainer& rSrc); Index: src/libchcore/TConfig.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TConfig.cpp (.../TConfig.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TConfig.cpp (.../TConfig.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -142,6 +142,8 @@ boost::shared_lock lock(GetImpl()->m_lock); + InitColumns(spContainer); + spContainer->DeleteRows(m_pImpl->m_setRemovedObjects); BOOST_FOREACH(const ConfigNode& rNode, m_pImpl->m_mic) @@ -176,10 +178,9 @@ m_pImpl->m_setRemovedObjects.Clear(); m_pImpl->m_mic.clear(); + InitColumns(spContainer); + ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); - IColumnsDefinition& rColumns = spRowReader->GetColumnsDefinitions(); - if(rColumns.IsEmpty()) - rColumns % _T("name") % _T("node_order") % _T("value"); while(spRowReader->Next()) { @@ -195,6 +196,17 @@ } } +void TConfig::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + rColumns.AddColumn(_T("name"), IColumnsDefinition::eType_string); + rColumns.AddColumn(_T("node_order"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("value"), IColumnsDefinition::eType_string); + } +} + void TConfig::SetFilePath(PCTSTR pszPath) { boost::unique_lock lock(GetImpl()->m_lock); Index: src/libchcore/TConfig.h =================================================================== diff -u -rb1e03eb232a784d6e2d40f67cbbbb33be0972228 -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TConfig.h (.../TConfig.h) (revision b1e03eb232a784d6e2d40f67cbbbb33be0972228) +++ src/libchcore/TConfig.h (.../TConfig.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -55,6 +55,8 @@ void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer) const; + void InitColumns(const ISerializerContainerPtr& spContainer) const; + void ReadFromString(const TString& strInput); void WriteToString(TString& strOutput); Index: src/libchcore/TFileFilter.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TFileFilter.cpp (.../TFileFilter.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TFileFilter.cpp (.../TFileFilter.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -536,37 +536,36 @@ } } -void TFileFilter::SetupLoader(IColumnsDefinition& rColumns) +void TFileFilter::InitColumns(IColumnsDefinition& rColumns) { - rColumns - % _T("id") - % _T("use_mask") - % _T("mask") - % _T("use_exclude_mask") - % _T("exclude_mask") - % _T("use_size_1") - % _T("compare_type_1") - % _T("size_1") - % _T("use_size_2") - % _T("compare_type_2") - % _T("size_2") - % _T("date_type") - % _T("use_date_time_1") - % _T("date_compare_type_1") - % _T("use_date_1") - % _T("use_time_1") - % _T("datetime_1") - % _T("use_date_time_2") - % _T("date_compare_type_2") - % _T("use_date_2") - % _T("use_time_2") - % _T("datetime_2") - % _T("use_attributes") - % _T("attr_archive") - % _T("attr_ro") - % _T("attr_hidden") - % _T("attr_system") - % _T("attr_directory"); + rColumns.AddColumn(_T("id"), IColumnsDefinition::eType_sizet); + rColumns.AddColumn(_T("use_mask"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("mask"), IColumnsDefinition::eType_string); + rColumns.AddColumn(_T("use_exclude_mask"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("exclude_mask"), IColumnsDefinition::eType_string); + rColumns.AddColumn(_T("use_size_1"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("compare_type_1"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("size_1"), IColumnsDefinition::eType_ulonglong); + rColumns.AddColumn(_T("use_size_2"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("compare_type_2"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("size_2"), IColumnsDefinition::eType_ulonglong); + rColumns.AddColumn(_T("date_type"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("use_date_time_1"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("date_compare_type_1"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("use_date_1"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("use_time_1"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("datetime_1"), IColumnsDefinition::eType_ulonglong); + rColumns.AddColumn(_T("use_date_time_2"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("date_compare_type_2"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("use_date_2"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("use_time_2"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("datetime_2"), IColumnsDefinition::eType_ulonglong); + rColumns.AddColumn(_T("use_attributes"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("attr_archive"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("attr_ro"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("attr_hidden"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("attr_system"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("attr_directory"), IColumnsDefinition::eType_int); } void TFileFilter::Store(const ISerializerContainerPtr& spContainer) const Index: src/libchcore/TFileFilter.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TFileFilter.h (.../TFileFilter.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TFileFilter.h (.../TFileFilter.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -79,7 +79,7 @@ void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerRowReaderPtr& spRowReader); - static void SetupLoader(IColumnsDefinition& rColumns); + static void InitColumns(IColumnsDefinition& rColumns); // other size_t GetObjectID() const; Index: src/libchcore/TFileFiltersArray.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TFileFiltersArray.cpp (.../TFileFiltersArray.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TFileFiltersArray.cpp (.../TFileFiltersArray.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -152,6 +152,8 @@ void TFileFiltersArray::Store(const ISerializerContainerPtr& spContainer) const { + InitColumns(spContainer); + spContainer->DeleteRows(m_setRemovedObjects); BOOST_FOREACH(const TFileFilter& rFilter, m_vFilters) @@ -162,9 +164,7 @@ void TFileFiltersArray::Load(const ISerializerContainerPtr& spContainer) { - IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); - if(rColumns.IsEmpty()) - TFileFilter::SetupLoader(rColumns); + InitColumns(spContainer); ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); while(spRowReader->Next()) @@ -178,4 +178,11 @@ } } +void TFileFiltersArray::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + TFileFilter::InitColumns(rColumns); +} + END_CHCORE_NAMESPACE Index: src/libchcore/TFileFiltersArray.h =================================================================== diff -u -rb193a95402f2bf4c456fb9d65d111caaf6994823 -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TFileFiltersArray.h (.../TFileFiltersArray.h) (revision b193a95402f2bf4c456fb9d65d111caaf6994823) +++ src/libchcore/TFileFiltersArray.h (.../TFileFiltersArray.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -45,6 +45,8 @@ void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + bool IsEmpty() const; void Add(const TFileFilter& rFilter); Index: src/libchcore/TFileInfo.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TFileInfo.cpp (.../TFileInfo.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TFileInfo.cpp (.../TFileInfo.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -277,9 +277,17 @@ m_setModifications.reset(); } -void TFileInfo::InitLoader(IColumnsDefinition& rColumns) +void TFileInfo::InitColumns(IColumnsDefinition& rColumns) { - rColumns % _T("id") % _T("rel_path") % _T("base_path_id") % _T("attr") % _T("size") % _T("time_created") % _T("time_last_write") % _T("time_last_access") % _T("flags"); + rColumns.AddColumn(_T("id"), IColumnsDefinition::eType_sizet); + rColumns.AddColumn(_T("rel_path"), IColumnsDefinition::eType_path); + rColumns.AddColumn(_T("base_path_id"), IColumnsDefinition::eType_sizet); + rColumns.AddColumn(_T("attr"), IColumnsDefinition::eType_ulong); + rColumns.AddColumn(_T("size"), IColumnsDefinition::eType_ulonglong); + rColumns.AddColumn(_T("time_created"), IColumnsDefinition::eType_ulonglong); + rColumns.AddColumn(_T("time_last_write"), IColumnsDefinition::eType_ulonglong); + rColumns.AddColumn(_T("time_last_access"), IColumnsDefinition::eType_ulonglong); + rColumns.AddColumn(_T("flags"), IColumnsDefinition::eType_uint); } void TFileInfo::Load(const ISerializerRowReaderPtr& spRowReader, const TBasePathDataContainerPtr& spSrcContainer) Index: src/libchcore/TFileInfo.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TFileInfo.h (.../TFileInfo.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TFileInfo.h (.../TFileInfo.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -99,7 +99,7 @@ bool IsProcessed() const; void Store(const ISerializerContainerPtr& spContainer) const; - static void InitLoader(IColumnsDefinition& rColumns); + static void InitColumns(IColumnsDefinition& rColumns); void Load(const ISerializerRowReaderPtr& spRowReader, const TBasePathDataContainerPtr& spSrcContainer); private: Index: src/libchcore/TFileInfoArray.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TFileInfoArray.cpp (.../TFileInfoArray.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TFileInfoArray.cpp (.../TFileInfoArray.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -133,6 +133,8 @@ { boost::shared_lock lock(m_lock); + InitColumns(spContainer); + // store only if there is a complete collection of items inside // (this container is used in the directory scanning process. There is no // point storing only partially scanned data in the serializer as we @@ -149,9 +151,7 @@ void TFileInfoArray::Load(const ISerializerContainerPtr& spContainer, const TBasePathDataContainerPtr& spBasePaths) { - IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); - if(rColumns.IsEmpty()) - TFileInfo::InitLoader(rColumns); + InitColumns(spContainer); std::vector vEntries; ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); @@ -169,4 +169,11 @@ m_vFiles = vEntries; } +void TFileInfoArray::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + TFileInfo::InitColumns(rColumns); +} + END_CHCORE_NAMESPACE Index: src/libchcore/TFileInfoArray.h =================================================================== diff -u -ra5aa3c3cb78f3767641de2627d1a49a1dc35b429 -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TFileInfoArray.h (.../TFileInfoArray.h) (revision a5aa3c3cb78f3767641de2627d1a49a1dc35b429) +++ src/libchcore/TFileInfoArray.h (.../TFileInfoArray.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -65,6 +65,8 @@ void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer, const TBasePathDataContainerPtr& spBasePaths); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + protected: bool m_bComplete; Index: src/libchcore/TModPathContainer.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TModPathContainer.cpp (.../TModPathContainer.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TModPathContainer.cpp (.../TModPathContainer.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -280,6 +280,8 @@ void TModPathContainer::Store(const ISerializerContainerPtr& spContainer) const { + InitColumns(spContainer); + // delete items first spContainer->DeleteRows(m_setRemovedItems); m_setRemovedItems.Clear(); @@ -309,8 +311,7 @@ m_vPaths.clear(); m_stNextObjectID = 1; - IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); - rColumns % _T("id") % _T("path"); + InitColumns(spContainer); ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); while(spRowReader->Next()) @@ -327,4 +328,14 @@ ClearModifications(); } +void TModPathContainer::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + rColumns.AddColumn(_T("id"), IColumnsDefinition::eType_sizet); + rColumns.AddColumn(_T("path"), IColumnsDefinition::eType_path); + } +} + END_CHCORE_NAMESPACE Index: src/libchcore/TModPathContainer.h =================================================================== diff -u -r293e52b38d46653068006262172018a0f0d0a31c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TModPathContainer.h (.../TModPathContainer.h) (revision 293e52b38d46653068006262172018a0f0d0a31c) +++ src/libchcore/TModPathContainer.h (.../TModPathContainer.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -73,6 +73,9 @@ #pragma region Serialization void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer); + + void InitColumns(const ISerializerContainerPtr& spContainer) const; + #pragma endregion private: Index: src/libchcore/TSQLiteColumnDefinition.cpp =================================================================== diff -u -r9479911a096555a7504c5c8a8eaee83ecb63440c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSQLiteColumnDefinition.cpp (.../TSQLiteColumnDefinition.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/libchcore/TSQLiteColumnDefinition.cpp (.../TSQLiteColumnDefinition.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -31,9 +31,9 @@ { } -size_t TSQLiteColumnsDefinition::AddColumn(const TString& strColumnName) +size_t TSQLiteColumnsDefinition::AddColumn(const TString& strColumnName, ETypes eColType) { - m_vColumns.push_back(strColumnName); + m_vColumns.push_back(std::make_pair(strColumnName, eColType)); return m_vColumns.size() - 1; } @@ -42,24 +42,22 @@ m_vColumns.clear(); } -size_t TSQLiteColumnsDefinition::GetColumnIndex(const TString& strColumnName, bool bAdd) +size_t TSQLiteColumnsDefinition::GetColumnIndex(const TString& strColumnName) { - std::vector::const_iterator iterFnd = std::find(m_vColumns.begin(), m_vColumns.end(), strColumnName); - if(iterFnd == m_vColumns.end()) + size_t stPos = 0; + for(VecColumns::const_iterator iterFnd = m_vColumns.begin(); iterFnd != m_vColumns.end(); ++iterFnd) { - if(bAdd) - return AddColumn(strColumnName); - - THROW_CORE_EXCEPTION(eErr_InvalidData); + if(iterFnd->first == strColumnName) + return stPos; + ++stPos; } - std::vector::const_iterator iterBegin = m_vColumns.begin(); - return std::distance(iterBegin, iterFnd); + THROW_CORE_EXCEPTION(eErr_BoundsExceeded); } TString TSQLiteColumnsDefinition::GetColumnName(size_t stIndex) const { - return m_vColumns.at(stIndex); + return m_vColumns.at(stIndex).first; } size_t TSQLiteColumnsDefinition::GetCount() const @@ -72,18 +70,13 @@ return m_vColumns.empty(); } -IColumnsDefinition& TSQLiteColumnsDefinition::operator%(const TString& strColName) +TString TSQLiteColumnsDefinition::GetCommaSeparatedColumns() const { - AddColumn(strColName); - return *this; -} - -chcore::TString TSQLiteColumnsDefinition::GetCommaSeparatedColumns() const -{ TString strColumns; - BOOST_FOREACH(const TString& strName, m_vColumns) + VecColumns::value_type pairCol; + BOOST_FOREACH(pairCol, m_vColumns) { - strColumns += strName + _T(","); + strColumns += pairCol.first + _T(","); } strColumns.TrimRightSelf(_T(",")); Index: src/libchcore/TSQLiteColumnDefinition.h =================================================================== diff -u -r9479911a096555a7504c5c8a8eaee83ecb63440c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSQLiteColumnDefinition.h (.../TSQLiteColumnDefinition.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/libchcore/TSQLiteColumnDefinition.h (.../TSQLiteColumnDefinition.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -32,22 +32,23 @@ TSQLiteColumnsDefinition(); virtual ~TSQLiteColumnsDefinition(); - virtual size_t AddColumn(const TString& strColumnName); + virtual size_t AddColumn(const TString& strColumnName, ETypes eColType); virtual void Clear(); - virtual size_t GetColumnIndex(const TString& strColumnName, bool bAdd = true); + virtual size_t GetColumnIndex(const TString& strColumnName); virtual TString GetColumnName(size_t stIndex) const; virtual size_t GetCount() const; virtual bool IsEmpty() const; - virtual IColumnsDefinition& operator%(const TString& strColName); +// virtual IColumnsDefinition& operator%(const TString& strColName); virtual TString GetCommaSeparatedColumns() const; private: #pragma warning(push) #pragma warning(disable: 4251) - std::vector m_vColumns; + typedef std::vector> VecColumns; + VecColumns m_vColumns; #pragma warning(pop) }; Index: src/libchcore/TSQLiteSerializerRowReader.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSQLiteSerializerRowReader.cpp (.../TSQLiteSerializerRowReader.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSQLiteSerializerRowReader.cpp (.../TSQLiteSerializerRowReader.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -165,9 +165,4 @@ return boost::numeric_cast(stColumn); } -IColumnsDefinition& TSQLiteSerializerRowReader::GetColumnsDefinitions() const -{ - return m_rColumns; -} - END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteSerializerRowReader.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSQLiteSerializerRowReader.h (.../TSQLiteSerializerRowReader.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSQLiteSerializerRowReader.h (.../TSQLiteSerializerRowReader.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -36,8 +36,6 @@ TSQLiteSerializerRowReader(const sqlite::TSQLiteDatabasePtr& spDatabase, TSQLiteColumnsDefinition& rColumns, const TString& strContainerName); virtual ~TSQLiteSerializerRowReader(); - virtual IColumnsDefinition& GetColumnsDefinitions() const; - virtual bool Next(); virtual void GetValue(const TString& strColName, bool& bValue); Index: src/libchcore/TSubTaskArray.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskArray.cpp (.../TSubTaskArray.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskArray.cpp (.../TSubTaskArray.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -181,6 +181,8 @@ /////////////////////////////////////////////////////////////////////// { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtasks_info")); + InitSubtasksInfoColumns(spContainer); + ISerializerRowDataPtr spRow; if(bAdded) @@ -195,6 +197,9 @@ /////////////////////////////////////////////////////////////////////// { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtasks")); + + InitSubtasksColumns(spContainer); + ISerializerRowDataPtr spRow; // base data @@ -255,12 +260,10 @@ /////////////////////////////////////////////////////////////////////// { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtasks_info")); - ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); - IColumnsDefinition& rColumns = spRowReader->GetColumnsDefinitions(); - if(rColumns.IsEmpty()) - rColumns % _T("id") % _T("operation"); + InitSubtasksInfoColumns(spContainer); + ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); if(spRowReader->Next()) spRowReader->GetValue(_T("operation"), *(int*)&m_eOperationType.Modify()); } @@ -272,9 +275,7 @@ ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtasks")); ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); - IColumnsDefinition& rColumns = spRowReader->GetColumnsDefinitions(); - if(rColumns.IsEmpty()) - rColumns % _T("id") % _T("type") % _T("is_current") % _T("is_estimation"); + InitSubtasksColumns(spContainer); while(spRowReader->Next()) { @@ -335,4 +336,30 @@ } } +IColumnsDefinition& TSubTasksArray::InitSubtasksColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + rColumns.AddColumn(_T("id"), IColumnsDefinition::eType_long); + rColumns.AddColumn(_T("type"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("is_current"), IColumnsDefinition::eType_bool); + rColumns.AddColumn(_T("is_estimation"), IColumnsDefinition::eType_bool); + } + + return rColumns; +} + +IColumnsDefinition& TSubTasksArray::InitSubtasksInfoColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + rColumns.AddColumn(_T("id"), IColumnsDefinition::eType_long); + rColumns.AddColumn(_T("operation"), IColumnsDefinition::eType_int); + } + + return rColumns; +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskArray.h =================================================================== diff -u -rff16e23b043c1c3f3ea883372b6f81d7ad4adca3 -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskArray.h (.../TSubTaskArray.h) (revision ff16e23b043c1c3f3ea883372b6f81d7ad4adca3) +++ src/libchcore/TSubTaskArray.h (.../TSubTaskArray.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -66,6 +66,9 @@ void AddSubTask(const TSubTaskBasePtr& spOperation, bool bIsPartOfEstimation); static TSubTaskBasePtr CreateSubtask(ESubOperationType eType, TSubTaskContext& rContext); + IColumnsDefinition& InitSubtasksColumns(const ISerializerContainerPtr& spContainer) const; + IColumnsDefinition& InitSubtasksInfoColumns(const ISerializerContainerPtr& spContainer) const; + private: enum EModifications { Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -122,9 +122,10 @@ } } - void TCopyMoveProgressInfo::InitLoader(IColumnsDefinition& rColumns) + void TCopyMoveProgressInfo::InitColumns(IColumnsDefinition& rColumns) { - rColumns % _T("current_index") % _T("cf_processed_size"); + rColumns.AddColumn(_T("current_index"), IColumnsDefinition::eType_sizet); + rColumns.AddColumn(_T("cf_processed_size"), IColumnsDefinition::eType_ulonglong); } void TCopyMoveProgressInfo::Load(const ISerializerRowReaderPtr& spRowReader) @@ -1318,6 +1319,8 @@ void TSubTaskCopyMove::Store(const ISerializerPtr& spSerializer) const { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_copymove")); + InitColumns(spContainer); + ISerializerRowDataPtr spRow; if(m_tProgressInfo.WasSerialized()) @@ -1333,12 +1336,7 @@ { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_copymove")); - IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); - if(rColumns.IsEmpty()) - { - details::TCopyMoveProgressInfo::InitLoader(rColumns); - TSubTaskStatsInfo::InitLoader(rColumns); - } + InitColumns(spContainer); ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); if(spRowReader->Next()) @@ -1348,4 +1346,14 @@ } } +void TSubTaskCopyMove::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + details::TCopyMoveProgressInfo::InitColumns(rColumns); + TSubTaskStatsInfo::InitColumns(rColumns); + } +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskCopyMove.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -64,7 +64,7 @@ void DecreaseCurrentFileProcessedSize(unsigned long long ullSizeToSubtract); void Store(const ISerializerRowDataPtr& spRowData) const; - static void InitLoader(IColumnsDefinition& rColumns); + static void InitColumns(IColumnsDefinition& rColumns); void Load(const ISerializerRowReaderPtr& spRowReader); bool WasSerialized() const; @@ -102,6 +102,8 @@ virtual void Store(const ISerializerPtr& spSerializer) const; virtual void Load(const ISerializerPtr& spSerializer); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + virtual TSubTaskProgressInfo& GetProgressInfo() { return m_tProgressInfo; } virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& rStats) const; Index: src/libchcore/TSubTaskDelete.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -87,9 +87,9 @@ } } - void TDeleteProgressInfo::InitLoader(IColumnsDefinition& rColumns) + void TDeleteProgressInfo::InitColumns(IColumnsDefinition& rColumns) { - rColumns % _T("current_index"); + rColumns.AddColumn(_T("current_index"), IColumnsDefinition::eType_sizet); } void TDeleteProgressInfo::Load(const ISerializerRowReaderPtr& spRowReader) @@ -253,6 +253,8 @@ void TSubTaskDelete::Store(const ISerializerPtr& spSerializer) const { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_delete")); + InitColumns(spContainer); + ISerializerRowDataPtr spRow; if(m_tProgressInfo.WasSerialized()) @@ -268,12 +270,7 @@ { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_delete")); - IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); - if(rColumns.IsEmpty()) - { - details::TDeleteProgressInfo::InitLoader(rColumns); - TSubTaskStatsInfo::InitLoader(rColumns); - } + InitColumns(spContainer); ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); if(spRowReader->Next()) @@ -283,4 +280,14 @@ } } +void TSubTaskDelete::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + details::TDeleteProgressInfo::InitColumns(rColumns); + TSubTaskStatsInfo::InitColumns(rColumns); + } +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskDelete.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -49,7 +49,7 @@ size_t GetCurrentIndex() const; void Store(const ISerializerRowDataPtr& spRowData) const; - static void InitLoader(IColumnsDefinition& rColumns); + static void InitColumns(IColumnsDefinition& rColumns); void Load(const ISerializerRowReaderPtr& spRowReader); bool WasSerialized() const; @@ -76,6 +76,8 @@ virtual void Store(const ISerializerPtr& spSerializer) const; virtual void Load(const ISerializerPtr& spSerializer); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + virtual TSubTaskProgressInfo& GetProgressInfo() { return m_tProgressInfo; } virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const; Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -89,9 +89,9 @@ } } - void TFastMoveProgressInfo::InitLoader(IColumnsDefinition& rColumns) + void TFastMoveProgressInfo::InitColumns(IColumnsDefinition& rColumns) { - rColumns % _T("current_index"); + rColumns.AddColumn(_T("current_index"), IColumnsDefinition::eType_sizet); } void TFastMoveProgressInfo::Load(const ISerializerRowReaderPtr& spRowReader) @@ -312,6 +312,9 @@ void TSubTaskFastMove::Store(const ISerializerPtr& spSerializer) const { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_fastmove")); + + InitColumns(spContainer); + ISerializerRowDataPtr spRow; if(m_tProgressInfo.WasSerialized()) @@ -327,12 +330,7 @@ { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_fastmove")); - IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); - if(rColumns.IsEmpty()) - { - details::TFastMoveProgressInfo::InitLoader(rColumns); - TSubTaskStatsInfo::InitLoader(rColumns); - } + InitColumns(spContainer); ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); if(spRowReader->Next()) @@ -342,4 +340,14 @@ } } +void TSubTaskFastMove::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + details::TFastMoveProgressInfo::InitColumns(rColumns); + TSubTaskStatsInfo::InitColumns(rColumns); + } +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskFastMove.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -51,7 +51,7 @@ size_t GetCurrentIndex() const; void Store(const ISerializerRowDataPtr& spRowData) const; - static void InitLoader(IColumnsDefinition& rColumns); + static void InitColumns(IColumnsDefinition& rColumns); void Load(const ISerializerRowReaderPtr& spRowReader); bool WasSerialized() const; @@ -79,6 +79,8 @@ virtual void Store(const ISerializerPtr& spSerializer) const; virtual void Load(const ISerializerPtr& spSerializer); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + virtual TSubTaskProgressInfo& GetProgressInfo() { return m_tProgressInfo; } virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& rStats) const; Index: src/libchcore/TSubTaskStatsInfo.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -320,23 +320,22 @@ m_setModifications.reset(); } -void TSubTaskStatsInfo::InitLoader(IColumnsDefinition& rColumnDefs) +void TSubTaskStatsInfo::InitColumns(IColumnsDefinition& rColumnDefs) { - rColumnDefs - % _T("is_running") - % _T("is_initialized") - % _T("total_size") - % _T("processed_size") - % _T("size_speed") - % _T("total_count") - % _T("processed_count") - % _T("count_speed") - % _T("ci_processed_size") - % _T("ci_total_size") - % _T("timer") - % _T("buffer_index") - % _T("current_path") - % _T("suboperation_type"); + rColumnDefs.AddColumn(_T("is_running"), IColumnsDefinition::eType_bool); + rColumnDefs.AddColumn(_T("is_initialized"), IColumnsDefinition::eType_bool); + rColumnDefs.AddColumn(_T("total_size"), IColumnsDefinition::eType_ulonglong); + rColumnDefs.AddColumn(_T("processed_size"), IColumnsDefinition::eType_ulonglong); + rColumnDefs.AddColumn(_T("size_speed"), IColumnsDefinition::eType_string); + rColumnDefs.AddColumn(_T("total_count"), IColumnsDefinition::eType_sizet); + rColumnDefs.AddColumn(_T("processed_count"), IColumnsDefinition::eType_sizet); + rColumnDefs.AddColumn(_T("count_speed"), IColumnsDefinition::eType_string); + rColumnDefs.AddColumn(_T("ci_processed_size"), IColumnsDefinition::eType_ulonglong); + rColumnDefs.AddColumn(_T("ci_total_size"), IColumnsDefinition::eType_ulonglong); + rColumnDefs.AddColumn(_T("timer"), IColumnsDefinition::eType_ulonglong); + rColumnDefs.AddColumn(_T("buffer_index"), IColumnsDefinition::eType_int); + rColumnDefs.AddColumn(_T("current_path"), IColumnsDefinition::eType_string); + rColumnDefs.AddColumn(_T("suboperation_type"), IColumnsDefinition::eType_int); } void TSubTaskStatsInfo::Load(const ISerializerRowReaderPtr& spRowReader) Index: src/libchcore/TSubTaskStatsInfo.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -100,7 +100,7 @@ // serialization void Store(const ISerializerRowDataPtr& spRowData) const; - static void InitLoader(IColumnsDefinition& rColumnDefs); + static void InitColumns(IColumnsDefinition& rColumnDefs); void Load(const ISerializerRowReaderPtr& spRowReader); private: Index: src/libchcore/TTaskBaseData.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TTaskBaseData.cpp (.../TTaskBaseData.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TTaskBaseData.cpp (.../TTaskBaseData.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -80,6 +80,8 @@ void TTaskBaseData::Store(const ISerializerContainerPtr& spContainer) const { + InitColumns(spContainer); + ISerializerRowDataPtr spRow; // base data @@ -110,12 +112,10 @@ void TTaskBaseData::Load(const ISerializerContainerPtr& spContainer) { + InitColumns(spContainer); + ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); - IColumnsDefinition& rColumns = spRowReader->GetColumnsDefinitions(); - if(rColumns.IsEmpty()) - rColumns % _T("name") % _T("log_path") % _T("current_state") % _T("destination_path"); - bool bResult = spRowReader->Next(); if(bResult) { @@ -130,4 +130,16 @@ m_setChanges.reset(); } +void TTaskBaseData::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + rColumns.AddColumn(_T("name"), IColumnsDefinition::eType_string); + rColumns.AddColumn(_T("log_path"), IColumnsDefinition::eType_string); + rColumns.AddColumn(_T("current_state"), IColumnsDefinition::eType_int); + rColumns.AddColumn(_T("destination_path"), IColumnsDefinition::eType_path); + } +} + END_CHCORE_NAMESPACE Index: src/libchcore/TTaskBaseData.h =================================================================== diff -u -r293e52b38d46653068006262172018a0f0d0a31c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TTaskBaseData.h (.../TTaskBaseData.h) (revision 293e52b38d46653068006262172018a0f0d0a31c) +++ src/libchcore/TTaskBaseData.h (.../TTaskBaseData.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -52,6 +52,8 @@ void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + private: enum EModifications { Index: src/libchcore/TTaskInfo.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TTaskInfo.cpp (.../TTaskInfo.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TTaskInfo.cpp (.../TTaskInfo.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -102,9 +102,11 @@ m_setModifications.reset(); } -void TTaskInfoEntry::InitLoader(IColumnsDefinition& rColumnDefs) +void TTaskInfoEntry::InitColumns(IColumnsDefinition& rColumnDefs) { - rColumnDefs % _T("id") % _T("path") % _T("task_order"); + rColumnDefs.AddColumn(_T("id"), IColumnsDefinition::eType_sizet); + rColumnDefs.AddColumn(_T("path"), IColumnsDefinition::eType_path); + rColumnDefs.AddColumn(_T("task_order"), IColumnsDefinition::eType_int); } size_t TTaskInfoEntry::GetObjectID() const @@ -201,6 +203,8 @@ void TTaskInfoContainer::Store(const ISerializerContainerPtr& spContainer) const { + InitColumns(spContainer); + spContainer->DeleteRows(m_setRemovedTasks); m_setRemovedTasks.Clear(); @@ -212,10 +216,9 @@ void TTaskInfoContainer::Load(const ISerializerContainerPtr& spContainer) { + InitColumns(spContainer); + ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); - IColumnsDefinition& rColumns = spRowReader->GetColumnsDefinitions(); - if(rColumns.IsEmpty()) - TTaskInfoEntry::InitLoader(rColumns); TTaskInfoEntry tEntry; while(spRowReader->Next()) @@ -238,4 +241,11 @@ THROW_CORE_EXCEPTION(eErr_InvalidArgument); } +void TTaskInfoContainer::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + TTaskInfoEntry::InitColumns(rColumns); +} + END_CHCORE_NAMESPACE Index: src/libchcore/TTaskInfo.h =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TTaskInfo.h (.../TTaskInfo.h) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TTaskInfo.h (.../TTaskInfo.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -63,7 +63,7 @@ void SetOrder(int iOrder); void Store(const ISerializerContainerPtr& spContainer) const; - static void InitLoader(IColumnsDefinition& rColumnDefs); + static void InitColumns(IColumnsDefinition& rColumnDefs); void Load(const ISerializerRowReaderPtr& spRowReader); void ResetModifications(); @@ -105,6 +105,8 @@ void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + void ClearModifications(); private: Index: src/libchcore/TTaskLocalStats.cpp =================================================================== diff -u -r081055369d6b332ef1651877756657973b1b2d9c -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TTaskLocalStats.cpp (.../TTaskLocalStats.cpp) (revision 081055369d6b332ef1651877756657973b1b2d9c) +++ src/libchcore/TTaskLocalStats.cpp (.../TTaskLocalStats.cpp) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -154,6 +154,7 @@ void TTaskLocalStatsInfo::Store(const ISerializerContainerPtr& spContainer) const { boost::shared_lock lock(m_lock); + InitColumns(spContainer); ISerializerRowDataPtr spRow; bool bAdded = m_setModifications[eMod_Added]; @@ -175,10 +176,7 @@ { boost::unique_lock lock(m_lock); - IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); - if(rColumns.IsEmpty()) - rColumns % _T("id") % _T("elapsed_time"); - + InitColumns(spContainer); ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); if(spRowReader->Next()) { @@ -190,4 +188,14 @@ } } +void TTaskLocalStatsInfo::InitColumns(const ISerializerContainerPtr& spContainer) const +{ + IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); + if(rColumns.IsEmpty()) + { + rColumns.AddColumn(_T("id"), IColumnsDefinition::eType_long); + rColumns.AddColumn(_T("elapsed_time"), IColumnsDefinition::eType_ulonglong); + } +} + END_CHCORE_NAMESPACE Index: src/libchcore/TTaskLocalStats.h =================================================================== diff -u -r320c4eb6ba3a38dcd6fbda6a9a12a8350a153e41 -rfc67a825635691930b3ac00dc95b16e59f3d2fae --- src/libchcore/TTaskLocalStats.h (.../TTaskLocalStats.h) (revision 320c4eb6ba3a38dcd6fbda6a9a12a8350a153e41) +++ src/libchcore/TTaskLocalStats.h (.../TTaskLocalStats.h) (revision fc67a825635691930b3ac00dc95b16e59f3d2fae) @@ -72,6 +72,8 @@ void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer); + void InitColumns(const ISerializerContainerPtr& spContainer) const; + protected: // running/not running state void MarkTaskAsRunning();