Index: src/common/GTestMacros.h
===================================================================
diff -u -N
--- src/common/GTestMacros.h (revision 0)
+++ src/common/GTestMacros.h (revision 301444777085263aae7aff911dd56722f302597e)
@@ -0,0 +1,16 @@
+#ifndef __GTESTMACROS_H__
+#define __GTESTMACROS_H__
+
+#define EXPECT_TIMEOUT(handle)\
+ {\
+ DWORD dwResult = WaitForSingleObject(handle, 0); \
+ EXPECT_EQ(WAIT_TIMEOUT, dwResult); \
+ }
+
+#define EXPECT_SIGNALED(handle)\
+ {\
+ DWORD dwResult = WaitForSingleObject(handle, 0); \
+ EXPECT_EQ(WAIT_OBJECT_0 + 0, dwResult); \
+ }
+
+#endif
Index: src/libchcore/GTestMacros.h
===================================================================
diff -u -N
--- src/libchcore/GTestMacros.h (revision bef894e38e5c1486824787cf8c47a87a0828b228)
+++ src/libchcore/GTestMacros.h (revision 0)
@@ -1,16 +0,0 @@
-#ifndef __GTESTMACROS_H__
-#define __GTESTMACROS_H__
-
-#define EXPECT_TIMEOUT(handle)\
- {\
- DWORD dwResult = WaitForSingleObject(handle, 0); \
- EXPECT_EQ(WAIT_TIMEOUT, dwResult); \
- }
-
-#define EXPECT_SIGNALED(handle)\
- {\
- DWORD dwResult = WaitForSingleObject(handle, 0); \
- EXPECT_EQ(WAIT_OBJECT_0 + 0, dwResult); \
- }
-
-#endif
Index: src/libchcore/libchcore.vc140.vcxproj
===================================================================
diff -u -N -r776c47d61a5a67d5e2541d58013e221c685460ec -r301444777085263aae7aff911dd56722f302597e
--- src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision 776c47d61a5a67d5e2541d58013e221c685460ec)
+++ src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -473,7 +473,7 @@
-
+
Index: src/libchcore/libchcore.vc140.vcxproj.filters
===================================================================
diff -u -N -r776c47d61a5a67d5e2541d58013e221c685460ec -r301444777085263aae7aff911dd56722f302597e
--- src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision 776c47d61a5a67d5e2541d58013e221c685460ec)
+++ src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -77,9 +77,6 @@
Source Files\Tools
-
- Tests
-
Source Files\Tools\Timers
@@ -105,6 +102,9 @@
Source Files\Shared
+
+ Tests
+
Index: src/libchengine/GTestMacros.h
===================================================================
diff -u -N
--- src/libchengine/GTestMacros.h (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/GTestMacros.h (revision 0)
@@ -1,16 +0,0 @@
-#ifndef __GTESTMACROS_H__
-#define __GTESTMACROS_H__
-
-#define EXPECT_TIMEOUT(handle)\
- {\
- DWORD dwResult = WaitForSingleObject(handle, 0); \
- EXPECT_EQ(WAIT_TIMEOUT, dwResult); \
- }
-
-#define EXPECT_SIGNALED(handle)\
- {\
- DWORD dwResult = WaitForSingleObject(handle, 0); \
- EXPECT_EQ(WAIT_OBJECT_0 + 0, dwResult); \
- }
-
-#endif
Index: src/libchengine/TOverlappedThreadPool.cpp
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/TOverlappedThreadPool.cpp (.../TOverlappedThreadPool.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TOverlappedThreadPool.cpp (.../TOverlappedThreadPool.cpp) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -21,12 +21,6 @@
namespace chengine
{
- TOverlappedThreadPool::TOverlappedThreadPool(HANDLE hKill) :
- m_threadReader(hKill),
- m_threadWriter(hKill)
- {
- }
-
TReaderThread& TOverlappedThreadPool::ReaderThread()
{
return m_threadReader;
Index: src/libchengine/TOverlappedThreadPool.h
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/TOverlappedThreadPool.h (.../TOverlappedThreadPool.h) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TOverlappedThreadPool.h (.../TOverlappedThreadPool.h) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -32,8 +32,6 @@
class TOverlappedThreadPool
{
public:
- explicit TOverlappedThreadPool(HANDLE hKill);
-
TReaderThread& ReaderThread();
TWriterThread& WriterThread();
Index: src/libchengine/TPlainStringPool.cpp
===================================================================
diff -u -N
--- src/libchengine/TPlainStringPool.cpp (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TPlainStringPool.cpp (revision 0)
@@ -1,96 +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.
-// ============================================================================
-#include "stdafx.h"
-#include "TPlainStringPool.h"
-#include "../libchcore/TCoreException.h"
-
-using namespace chcore;
-
-namespace chengine
-{
- TPlainStringPool::TPlainStringPool()
- {
- }
-
- TPlainStringPool::~TPlainStringPool()
- {
- Clear();
- }
-
- wchar_t* TPlainStringPool::Alloc(size_t stCount)
- {
- if (stCount > BlockSize)
- throw chcore::TCoreException(chcore::eErr_InvalidArgument, L"stCount", LOCATION);
-
- // find block where the new string would fit
- size_t stBlockCount = m_vBlocks.size();
- for (size_t stIndex = 0; stIndex < stBlockCount; ++stIndex)
- {
- if (m_vBlocks[stIndex].second >= stCount)
- {
- wchar_t* pszResult = m_vBlocks[stIndex].first + BlockSize - m_vBlocks[stIndex].second;
- m_vBlocks[stIndex].second -= stCount;
- return pszResult;
- }
- }
-
- wchar_t* pszBuffer = AllocNewBlock();
- m_vBlocks.back().second -= stCount;
-
- return pszBuffer;
- }
-
- wchar_t* TPlainStringPool::AllocForString(const wchar_t* pszString)
- {
- size_t stLen = wcslen(pszString) + 1;
-
- wchar_t* pszBuffer = Alloc(stLen);
- wmemcpy_s(pszBuffer, BlockSize, pszString, stLen);
-
- return pszBuffer;
- }
-
- void TPlainStringPool::Clear(bool bLeaveSingleEmptyBlock)
- {
- size_t stBlockCount = m_vBlocks.size();
- for (size_t stIndex = 0; stIndex < stBlockCount; ++stIndex)
- {
- if (!bLeaveSingleEmptyBlock || stIndex != 0)
- {
- delete[] m_vBlocks[stIndex].first;
- }
- }
-
- if (bLeaveSingleEmptyBlock)
- {
- if (m_vBlocks.size() > 1)
- m_vBlocks.erase(m_vBlocks.begin() + 1, m_vBlocks.end());
- }
- else
- m_vBlocks.clear();
- }
-
- wchar_t* TPlainStringPool::AllocNewBlock()
- {
- wchar_t* pszBlock = new wchar_t[BlockSize];
- m_vBlocks.push_back(std::make_pair(pszBlock, BlockSize));
-
- return pszBlock;
- }
-}
Index: src/libchengine/TPlainStringPool.h
===================================================================
diff -u -N
--- src/libchengine/TPlainStringPool.h (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TPlainStringPool.h (revision 0)
@@ -1,54 +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 __TPLAINSTRINGPOOL_H__
-#define __TPLAINSTRINGPOOL_H__
-
-#include "libchengine.h"
-
-namespace chengine
-{
- class LIBCHENGINE_API TPlainStringPool
- {
- public:
- static const size_t BlockSize = 256 * 1024;
-
- public:
- TPlainStringPool();
- TPlainStringPool(const TPlainStringPool&) = delete;
- ~TPlainStringPool();
-
- TPlainStringPool& operator=(const TPlainStringPool&) = delete;
-
- wchar_t* Alloc(size_t stCount);
- wchar_t* AllocForString(const wchar_t* pszString);
-
- void Clear(bool bLeaveSingleEmptyBlock = true);
-
- private:
- wchar_t* AllocNewBlock();
-
- private:
-#pragma warning(push)
-#pragma warning(disable: 4251)
- std::vector > m_vBlocks; // memory blocks of size BlockSize => remaining size
-#pragma warning(pop)
- };
-}
-
-#endif
Index: src/libchengine/TSQLiteDatabase.cpp
===================================================================
diff -u -N
--- src/libchengine/TSQLiteDatabase.cpp (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TSQLiteDatabase.cpp (revision 0)
@@ -1,71 +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 "TSQLiteDatabase.h"
-#include "sqlite3/sqlite3.h"
-#include "../libchcore/ErrorCodes.h"
-#include "TSQLiteException.h"
-
-using namespace chcore;
-
-namespace chengine
-{
- namespace sqlite
- {
- TSQLiteDatabase::TSQLiteDatabase(const TSmartPath& pathDatabase) :
- m_pathDatabase(pathDatabase),
- m_pDBHandle(nullptr),
- m_bInTransaction(false)
- {
- int iResult = sqlite3_open16(m_pathDatabase.ToString(), &m_pDBHandle);
- if (iResult != SQLITE_OK)
- {
- const wchar_t* pszMsg = (const wchar_t*)sqlite3_errmsg16(m_pDBHandle);
- throw TSQLiteException(eErr_SQLiteCannotOpenDatabase, iResult, pszMsg, LOCATION);
- }
- }
-
- TSQLiteDatabase::~TSQLiteDatabase()
- {
- int iResult = sqlite3_close_v2(m_pDBHandle); // handles properly the nullptr DB Handle
- iResult;
- _ASSERTE(iResult == SQLITE_OK);
- }
-
- HANDLE TSQLiteDatabase::GetHandle()
- {
- return m_pDBHandle;
- }
-
- bool TSQLiteDatabase::GetInTransaction() const
- {
- return m_bInTransaction;
- }
-
- void TSQLiteDatabase::SetInTransaction(bool bInTransaction)
- {
- m_bInTransaction = bInTransaction;
- }
-
- TSmartPath TSQLiteDatabase::GetLocation() const
- {
- return m_pathDatabase;
- }
- }
-}
Index: src/libchengine/TSQLiteDatabase.h
===================================================================
diff -u -N
--- src/libchengine/TSQLiteDatabase.h (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TSQLiteDatabase.h (revision 0)
@@ -1,60 +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 __TSQLITEDATABASE_H__
-#define __TSQLITEDATABASE_H__
-
-#include "../libchcore/TPath.h"
-
-struct sqlite3;
-
-namespace chengine
-{
- namespace sqlite
- {
- class TSQLiteDatabase
- {
- public:
- explicit TSQLiteDatabase(const chcore::TSmartPath& strFilename);
- TSQLiteDatabase(const TSQLiteDatabase&) = delete;
- ~TSQLiteDatabase();
-
- TSQLiteDatabase& operator=(const TSQLiteDatabase&) = delete;
-
- HANDLE GetHandle();
-
- chcore::TSmartPath GetLocation() const;
-
- bool GetInTransaction() const;
-
- protected:
- void SetInTransaction(bool bInTransaction);
-
- private:
- chcore::TSmartPath m_pathDatabase;
- sqlite3* m_pDBHandle;
- bool m_bInTransaction; // global transaction state
-
- friend class TSQLiteTransaction;
- };
-
- typedef std::shared_ptr TSQLiteDatabasePtr;
- }
-}
-
-#endif
Index: src/libchengine/TSQLiteException.cpp
===================================================================
diff -u -N
--- src/libchengine/TSQLiteException.cpp (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TSQLiteException.cpp (revision 0)
@@ -1,37 +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 "TSQLiteException.h"
-
-namespace chengine
-{
- namespace sqlite
- {
- TSQLiteException::TSQLiteException(chcore::EGeneralErrors eErrorCode, int iSQLiteError, const wchar_t* pszMsg, const wchar_t* pszFile, size_t stLineNumber, const wchar_t* pszFunction) :
- TBaseException(eErrorCode, pszMsg, pszFile, stLineNumber, pszFunction),
- m_iSQLiteError(iSQLiteError)
- {
- }
-
- int TSQLiteException::GetSQLiteError() const
- {
- return m_iSQLiteError;
- }
- }
-}
Index: src/libchengine/TSQLiteException.h
===================================================================
diff -u -N
--- src/libchengine/TSQLiteException.h (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TSQLiteException.h (revision 0)
@@ -1,41 +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 __TSQLITEEXCEPTION_H__
-#define __TSQLITEEXCEPTION_H__
-
-#include "../libchcore/TBaseException.h"
-
-namespace chengine
-{
- namespace sqlite
- {
- class TSQLiteException : public chcore::TBaseException
- {
- public:
- TSQLiteException(chcore::EGeneralErrors eErrorCode, int iSQLiteError, const wchar_t* pszMsg, const wchar_t* pszFile, size_t stLineNumber, const wchar_t* pszFunction);
-
- int GetSQLiteError() const;
-
- private:
- int m_iSQLiteError;
- };
- }
-}
-
-#endif
Index: src/libchengine/TSQLiteStatement.cpp
===================================================================
diff -u -N
--- src/libchengine/TSQLiteStatement.cpp (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TSQLiteStatement.cpp (revision 0)
@@ -1,348 +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 "TSQLiteStatement.h"
-#include "sqlite3/sqlite3.h"
-#include "TSQLiteException.h"
-#include
-
-using namespace chcore;
-using namespace string;
-
-namespace chengine
-{
- namespace sqlite
- {
- TSQLiteStatement::TSQLiteStatement(const TSQLiteDatabasePtr& spDatabase) :
- m_pStatement(nullptr),
- m_spDatabase(spDatabase),
- m_bHasRow(false)
- {
- if (!m_spDatabase)
- throw TSQLiteException(eErr_InvalidArgument, 0, _T("Invalid database provided"), LOCATION);
- }
-
- TSQLiteStatement::~TSQLiteStatement()
- {
- int iResult = sqlite3_finalize(m_pStatement);
- _ASSERTE(iResult == SQLITE_OK); iResult;
- }
-
- void TSQLiteStatement::Close()
- {
- if (m_pStatement != nullptr)
- {
- int iResult = sqlite3_finalize(m_pStatement);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteFinalizeError, iResult, _T("Cannot finalize statement"), LOCATION);
- m_pStatement = nullptr;
- }
- m_bHasRow = false;
- }
-
- void TSQLiteStatement::Prepare(PCWSTR pszQuery)
- {
- Close();
-
- int iResult = sqlite3_prepare16_v2((sqlite3*)m_spDatabase->GetHandle(), pszQuery, -1, &m_pStatement, nullptr);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLitePrepareError, iResult, (PCTSTR)sqlite3_errmsg16((sqlite3*)m_spDatabase->GetHandle()), LOCATION);
- }
-
- TSQLiteStatement::EStepResult TSQLiteStatement::Step()
- {
- m_bHasRow = false;
-
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
-
- int iResult = sqlite3_step(m_pStatement);
- switch (iResult)
- {
- case SQLITE_ROW:
- m_bHasRow = true;
- return eStep_HasRow;
- case SQLITE_OK:
- case SQLITE_DONE:
- Reset();
- return eStep_Finished;
- default:
- {
- const wchar_t* pszErrMsg = (const wchar_t*)sqlite3_errmsg16((sqlite3*)m_spDatabase->GetHandle());
- const size_t stMaxSize = 1024;
- wchar_t szText[stMaxSize];
- _snwprintf_s(szText, stMaxSize, _TRUNCATE, L"Cannot perform step on the statement. SQLite reported error: %s", pszErrMsg);
- throw TSQLiteException(eErr_SQLiteStepError, iResult, szText, LOCATION);
- }
- }
- }
-
- int TSQLiteStatement::Changes()
- {
- return sqlite3_changes((sqlite3*)m_spDatabase->GetHandle());
- }
-
- void TSQLiteStatement::BindValue(int iColumn, bool bValue)
- {
- BindValue(iColumn, bValue ? 1 : 0);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, short siValue)
- {
- BindValue(iColumn, (int)siValue);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, unsigned short usiValue)
- {
- BindValue(iColumn, (unsigned int)usiValue);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, int iValue)
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
-
- int iResult = sqlite3_bind_int(m_pStatement, iColumn, iValue);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteBindError, iResult, _T("Cannot bind a parameter"), LOCATION);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, unsigned int uiValue)
- {
- BindValue(iColumn, *(int*)&uiValue);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, long lValue)
- {
- BindValue(iColumn, boost::numeric_cast(lValue));
- }
-
- void TSQLiteStatement::BindValue(int iColumn, unsigned long ulValue)
- {
- BindValue(iColumn, boost::numeric_cast(ulValue));
- }
-
- void TSQLiteStatement::BindValue(int iColumn, long long llValue)
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
-
- int iResult = sqlite3_bind_int64(m_pStatement, iColumn, llValue);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteBindError, iResult, _T("Cannot bind a parameter"), LOCATION);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, unsigned long long ullValue)
- {
- BindValue(iColumn, *(long long*)&ullValue);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, double dValue)
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
-
- int iResult = sqlite3_bind_double(m_pStatement, iColumn, dValue);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteBindError, iResult, _T("Cannot bind a parameter"), LOCATION);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, PCTSTR pszText)
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
-
- int iResult = sqlite3_bind_text16(m_pStatement, iColumn, pszText, -1, SQLITE_TRANSIENT);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteBindError, iResult, _T("Cannot bind a parameter"), LOCATION);
- }
-
- void TSQLiteStatement::BindValue(int iColumn, const TString& strText)
- {
- BindValue(iColumn, strText.c_str());
- }
-
- void TSQLiteStatement::BindValue(int iColumn, const TSmartPath& path)
- {
- BindValue(iColumn, path.ToString());
- }
-
- bool TSQLiteStatement::GetBool(int iCol)
- {
- return GetInt(iCol) != 0;
- }
-
- short TSQLiteStatement::GetShort(int iCol)
- {
- return boost::numeric_cast(GetInt(iCol));
- }
-
- unsigned short TSQLiteStatement::GetUShort(int iCol)
- {
- return boost::numeric_cast(GetUInt(iCol));
- }
-
- int TSQLiteStatement::GetInt(int iCol)
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
- if (!m_bHasRow)
- throw TSQLiteException(eErr_SQLiteNoRowAvailable, 0, _T("No row available"), LOCATION);
-
- return sqlite3_column_int(m_pStatement, iCol);
- }
-
- unsigned int TSQLiteStatement::GetUInt(int iCol)
- {
- int iVal = GetInt(iCol);
- return *(unsigned int*)&iVal;
- }
-
- long TSQLiteStatement::GetLong(int iCol)
- {
- return boost::numeric_cast(GetInt(iCol));
- }
-
- unsigned long TSQLiteStatement::GetULong(int iCol)
- {
- return boost::numeric_cast(GetUInt(iCol));
- }
-
- long long TSQLiteStatement::GetInt64(int iCol)
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
- if (!m_bHasRow)
- throw TSQLiteException(eErr_SQLiteNoRowAvailable, 0, _T("No row available"), LOCATION);
-
- return sqlite3_column_int64(m_pStatement, iCol);
- }
-
- unsigned long long TSQLiteStatement::GetUInt64(int iCol)
- {
- long long llVal = GetInt64(iCol);
- return *(unsigned long long*)&llVal;
- }
-
- double TSQLiteStatement::GetDouble(int iCol)
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
- if (!m_bHasRow)
- throw TSQLiteException(eErr_SQLiteNoRowAvailable, 0, _T("No row available"), LOCATION);
-
- return sqlite3_column_double(m_pStatement, iCol);
- }
-
- TString TSQLiteStatement::GetText(int iCol)
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
- if (!m_bHasRow)
- throw TSQLiteException(eErr_SQLiteNoRowAvailable, 0, _T("No row available"), LOCATION);
-
- return TString((const wchar_t*)sqlite3_column_text16(m_pStatement, iCol));
- }
-
- TSmartPath TSQLiteStatement::GetPath(int iCol)
- {
- return PathFromWString(GetText(iCol));
- }
-
- void TSQLiteStatement::ClearBindings()
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
-
- int iResult = sqlite3_clear_bindings(m_pStatement);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteBindError, iResult, _T("Cannot clear bindings"), LOCATION);
- }
-
- void TSQLiteStatement::Reset()
- {
- if (!m_pStatement)
- throw TSQLiteException(eErr_SQLiteStatementNotPrepared, 0, _T("Tried to step on unprepared statement"), LOCATION);
-
- int iResult = sqlite3_reset(m_pStatement);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteBindError, iResult, _T("Cannot reset statement"), LOCATION);
- }
-
- void TSQLiteStatement::GetValue(int iCol, bool& bValue)
- {
- bValue = GetBool(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, short& iValue)
- {
- iValue = GetShort(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, unsigned short& uiValue)
- {
- uiValue = GetUShort(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, int& iValue)
- {
- iValue = GetInt(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, unsigned int& uiValue)
- {
- uiValue = GetUInt(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, long& lValue)
- {
- lValue = GetLong(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, unsigned long& ulValue)
- {
- ulValue = GetULong(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, long long& llValue)
- {
- llValue = GetInt64(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, unsigned long long& ullValue)
- {
- ullValue = GetUInt64(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, double& dValue)
- {
- dValue = GetDouble(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, TString& strValue)
- {
- strValue = GetText(iCol);
- }
-
- void TSQLiteStatement::GetValue(int iCol, TSmartPath& pathValue)
- {
- pathValue = GetPath(iCol);
- }
- }
-}
Index: src/libchengine/TSQLiteStatement.h
===================================================================
diff -u -N
--- src/libchengine/TSQLiteStatement.h (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TSQLiteStatement.h (revision 0)
@@ -1,108 +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 __TSQLITESTATEMENT_H__
-#define __TSQLITESTATEMENT_H__
-
-#include "TSQLiteDatabase.h"
-
-struct sqlite3_stmt;
-
-namespace chengine
-{
- namespace sqlite
- {
- typedef std::shared_ptr SQLiteStatementHandle;
-
- class TSQLiteStatement
- {
- public:
- enum EStepResult
- {
- eStep_Finished,
- eStep_HasRow
- };
-
- public:
- explicit TSQLiteStatement(const TSQLiteDatabasePtr& spDatabase);
- TSQLiteStatement(const TSQLiteStatement&) = delete;
- ~TSQLiteStatement();
-
- TSQLiteStatement& operator=(const TSQLiteStatement&) = delete;
-
- void Close();
-
- void Prepare(PCWSTR pszQuery);
-
- void BindValue(int iColumn, bool bValue);
- void BindValue(int iColumn, short siValue);
- void BindValue(int iColumn, unsigned short usiValue);
- void BindValue(int iColumn, int iValue);
- void BindValue(int iColumn, unsigned int uiValue);
- void BindValue(int iColumn, long lValue);
- void BindValue(int iColumn, unsigned long ulValue);
- void BindValue(int iColumn, long long llValue);
- void BindValue(int iColumn, unsigned long long ullValue);
- void BindValue(int iColumn, double dValue);
- void BindValue(int iColumn, PCTSTR pszText);
- void BindValue(int iColumn, const string::TString& strText);
- void BindValue(int iColumn, const chcore::TSmartPath& path);
-
- void ClearBindings();
-
- EStepResult Step();
- int Changes();
- void Reset();
-
- bool GetBool(int iCol);
- short GetShort(int iCol);
- unsigned short GetUShort(int iCol);
- int GetInt(int iCol);
- unsigned int GetUInt(int iCol);
- long GetLong(int iCol);
- unsigned long GetULong(int iCol);
- long long GetInt64(int iCol);
- unsigned long long GetUInt64(int iCol);
- double GetDouble(int iCol);
- string::TString GetText(int iCol);
- chcore::TSmartPath GetPath(int iCol);
-
- void GetValue(int iCol, bool& bValue);
- void GetValue(int iCol, short& iValue);
- void GetValue(int iCol, unsigned short& uiValue);
- void GetValue(int iCol, int& iValue);
- void GetValue(int iCol, unsigned int& uiValue);
- void GetValue(int iCol, long& lValue);
- void GetValue(int iCol, unsigned long& ulValue);
- void GetValue(int iCol, long long& llValue);
- void GetValue(int iCol, unsigned long long& ullValue);
- void GetValue(int iCol, double& dValue);
- void GetValue(int iCol, string::TString& strValue);
- void GetValue(int iCol, chcore::TSmartPath& pathValue);
-
- private:
- sqlite3_stmt* m_pStatement;
- TSQLiteDatabasePtr m_spDatabase;
- bool m_bHasRow;
- };
-
- typedef std::shared_ptr TSQLiteStatementPtr;
- }
-}
-
-#endif
Index: src/libchengine/TSQLiteTransaction.cpp
===================================================================
diff -u -N
--- src/libchengine/TSQLiteTransaction.cpp (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TSQLiteTransaction.cpp (revision 0)
@@ -1,101 +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 "TSQLiteTransaction.h"
-#include "TSQLiteException.h"
-#include "sqlite3/sqlite3.h"
-
-using namespace chcore;
-
-namespace chengine
-{
- namespace sqlite
- {
- TSQLiteTransaction::TSQLiteTransaction(const TSQLiteDatabasePtr& spDatabase) :
- m_spDatabase(spDatabase),
- m_bTransactionStarted(false)
- {
- if (!m_spDatabase)
- throw TSQLiteException(eErr_InvalidArgument, 0, _T("Invalid database provided"), LOCATION);
- Begin();
- }
-
- TSQLiteTransaction::~TSQLiteTransaction()
- {
- // try to rollback the transaction; this is the last resort
- if (m_bTransactionStarted && m_spDatabase->GetInTransaction())
- {
- int iResult = sqlite3_exec((sqlite3*)m_spDatabase->GetHandle(), "ROLLBACK TRANSACTION;", nullptr, nullptr, nullptr);
- iResult;
- _ASSERTE(iResult == SQLITE_OK);
- m_spDatabase->SetInTransaction(false);
- }
- }
-
- void TSQLiteTransaction::Begin()
- {
- if (m_spDatabase->GetInTransaction())
- return;
-
- if (m_bTransactionStarted)
- throw TSQLiteException(eErr_SQLiteCannotBeginTransaction, 0, _T("Transaction already started"), LOCATION);
-
- int iResult = sqlite3_exec((sqlite3*)m_spDatabase->GetHandle(), "BEGIN TRANSACTION", nullptr, nullptr, nullptr);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteCannotBeginTransaction, iResult, _T("Cannot begin transaction"), LOCATION);
-
- m_spDatabase->SetInTransaction(true);
- m_bTransactionStarted = true;
- }
-
- void TSQLiteTransaction::Rollback()
- {
- // no transactions whatsoever (even on database)
- if (!m_bTransactionStarted && !m_spDatabase->GetInTransaction())
- throw TSQLiteException(eErr_SQLiteCannotRollbackTransaction, 0, _T("Transaction not started"), LOCATION);
-
- // database has transaction started, but not by this object
- if (!m_bTransactionStarted)
- return;
-
- int iResult = sqlite3_exec((sqlite3*)m_spDatabase->GetHandle(), "ROLLBACK TRANSACTION;", nullptr, nullptr, nullptr);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteCannotRollbackTransaction, iResult, _T("Cannot rollback transaction"), LOCATION);
- m_spDatabase->SetInTransaction(false);
- m_bTransactionStarted = false;
- }
-
- void TSQLiteTransaction::Commit()
- {
- // no transactions whatsoever (even on database)
- if (!m_bTransactionStarted && !m_spDatabase->GetInTransaction())
- throw TSQLiteException(eErr_SQLiteCannotRollbackTransaction, 0, _T("Transaction not started"), LOCATION);
-
- // database has transaction started, but not by this object
- if (!m_bTransactionStarted)
- return;
-
- int iResult = sqlite3_exec((sqlite3*)m_spDatabase->GetHandle(), "COMMIT TRANSACTION;", nullptr, nullptr, nullptr);
- if (iResult != SQLITE_OK)
- throw TSQLiteException(eErr_SQLiteCannotCommitTransaction, iResult, _T("Cannot commit transaction"), LOCATION);
- m_spDatabase->SetInTransaction(false);
- m_bTransactionStarted = false;
- }
- }
-}
Index: src/libchengine/TSQLiteTransaction.h
===================================================================
diff -u -N
--- src/libchengine/TSQLiteTransaction.h (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TSQLiteTransaction.h (revision 0)
@@ -1,48 +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 __TSQLITETRANSACTION_H__
-#define __TSQLITETRANSACTION_H__
-
-#include "TSQLiteDatabase.h"
-
-namespace chengine
-{
- namespace sqlite
- {
- class TSQLiteTransaction
- {
- public:
- explicit TSQLiteTransaction(const TSQLiteDatabasePtr& spDatabase);
- TSQLiteTransaction(const TSQLiteTransaction&) = delete;
- ~TSQLiteTransaction();
-
- TSQLiteTransaction& operator=(const TSQLiteTransaction&) = delete;
-
- void Begin();
- void Rollback();
- void Commit();
-
- private:
- TSQLiteDatabasePtr m_spDatabase;
- bool m_bTransactionStarted; // states if transaction was started by this object
- };
- }
-}
-
-#endif
Index: src/libchengine/TSubTaskCopyMove.cpp
===================================================================
diff -u -N -r85b07e753393f661f7d8f528e4238ebb6e9e1204 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 85b07e753393f661f7d8f528e4238ebb6e9e1204)
+++ src/libchengine/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -168,7 +168,7 @@
LOG_INFO(m_spLog) << strFormat.c_str();
- TOverlappedThreadPool threadPool(rThreadController.GetKillThreadHandle());
+ TOverlappedThreadPool threadPool;
for(; fcIndex < fcSize; fcIndex++)
{
Index: src/libchengine/TThreadedQueueRunner.h
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/TThreadedQueueRunner.h (.../TThreadedQueueRunner.h) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/TThreadedQueueRunner.h (.../TThreadedQueueRunner.h) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -30,8 +30,7 @@
class TThreadedQueueRunner
{
public:
- explicit TThreadedQueueRunner(HANDLE hKill) :
- m_hKill(hKill),
+ explicit TThreadedQueueRunner() :
m_eventLocalKill(true, false)
{
}
@@ -107,7 +106,6 @@
private:
WaitableQueue m_queue;
std::thread m_thread;
- HANDLE m_hKill = nullptr;
TEvent m_eventLocalKill;
};
}
Index: src/libchengine/Tests/TOrderedBufferQueueTests.cpp
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/Tests/TOrderedBufferQueueTests.cpp (.../TOrderedBufferQueueTests.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/Tests/TOrderedBufferQueueTests.cpp (.../TOrderedBufferQueueTests.cpp) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "../TOrderedBufferQueue.h"
-#include "../GTestMacros.h"
+#include "../../common/GTestMacros.h"
class FallbackCollection : public std::vector
{
Index: src/libchengine/Tests/TOverlappedReaderTests.cpp
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/Tests/TOverlappedReaderTests.cpp (.../TOverlappedReaderTests.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/Tests/TOverlappedReaderTests.cpp (.../TOverlappedReaderTests.cpp) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -3,7 +3,7 @@
#include "gmock/gmock.h"
#include "../TOverlappedDataBuffer.h"
#include "../../liblogger/TLogFileData.h"
-#include "../GTestMacros.h"
+#include "../../common/GTestMacros.h"
#include "../TOverlappedMemoryPool.h"
#include "../TOverlappedReader.h"
Index: src/libchengine/Tests/TOverlappedWriterTests.cpp
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/Tests/TOverlappedWriterTests.cpp (.../TOverlappedWriterTests.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/Tests/TOverlappedWriterTests.cpp (.../TOverlappedWriterTests.cpp) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -2,7 +2,7 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "../TOverlappedWriter.h"
-#include "../GTestMacros.h"
+#include "../../common/GTestMacros.h"
using namespace chengine;
Index: src/libchengine/Tests/TReadBufferQueueWrapperTests.cpp
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/Tests/TReadBufferQueueWrapperTests.cpp (.../TReadBufferQueueWrapperTests.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/Tests/TReadBufferQueueWrapperTests.cpp (.../TReadBufferQueueWrapperTests.cpp) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -3,7 +3,7 @@
#include "gmock/gmock.h"
#include "../TReadBufferQueueWrapper.h"
#include
-#include "../GTestMacros.h"
+#include "../../common/GTestMacros.h"
using namespace chengine;
using namespace chcore;
Index: src/libchengine/Tests/TWriteBufferQueueWrapperTests.cpp
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/Tests/TWriteBufferQueueWrapperTests.cpp (.../TWriteBufferQueueWrapperTests.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/Tests/TWriteBufferQueueWrapperTests.cpp (.../TWriteBufferQueueWrapperTests.cpp) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -3,7 +3,7 @@
#include "gmock/gmock.h"
#include "../TWriteBufferQueueWrapper.h"
#include
-#include "../GTestMacros.h"
+#include "../../common/GTestMacros.h"
using namespace chengine;
using namespace chcore;
Index: src/libchengine/Tests/TestsTThreadedQueueRunner.cpp
===================================================================
diff -u -N
--- src/libchengine/Tests/TestsTThreadedQueueRunner.cpp (revision 0)
+++ src/libchengine/Tests/TestsTThreadedQueueRunner.cpp (revision 301444777085263aae7aff911dd56722f302597e)
@@ -0,0 +1,60 @@
+#include "stdafx.h"
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "../TThreadedQueueRunner.h"
+#include "../TEvent.h"
+
+using namespace chengine;
+
+static void TestFunction(int& val)
+{
+ ++val;
+}
+
+static void TestFunctionWithSleep(int& val)
+{
+ ++val;
+ Sleep(50);
+}
+
+TEST(TestsTThreadedQueueRunner, PushSingleTask)
+{
+ TThreadedQueueRunner> runner;
+
+ int iValue = 0;
+ runner.PushTask(std::function(std::bind(&TestFunction, std::ref(iValue))));
+ runner.Stop();
+
+ EXPECT_EQ(1, iValue);
+}
+
+TEST(TestsTThreadedQueueRunner, PushMultipleTasks)
+{
+ TThreadedQueueRunner> runner;
+
+ int iValue = 0;
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.Stop();
+
+ EXPECT_EQ(5, iValue);
+}
+
+TEST(TestsTThreadedQueueRunner, PushMultipleTasksWithPreemptiveStart)
+{
+ TThreadedQueueRunner> runner;
+ runner.Start();
+
+ int iValue = 0;
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.PushTask(std::function(std::bind(&TestFunctionWithSleep, std::ref(iValue))));
+ runner.Stop();
+
+ EXPECT_EQ(5, iValue);
+}
Index: src/libchengine/Tests/TestsWaitableQueue.cpp
===================================================================
diff -u -N
--- src/libchengine/Tests/TestsWaitableQueue.cpp (revision 0)
+++ src/libchengine/Tests/TestsWaitableQueue.cpp (revision 301444777085263aae7aff911dd56722f302597e)
@@ -0,0 +1,28 @@
+#include "stdafx.h"
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "../WaitableQueue.h"
+#include "../../common/GTestMacros.h"
+
+using namespace chengine;
+
+TEST(TestsWaitableQueue, DefaultConstruction)
+{
+ WaitableQueue queue;
+ EXPECT_TRUE(queue.GetWaitHandle() != INVALID_HANDLE_VALUE);
+ EXPECT_TIMEOUT(queue.GetWaitHandle());
+}
+
+TEST(TestsWaitableQueue, PopFrom_EmptyContainer)
+{
+ WaitableQueue queue;
+ EXPECT_THROW(queue.PopFront(), std::exception);
+}
+
+TEST(TestsWaitableQueue, Push)
+{
+ WaitableQueue queue;
+ queue.PushBack(5);
+ EXPECT_SIGNALED(queue.GetWaitHandle());
+ EXPECT_EQ(5, queue.PopFront());
+}
Index: src/libchengine/WaitableQueue.h
===================================================================
diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/WaitableQueue.h (.../WaitableQueue.h) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libchengine/WaitableQueue.h (.../WaitableQueue.h) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -23,6 +23,8 @@
#include
#include
#include "TEvent.h"
+#include "..\libchcore\ErrorCodes.h"
+#include "..\libchcore\TCoreException.h"
namespace chengine
{
@@ -46,6 +48,9 @@
{
std::lock_guard lock(m_lock);
+ if (m_queue.empty())
+ throw chcore::TCoreException(chcore::eErr_BoundsExceeded, L"Tried to pop from empty container", LOCATION);
+
T value = std::move(m_queue.front());
m_queue.pop_front();
Index: src/libchengine/libchengine.vcxproj
===================================================================
diff -u -N -r85b07e753393f661f7d8f528e4238ebb6e9e1204 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/libchengine.vcxproj (.../libchengine.vcxproj) (revision 85b07e753393f661f7d8f528e4238ebb6e9e1204)
+++ src/libchengine/libchengine.vcxproj (.../libchengine.vcxproj) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -471,6 +471,7 @@
+
@@ -480,7 +481,6 @@
-
@@ -506,13 +506,13 @@
+
-
@@ -521,16 +521,11 @@
-
-
-
-
-
@@ -643,6 +638,18 @@
true
true
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
true
true
@@ -711,15 +718,10 @@
-
-
-
-
-
Index: src/libchengine/libchengine.vcxproj.filters
===================================================================
diff -u -N -r85b07e753393f661f7d8f528e4238ebb6e9e1204 -r301444777085263aae7aff911dd56722f302597e
--- src/libchengine/libchengine.vcxproj.filters (.../libchengine.vcxproj.filters) (revision 85b07e753393f661f7d8f528e4238ebb6e9e1204)
+++ src/libchengine/libchengine.vcxproj.filters (.../libchengine.vcxproj.filters) (revision 301444777085263aae7aff911dd56722f302597e)
@@ -27,9 +27,6 @@
{1fddd996-c723-4b09-9c98-868df98fe204}
-
- {e6da867d-b0bd-42d5-a0c8-43542984582f}
-
{e4894f9f-1e1d-451a-9a02-60b9d682b60f}
@@ -194,18 +191,6 @@
Source Files\Task Manager
-
- Source Files\Tools\SQLite
-
-
- Source Files\Tools\SQLite
-
-
- Source Files\Tools\SQLite
-
-
- Source Files\Tools\SQLite
-
Source Files\Tools
@@ -227,12 +212,6 @@
Source Files\Task
-
- Source Files\Tools
-
-
- Source Files\Tools
-
Source Files\Feedback
@@ -311,9 +290,6 @@
Source Files\Library files
-
- Tests
-
Source Files\Filesystems\OverlappedIO\ReaderWriter
@@ -399,6 +375,12 @@
Source Files\Tools
+
+ Tests
+
+
+ Source Files\Tools
+
@@ -485,18 +467,6 @@
Source Files\Task Manager
-
- Source Files\Tools\SQLite
-
-
- Source Files\Tools\SQLite
-
-
- Source Files\Tools\SQLite
-
-
- Source Files\Tools\SQLite
-
Source Files\Tools
@@ -524,15 +494,9 @@
Tests
-
- Source Files\Tools
-
Tests
-
- Source Files\Tools
-
Source Files\Feedback
@@ -686,6 +650,15 @@
Source Files\Tools
+
+ Tests
+
+
+ Tests
+
+
+ Source Files\Tools
+
Index: src/libserializer/TObsoleteFiles.cpp
===================================================================
diff -u -N
--- src/libserializer/TObsoleteFiles.cpp (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libserializer/TObsoleteFiles.cpp (revision 0)
@@ -1,116 +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.
-// ============================================================================
-#include "stdafx.h"
-#include "TObsoleteFiles.h"
-#include "ISerializerContainer.h"
-
-using namespace chcore;
-
-namespace serializer
-{
- ObsoleteFileInfo::ObsoleteFileInfo(const TSmartPath& path, bool bAdded) :
- m_path(path),
- m_bAdded(bAdded)
- {
- }
-
- ObsoleteFileInfo::ObsoleteFileInfo() :
- m_bAdded(false)
- {
- }
-
- TObsoleteFiles::TObsoleteFiles() :
- m_oidLast(0)
- {
- }
-
- TObsoleteFiles::~TObsoleteFiles()
- {
- }
-
- void TObsoleteFiles::DeleteObsoleteFile(const TSmartPath& pathToDelete)
- {
- if (!DeleteFile(pathToDelete.ToString()) && GetLastError() != ERROR_FILE_NOT_FOUND)
- m_mapPaths.insert(std::make_pair(++m_oidLast, ObsoleteFileInfo(pathToDelete, true)));
- }
-
- void TObsoleteFiles::Store(const ISerializerContainerPtr& spContainer) const
- {
- InitColumns(spContainer);
-
- spContainer->DeleteRows(m_setRemovedObjects);
- m_setRemovedObjects.Clear();
-
- for (MapPaths::const_iterator iter = m_mapPaths.begin(); iter != m_mapPaths.end(); ++iter)
- {
- if (iter->second.m_bAdded)
- {
- ISerializerRowData& rRow = spContainer->GetRow(iter->first, true);
- rRow.SetValue(_T("path"), iter->second.m_path);
- }
-
- iter->second.m_bAdded = false;
- }
- }
-
- void TObsoleteFiles::Load(const ISerializerContainerPtr& spContainer)
- {
- InitColumns(spContainer);
-
- ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader();
-
- ObsoleteFileInfo tEntry;
- object_id_t oid = 0;
- while (spRowReader->Next())
- {
- spRowReader->GetValue(_T("id"), oid);
- spRowReader->GetValue(_T("path"), tEntry.m_path);
- tEntry.m_bAdded = false;
-
- m_mapPaths.insert(std::make_pair(oid, tEntry));
- m_oidLast = std::max(m_oidLast, oid);
- }
-
- m_setRemovedObjects.Clear();
-
- // try to delete files
- MapPaths::iterator iter = m_mapPaths.begin();
- while (iter != m_mapPaths.end())
- {
- BOOL bDeleted = DeleteFile(iter->second.m_path.ToString());
- if (bDeleted || GetLastError() == ERROR_FILE_NOT_FOUND)
- {
- m_setRemovedObjects.Add(iter->first);
- iter = m_mapPaths.erase(iter);
- }
- else
- ++iter;
- }
- }
-
- void TObsoleteFiles::InitColumns(const ISerializerContainerPtr& spContainer) const
- {
- IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition();
- if (rColumns.IsEmpty())
- {
- rColumns.AddColumn(_T("id"), ColumnType::value);
- rColumns.AddColumn(_T("path"), IColumnsDefinition::eType_path);
- }
- }
-}
Index: src/libserializer/TObsoleteFiles.h
===================================================================
diff -u -N
--- src/libserializer/TObsoleteFiles.h (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187)
+++ src/libserializer/TObsoleteFiles.h (revision 0)
@@ -1,67 +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 __TOBSOLETEFILES_H__
-#define __TOBSOLETEFILES_H__
-
-#include
@@ -215,9 +214,6 @@
Source Files\Tools
-
- Source Files\Tools
-
Source Files\Serialization\Fake