Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -r9479911a096555a7504c5c8a8eaee83ecb63440c -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -41,8 +41,7 @@ #include "../libchcore/TCoreException.h" #include "../libicpf/exception.h" #include "../libchcore/TTaskManagerStatsSnapshot.h" -#include "../libchcore/TSQLiteSerializer.h" -#include "../libchcore/TTaskManagerSchema.h" +#include "../libchcore/TSQLiteSerializerFactory.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -288,15 +287,13 @@ void CMainWnd::LoadTaskManager() { + using namespace chcore; + CString strTasksDir = GetTasksDirectory(); - CString strTMPath = strTasksDir + _T("tasks.sqlite"); + TSQLiteSerializerFactoryPtr spSerializerFactory(new TSQLiteSerializerFactory(PathFromString(strTasksDir))); - chcore::TSQLiteSerializerPtr spSerializer(new chcore::TSQLiteSerializer( - chcore::PathFromString(strTMPath), - chcore::TTaskManagerSchemaPtr(new chcore::TTaskManagerSchema))); + m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, m_pFeedbackFactory)); - m_spTasks.reset(new chcore::TTaskManager(spSerializer, m_pFeedbackFactory)); - // load last state LOG_INFO(_T("Loading existing tasks...")); Index: src/libchcore/ISerializerFactory.cpp =================================================================== diff -u -N --- src/libchcore/ISerializerFactory.cpp (revision 0) +++ src/libchcore/ISerializerFactory.cpp (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -0,0 +1,28 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "ISerializerFactory.h" + +BEGIN_CHCORE_NAMESPACE + +ISerializerFactory::~ISerializerFactory() +{ +} + +END_CHCORE_NAMESPACE Index: src/libchcore/ITaskSerializer.h =================================================================== diff -u -N --- src/libchcore/ITaskSerializer.h (revision 1342b18babc7e88850e74f46cb473a737a68f28a) +++ src/libchcore/ITaskSerializer.h (revision 0) @@ -1,39 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2013 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -#ifndef __ITASKSERIALIZER_H__ -#define __ITASKSERIALIZER_H__ - -#include "libchcore.h" -#include "TPath.h" - -BEGIN_CHCORE_NAMESPACE - -class LIBCHCORE_API ITaskSerializer -{ -public: - virtual ~ITaskSerializer() {} - - virtual TSmartPath GetLocation() const = 0; -}; - -typedef boost::shared_ptr ITaskSerializerPtr; - -END_CHCORE_NAMESPACE - -#endif Index: src/libchcore/ISerializerFactory.h =================================================================== diff -u -N --- src/libchcore/ISerializerFactory.h (revision 0) +++ src/libchcore/ISerializerFactory.h (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -0,0 +1,47 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __ISERIALIZERFACTORY_H__ +#define __ISERIALIZERFACTORY_H__ + +#include "libchcore.h" +#include "TString.h" +#include "ISerializer.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API ISerializerFactory +{ +public: + enum EObjectType + { + eObj_TaskManager, + eObj_Task + }; + +public: + virtual ~ISerializerFactory(); + + virtual ISerializerPtr CreateSerializer(EObjectType eObjType, const TString& strNameHint = _T("")) = 0; +}; + +typedef boost::shared_ptr ISerializerFactoryPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TSQLiteSerializerFactory.cpp =================================================================== diff -u -N --- src/libchcore/TSQLiteSerializerFactory.cpp (revision 0) +++ src/libchcore/TSQLiteSerializerFactory.cpp (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -0,0 +1,83 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TSQLiteSerializerFactory.h" +#include +#include +#include +#include +#include "TSQLiteTaskSchema.h" +#include "TSQLiteSerializer.h" +#include "TSQLiteTaskManagerSchema.h" +#include "TCoreException.h" +#include "ErrorCodes.h" + +BEGIN_CHCORE_NAMESPACE + +TSQLiteSerializerFactory::TSQLiteSerializerFactory(const TSmartPath& pathSerializeDir) : + m_pathSerializeDir(pathSerializeDir) +{ +} + +TSQLiteSerializerFactory::~TSQLiteSerializerFactory() +{ +} + +ISerializerPtr TSQLiteSerializerFactory::CreateSerializer(EObjectType eObjType, const TString& strNameHint) +{ + switch(eObjType) + { + case ISerializerFactory::eObj_Task: + { + TString strName(strNameHint); + if(strNameHint.IsEmpty()) + { + boost::uuids::random_generator gen; + boost::uuids::uuid u = gen(); + strName = boost::lexical_cast(u).c_str(); + } + + if(!strName.EndsWithNoCase(_T(".sqlite"))) + strName += _T(".sqlite"); + + TSmartPath pathTask(m_pathSerializeDir); + pathTask += PathFromString(strName); + + TSQLiteSerializerPtr spSerializer(new TSQLiteSerializer( + pathTask, + TSQLiteTaskSchemaPtr(new TSQLiteTaskSchema))); + + return spSerializer; + } + case ISerializerFactory::eObj_TaskManager: + { + TSmartPath pathTaskManager = m_pathSerializeDir + PathFromString(_T("tasks.sqlite")); + + TSQLiteSerializerPtr spSerializer(new TSQLiteSerializer( + pathTaskManager, + TTaskManagerSchemaPtr(new TSQLiteTaskManagerSchema))); + + return spSerializer; + } + default: + THROW_CORE_EXCEPTION(eErr_InvalidArgument); + } +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteSerializerFactory.h =================================================================== diff -u -N --- src/libchcore/TSQLiteSerializerFactory.h (revision 0) +++ src/libchcore/TSQLiteSerializerFactory.h (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -0,0 +1,44 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TSQLITESERIALIZERFACTORY_H__ +#define __TSQLITESERIALIZERFACTORY_H__ + +#include "libchcore.h" +#include "TPath.h" +#include "ISerializerFactory.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteSerializerFactory : public ISerializerFactory +{ +public: + TSQLiteSerializerFactory(const TSmartPath& pathSerializeDir); + virtual ~TSQLiteSerializerFactory(); + + virtual ISerializerPtr CreateSerializer(EObjectType eObjType, const TString& strNameHint = _T("")); + +private: + TSmartPath m_pathSerializeDir; +}; + +typedef boost::shared_ptr TSQLiteSerializerFactoryPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TSQLiteTaskManagerSchema.cpp =================================================================== diff -u -N --- src/libchcore/TSQLiteTaskManagerSchema.cpp (revision 0) +++ src/libchcore/TSQLiteTaskManagerSchema.cpp (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -0,0 +1,58 @@ +// ============================================================================ +// Copyright (C) 2001-2013 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TSQLiteTaskManagerSchema.h" +#include "TSQLiteTransaction.h" +#include "TSerializerVersion.h" +#include "TSQLiteStatement.h" + +BEGIN_CHCORE_NAMESPACE + +using namespace sqlite; + +TSQLiteTaskManagerSchema::TSQLiteTaskManagerSchema() +{ +} + +TSQLiteTaskManagerSchema::~TSQLiteTaskManagerSchema() +{ +} + +void TSQLiteTaskManagerSchema::Setup(const sqlite::TSQLiteDatabasePtr& spDatabase) +{ + TSQLiteTransaction tTransaction(spDatabase); + + // check version of the database + TSerializerVersion tVersion(spDatabase); + + // if version is 0, then this is the fresh database with (almost) no tables inside + if(tVersion.GetVersion() == 0) + { + TSQLiteStatement tStatement(spDatabase); + tStatement.Prepare(_T("CREATE TABLE tasks(task_id BIGINT UNIQUE, task_order INT, path VARCHAR(32768))")); + tStatement.Step(); + + // and finally set the database version to current one + tVersion.SetVersion(1); + } + + tTransaction.Commit(); +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TTaskManagerSchema.cpp =================================================================== diff -u -N --- src/libchcore/TTaskManagerSchema.cpp (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/libchcore/TTaskManagerSchema.cpp (revision 0) @@ -1,58 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2013 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -#include "stdafx.h" -#include "TTaskManagerSchema.h" -#include "TSQLiteTransaction.h" -#include "TSerializerVersion.h" -#include "TSQLiteStatement.h" - -BEGIN_CHCORE_NAMESPACE - -using namespace sqlite; - -TTaskManagerSchema::TTaskManagerSchema() -{ -} - -TTaskManagerSchema::~TTaskManagerSchema() -{ -} - -void TTaskManagerSchema::Setup(const sqlite::TSQLiteDatabasePtr& spDatabase) -{ - TSQLiteTransaction tTransaction(spDatabase); - - // check version of the database - TSerializerVersion tVersion(spDatabase); - - // if version is 0, then this is the fresh database with (almost) no tables inside - if(tVersion.GetVersion() == 0) - { - TSQLiteStatement tStatement(spDatabase); - tStatement.Prepare(_T("CREATE TABLE tasks(task_id BIGINT UNIQUE, task_order INT, path VARCHAR(32768))")); - tStatement.Step(); - - // and finally set the database version to current one - tVersion.SetVersion(1); - } - - tTransaction.Commit(); -} - -END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteTaskManagerSchema.h =================================================================== diff -u -N --- src/libchcore/TSQLiteTaskManagerSchema.h (revision 0) +++ src/libchcore/TSQLiteTaskManagerSchema.h (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -0,0 +1,41 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TTASKMANAGERSCHEMA_H__ +#define __TTASKMANAGERSCHEMA_H__ + +#include "libchcore.h" +#include "TSQLiteDatabase.h" +#include "ISQLiteSerializerSchema.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteTaskManagerSchema : public ISQLiteSerializerSchema +{ +public: + TSQLiteTaskManagerSchema(); + virtual ~TSQLiteTaskManagerSchema(); + + virtual void Setup(const sqlite::TSQLiteDatabasePtr& spDatabase); +}; + +typedef boost::shared_ptr TTaskManagerSchemaPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TTaskManagerSchema.h =================================================================== diff -u -N --- src/libchcore/TTaskManagerSchema.h (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/libchcore/TTaskManagerSchema.h (revision 0) @@ -1,41 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2014 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -#ifndef __TTASKMANAGERSCHEMA_H__ -#define __TTASKMANAGERSCHEMA_H__ - -#include "libchcore.h" -#include "TSQLiteDatabase.h" -#include "ISQLiteSerializerSchema.h" - -BEGIN_CHCORE_NAMESPACE - -class LIBCHCORE_API TTaskManagerSchema : public ISQLiteSerializerSchema -{ -public: - TTaskManagerSchema(); - virtual ~TTaskManagerSchema(); - - virtual void Setup(const sqlite::TSQLiteDatabasePtr& spDatabase); -}; - -typedef boost::shared_ptr TTaskManagerSchemaPtr; - -END_CHCORE_NAMESPACE - -#endif Index: src/libchcore/TSQLiteTaskSchema.cpp =================================================================== diff -u -N --- src/libchcore/TSQLiteTaskSchema.cpp (revision 0) +++ src/libchcore/TSQLiteTaskSchema.cpp (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -0,0 +1,57 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TSQLiteTaskSchema.h" +#include "TSQLiteTransaction.h" +#include "TSerializerVersion.h" + +BEGIN_CHCORE_NAMESPACE + +TSQLiteTaskSchema::TSQLiteTaskSchema() +{ +} + +TSQLiteTaskSchema::~TSQLiteTaskSchema() +{ +} + +void TSQLiteTaskSchema::Setup(const sqlite::TSQLiteDatabasePtr& spDatabase) +{ + sqlite::TSQLiteTransaction tTransaction(spDatabase); + + // check version of the database + TSerializerVersion tVersion(spDatabase); + + // if version is 0, then this is the fresh database with (almost) no tables inside + if(tVersion.GetVersion() == 0) + { +/* + TSQLiteStatement tStatement(spDatabase); + tStatement.Prepare(_T("CREATE TABLE tasks(task_id BIGINT UNIQUE, task_order INT, path VARCHAR(32768))")); + tStatement.Step(); +*/ + + // and finally set the database version to current one + tVersion.SetVersion(1); + } + + tTransaction.Commit(); +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TSQLiteTaskSchema.h =================================================================== diff -u -N --- src/libchcore/TSQLiteTaskSchema.h (revision 0) +++ src/libchcore/TSQLiteTaskSchema.h (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -0,0 +1,40 @@ +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TSQLITETASKSCHEMA_H__ +#define __TSQLITETASKSCHEMA_H__ + +#include "libchcore.h" +#include "ISQLiteSerializerSchema.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TSQLiteTaskSchema : public ISQLiteSerializerSchema +{ +public: + TSQLiteTaskSchema(); + virtual ~TSQLiteTaskSchema(); + + virtual void Setup(const sqlite::TSQLiteDatabasePtr& spDatabase); +}; + +typedef boost::shared_ptr TSQLiteTaskSchemaPtr; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TTask.h =================================================================== diff -u -N -r9479911a096555a7504c5c8a8eaee83ecb63440c -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb --- src/libchcore/TTask.h (.../TTask.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/libchcore/TTask.h (.../TTask.h) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -33,7 +33,6 @@ #include "TSubTaskArray.h" #include "TSubTaskContext.h" #include "TTaskStatsSnapshot.h" -#include "ITaskSerializer.h" #include "ISerializer.h" BEGIN_CHCORE_NAMESPACE Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -N -r9479911a096555a7504c5c8a8eaee83ecb63440c -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -30,13 +30,14 @@ //////////////////////////////////////////////////////////////////////////////// // TTaskManager members -TTaskManager::TTaskManager(const ISerializerPtr& spSerializer, IFeedbackHandlerFactory* piFeedbackHandlerFactory) : +TTaskManager::TTaskManager(const ISerializerFactoryPtr& spSerializerFactory, IFeedbackHandlerFactory* piFeedbackHandlerFactory) : m_stNextTaskID(NoTaskID + 1), - m_spSerializer(spSerializer), + m_spSerializerFactory(spSerializerFactory), m_piFeedbackFactory(piFeedbackHandlerFactory) { - if(!piFeedbackHandlerFactory) + if(!piFeedbackHandlerFactory || !spSerializerFactory) THROW_CORE_EXCEPTION(eErr_InvalidPointer); + m_spSerializer = m_spSerializerFactory->CreateSerializer(ISerializerFactory::eObj_TaskManager); } TTaskManager::~TTaskManager() @@ -47,7 +48,7 @@ TTaskPtr TTaskManager::CreateTask(const TTaskDefinition& tTaskDefinition) { IFeedbackHandler* piHandler = CreateNewFeedbackHandler(); - ISerializerPtr spSerializer;// = m_spSerializer->CreateNewTaskSerializer(tTaskDefinition.GetTaskName()); + ISerializerPtr spSerializer = m_spSerializerFactory->CreateSerializer(ISerializerFactory::eObj_Task, tTaskDefinition.GetTaskName()); TTaskPtr spTask(new TTask(spSerializer, piHandler)); spTask->SetLogPath(CreateTaskLogPath(tTaskDefinition.GetTaskName())); @@ -463,23 +464,21 @@ // not reset the modification state) m_tTasks.ClearModifications(); -/* for(size_t stIndex = 0; stIndex < m_tTasks.GetCount(); ++stIndex) { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); if(!rEntry.GetTask()) { IFeedbackHandler* piHandler = CreateNewFeedbackHandler(); - ITaskSerializerPtr spSerializer = m_spSerializer->CreateExistingTaskSerializer(rEntry.GetTaskSerializeLocation()); + ISerializerPtr spSerializer(m_spSerializerFactory->CreateSerializer(ISerializerFactory::eObj_Task, rEntry.GetTaskSerializeLocation().ToWString())); TTaskPtr spTask(new TTask(spSerializer, piHandler)); spTask->Load(); rEntry.SetTask(spTask); } } -*/ } TSmartPath TTaskManager::CreateTaskLogPath(const TString& strTaskUuid) const { Index: src/libchcore/TTaskManager.h =================================================================== diff -u -N -r9479911a096555a7504c5c8a8eaee83ecb63440c -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb --- src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -24,8 +24,8 @@ #include "TPath.h" #include "TTaskManagerStatsSnapshot.h" #include "TTaskInfo.h" -#include "ITaskManagerSerializer.h" #include "ISerializer.h" +#include "ISerializerFactory.h" BEGIN_CHCORE_NAMESPACE @@ -38,7 +38,7 @@ class LIBCHCORE_API TTaskManager { public: - TTaskManager(const ISerializerPtr& spSerializer, IFeedbackHandlerFactory* piFeedbackHandlerFactory); + TTaskManager(const ISerializerFactoryPtr& spSerializerFactory, IFeedbackHandlerFactory* piFeedbackHandlerFactory); ~TTaskManager(); void Store(); @@ -96,6 +96,7 @@ #pragma warning(push) #pragma warning(disable: 4251) ISerializerPtr m_spSerializer; + ISerializerFactoryPtr m_spSerializerFactory; #pragma warning(pop) }; Index: src/libchcore/Tests/TestsTSQLiteDatabase.cpp =================================================================== diff -u -N -r3397fd021739bea537248415a7b4fc2712dd2320 -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb --- src/libchcore/Tests/TestsTSQLiteDatabase.cpp (.../TestsTSQLiteDatabase.cpp) (revision 3397fd021739bea537248415a7b4fc2712dd2320) +++ src/libchcore/Tests/TestsTSQLiteDatabase.cpp (.../TestsTSQLiteDatabase.cpp) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -3,11 +3,12 @@ #include "gmock/gmock.h" #include "../TSQLiteDatabase.h" +using namespace chcore; using namespace chcore::sqlite; TEST(SQLiteDatabase, CreationWithVerification) { - TSQLiteDatabase db(_T(":memory:")); + TSQLiteDatabase db(PathFromString(_T(":memory:"))); EXPECT_TRUE(db.GetHandle() != NULL); EXPECT_FALSE(db.GetInTransaction()); } Index: src/libchcore/Tests/TestsTSQLiteStatement.cpp =================================================================== diff -u -N -r3397fd021739bea537248415a7b4fc2712dd2320 -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb --- src/libchcore/Tests/TestsTSQLiteStatement.cpp (.../TestsTSQLiteStatement.cpp) (revision 3397fd021739bea537248415a7b4fc2712dd2320) +++ src/libchcore/Tests/TestsTSQLiteStatement.cpp (.../TestsTSQLiteStatement.cpp) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -5,11 +5,12 @@ #include "../TSQLiteStatement.h" #include "../TSQLiteException.h" +using namespace chcore; using namespace chcore::sqlite; TEST(SQLiteStatement, CorrectPrepare) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); tStatement.Prepare(_T("CREATE TABLE test(col1 INTEGER, col2 VARCHAR(40))")); @@ -18,15 +19,15 @@ TEST(SQLiteStatement, IncorrectPrepare) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); EXPECT_THROW(tStatement.Prepare(_T("CREATE incorrect TABLE test(col1 INTEGER, col2 VARCHAR(40))")), TSQLiteException); } TEST(SQLiteStatement, PreparedStep) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); tStatement.Prepare(_T("CREATE TABLE test(col1 INTEGER, col2 VARCHAR(40))")); @@ -35,15 +36,15 @@ TEST(SQLiteStatement, UnpreparedStep) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); EXPECT_THROW(tStatement.Step(), TSQLiteException); } TEST(SQLiteStatement, UnpreparedBind) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); // insert data @@ -52,7 +53,7 @@ TEST(SQLiteStatement, InsertAndRetrieveData) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); // create schema @@ -74,7 +75,7 @@ TEST(SQLiteStatement, ClearBindings) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); // create schema Index: src/libchcore/Tests/TestsTSQLiteTransaction.cpp =================================================================== diff -u -N -r3397fd021739bea537248415a7b4fc2712dd2320 -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb --- src/libchcore/Tests/TestsTSQLiteTransaction.cpp (.../TestsTSQLiteTransaction.cpp) (revision 3397fd021739bea537248415a7b4fc2712dd2320) +++ src/libchcore/Tests/TestsTSQLiteTransaction.cpp (.../TestsTSQLiteTransaction.cpp) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -6,11 +6,12 @@ #include "../TSQLiteStatement.h" #include "../TSQLiteException.h" +using namespace chcore; using namespace chcore::sqlite; TEST(SQLiteTransaction, BeginTransactionWithDefaultRollback_Empty) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); // separate scope for the transaction { @@ -22,7 +23,7 @@ TEST(SQLiteTransaction, BeginTransactionWithDefaultRollback_WithData) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); // separate scope for the transaction @@ -44,7 +45,7 @@ TEST(SQLiteTransaction, BeginTransactionWithCommit) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); // separate scope for the transaction TSQLiteTransaction tran(spDB); @@ -55,7 +56,7 @@ TEST(SQLiteTransaction, BeginTransactionWithCommit_WithData) { - TSQLiteDatabasePtr spDB(new TSQLiteDatabase(_T(":memory:"))); + TSQLiteDatabasePtr spDB(new TSQLiteDatabase(PathFromString(_T(":memory:")))); TSQLiteStatement tStatement(spDB); // separate scope for the transaction Index: src/libchcore/Tests/TestsTaskManagerSerializer.cpp =================================================================== diff -u -N --- src/libchcore/Tests/TestsTaskManagerSerializer.cpp (revision b1ecc12ba4c1f2a7b4acd6e82fc4193535e55ff0) +++ src/libchcore/Tests/TestsTaskManagerSerializer.cpp (revision 0) @@ -1,14 +0,0 @@ -#include "stdafx.h" -#include "gtest/gtest.h" -#include "gmock/gmock.h" -#include "../TTaskManagerSerializer.h" - -using namespace chcore; - -TEST(TaskManagerSerializer, BasicTest) -{ - TTaskManagerSerializer tSerializer(PathFromString(_T("c:\\projects\\abc.sqlite")), PathFromString(_T("c:\\projects\\"))); - tSerializer.Setup(); - - EXPECT_TRUE(true); -} Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -N -r9479911a096555a7504c5c8a8eaee83ecb63440c -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 9479911a096555a7504c5c8a8eaee83ecb63440c) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) @@ -1300,27 +1300,27 @@ > + + + + @@ -1403,19 +1411,19 @@ > @@ -1503,42 +1511,6 @@ - - - - - - - - - - - - - -