Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions framework/areg/persist/IEDatabaseEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ class AREG_API IEDatabaseEngine
**/
virtual bool commit(bool doCommit) = 0;

/**
* \brief Rolls back the database changes and returns true if succeeded.
**/
virtual bool rollback(void) = 0;

//////////////////////////////////////////////////////////////////////////
// Forbidden calls.
//////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions framework/aregextend.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<ClCompile Include="aregextend\console\private\SystemServiceConsole.cpp" />
<ClCompile Include="aregextend\db\private\LogSqliteDatabase.cpp" />
<ClCompile Include="aregextend\db\private\SqliteDatabase.cpp" />
<ClCompile Include="aregextend\db\private\SqliteRow.cpp" />
<ClCompile Include="aregextend\db\private\SqliteStatement.cpp" />
<ClCompile Include="aregextend\service\private\DataRateHelper.cpp" />
<ClCompile Include="aregextend\service\private\NESystemService.cpp" />
<ClCompile Include="aregextend\service\private\posix\ServiceApplicationBasePosix.cpp" />
Expand All @@ -70,6 +72,8 @@
<ClInclude Include="aregextend\console\OptionParser.hpp" />
<ClInclude Include="aregextend\db\SqliteDatabase.hpp" />
<ClInclude Include="aregextend\db\LogSqliteDatabase.hpp" />
<ClInclude Include="aregextend\db\SqliteRow.hpp" />
<ClInclude Include="aregextend\db\SqliteStatement.hpp" />
<ClInclude Include="aregextend\service\DataRateHelper.hpp" />
<ClInclude Include="aregextend\service\NESystemService.hpp" />
<ClInclude Include="aregextend\console\SystemServiceConsole.hpp" />
Expand Down
12 changes: 12 additions & 0 deletions framework/aregextend.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
<ClCompile Include="aregextend\service\private\win32\ServiceApplicationBaseWin32.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="aregextend\db\private\SqliteStatement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="aregextend\db\private\SqliteRow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="aregextend\CMakeLists.txt">
Expand Down Expand Up @@ -133,6 +139,12 @@
<ClInclude Include="aregextend\resources\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="aregextend\db\SqliteRow.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="aregextend\db\SqliteStatement.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="aregextend\Readme.md">
Expand Down
57 changes: 57 additions & 0 deletions framework/aregextend/db/LogSqliteDatabase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@
#include "areg/logging/IELogDatabaseEngine.hpp"
#include "areg/base/String.hpp"

#if 0
#include <vector>

enum eLogItemType
{
ItemUnknown = 0 //!< Unknown log item type
, ItemInstance //!< Log instance item
, ItemThread //!< Log thread item
, ItemScope //!< Log scope item
, ItemPriority //!< Log priority item
};

struct sLogItem
{
ITEM_ID itemId { 0 }; //<! The ID of the log item
String itemName{ }; //!< The name of the log item
};

struct sLogItemList
{
eLogItemType itemType{ ItemUnknown }; //!< The type of the log item
std::vector<sLogItem> itemList{ }; //!< The list of log items
};
#endif
//////////////////////////////////////////////////////////////////////////
// LogSqliteDatabase class declaration
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -199,6 +223,39 @@ class LogSqliteDatabase : public IELogDatabaseEngine
**/
virtual bool logScopeDeactivate(const ITEM_ID & cookie, unsigned int scopeId, const DateTime & timestamp) override;

/**
* \brief Rolls back the database changes and returns true if succeeded.
**/
virtual bool rollback(void) override;

//////////////////////////////////////////////////////////////////////////
// Attributes and operations
//////////////////////////////////////////////////////////////////////////
#if 0
std::vector<String> getLogInstanceNames(void) const;

std::vector<ITEM_ID> getLogInstances(void) const;

std::vector<String> getLogThreadNames(void) const;

std::vector<ITEM_ID> getLogThreads(void) const;

std::vector<String> getLogScopeNames(void) const;

std::vector<ITEM_ID> getLogScopes(void) const;

std::vector<String> getPriorityNames(void) const;

std::vector<NELogging::sScopeInfo> getLogInstScopes(ITEM_ID instId) const;

std::vector<SharedBuffer> getLodMessages(void) const;

std::vector<SharedBuffer> getLodInstMessages(ITEM_ID instId) const;

std::vector<SharedBuffer> getLodScopeMessages(ITEM_ID instId, uint32_t scopeId) const;

#endif

//////////////////////////////////////////////////////////////////////////
// Hidden methods
//////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions framework/aregextend/db/SqliteDatabase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
**/
class SqliteDatabase : public IEDatabaseEngine
{
friend class SqliteStatement;
//////////////////////////////////////////////////////////////////////////
// Constructors / Destructor
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -111,6 +112,11 @@ class SqliteDatabase : public IEDatabaseEngine
**/
virtual bool commit(bool doCommit) override;

/**
* \brief Rolls back the database changes and returns true if succeeded.
**/
virtual bool rollback(void) override;

//////////////////////////////////////////////////////////////////////////
// Hidden methods
//////////////////////////////////////////////////////////////////////////
Expand Down
204 changes: 204 additions & 0 deletions framework/aregextend/db/SqliteRow.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
#ifndef AREG_AREGEXTEND_DB_SQLITEROW_HPP
#define AREG_AREGEXTEND_DB_SQLITEROW_HPP
/************************************************************************
* This file is part of the AREG SDK core engine.
* AREG SDK is dual-licensed under Free open source (Apache version 2.0
* License) and Commercial (with various pricing models) licenses, depending
* on the nature of the project (commercial, research, academic or free).
* You should have received a copy of the AREG SDK license description in LICENSE.txt.
* If not, please contact to info[at]aregtech.com
*
* \copyright (c) 2017-2023 Aregtech UG. All rights reserved.
* \file aregextend/db/SqliteRow.hpp
* \author Artak Avetyan
* \ingroup AREG platform, extended library, SQLite row object to get results.
************************************************************************/

/************************************************************************
* Include files.
************************************************************************/
#include "areg/base/GEGlobal.h"
#include "areg/base/String.hpp"

/************************************************************************
* Dependencies
************************************************************************/
class SqliteStatement;

//////////////////////////////////////////////////////////////////////////
// SqliteRow class declaration
//////////////////////////////////////////////////////////////////////////
/**
* \brief Represents a single row of results from a SQLite query.
* Provides access to column values and metadata for the current row.
**/
class SqliteRow
{
//////////////////////////////////////////////////////////////////////////
// Constructors / operators.
//////////////////////////////////////////////////////////////////////////
public:
/**
* \brief Default constructor. Initializes an invalid row.
*/
SqliteRow(void);

/**
* \brief Constructs a SqliteRow from a SqliteStatement.
* \param statement Reference to the SqliteStatement object.
*/
SqliteRow(SqliteStatement& statement);

/**
* \brief Constructs a SqliteRow from a raw statement pointer.
* \param statement Pointer to the underlying SQLite statement.
*/
SqliteRow(void* statement);

/**
* \brief Copy constructor.
* \param src The source SqliteRow to copy from.
*/
SqliteRow(const SqliteRow& src);

/**
* \brief Move constructor.
* \param src The source SqliteRow to move from.
*/
SqliteRow(SqliteRow&& src);

/**
* \brief Destructor. Defaulted.
*/
~SqliteRow(void) = default;

/**
* \brief Copy assignment operator.
* \param src The source SqliteRow to copy from.
* \return Reference to this object.
*/
SqliteRow& operator = (const SqliteRow& src);

/**
* \brief Move assignment operator.
* \param src The source SqliteRow to move from.
* \return Reference to this object.
*/
SqliteRow& operator = (SqliteRow&& src);

//////////////////////////////////////////////////////////////////////////
// Attributes and operations
//////////////////////////////////////////////////////////////////////////
public:
/**
* \brief Checks if the row is valid (i.e., associated with a statement).
* \return True if valid, false otherwise.
*/
inline bool isValid(void) const;

/**
* \brief Retrieves the integer value of the specified column.
* \param column The 0-based column index.
* \return The integer value of the column.
*/
int getInt(int column) const;

/**
* \brief Retrieves the 64-bit integer value of the specified column.
* \param column The 0-based column index.
* \return The 64-bit integer value of the column.
*/
int64_t getInt64(int column) const;

/**
* \brief Retrieves the double value of the specified column.
* \param column The 0-based column index.
* \return The double value of the column.
*/
double getDouble(int column) const;

/**
* \brief Retrieves the text value of the specified column.
* \param column The 0-based column index.
* \return The string value of the column.
*/
String getText(int column) const;

/**
* \brief Checks if the specified column is NULL.
* \param column The 0-based column index.
* \return True if the column is NULL, false otherwise.
*/
bool isNull(int column) const;

/**
* \brief Checks if the specified column index is valid.
* \param column The 0-based column index.
* \return True if the column index is valid, false otherwise.
*/
bool isColumnValid(int column) const;

/**
* \brief Checks if the specified column contains a string value.
* \param column The 0-based column index.
* \return True if the column is a string, false otherwise.
*/
bool isString(int column) const;

/**
* \brief Checks if the specified column contains a 32-bit integer value.
* \param column The 0-based column index.
* \return True if the column is a 32-bit integer, false otherwise.
*/
bool isInteger(int column) const;

/**
* \brief Checks if the specified column contains a 64-bit integer value.
* \param column The 0-based column index.
* \return True if the column is a 64-bit integer, false otherwise.
*/
bool isInteger64(int column) const;

/**
* \brief Checks if the specified column contains a double value.
* \param column The 0-based column index.
* \return True if the column is a double, false otherwise.
*/
bool isDouble(int column) const;

/**
* \brief Returns the number of columns in the row.
* \return The number of columns.
*/
int getColumnCount(void) const;

/**
* \brief Returns the name of the specified column.
* \param column The 0-based column index.
* \return The name of the column.
*/
String getColumnName(int column) const;

/**
* \brief Returns the index of the column with the specified name.
* \param columnName The name of the column.
* \return The 0-based index of the column, or -1 if not found.
*/
int getColumnIndex(const String& columnName) const;

//////////////////////////////////////////////////////////////////////////
// Member variables
//////////////////////////////////////////////////////////////////////////
protected:
/**
* \brief Pointer to the underlying SQLite statement.
*/
void* mStatement;
};

inline bool SqliteRow::isValid(void) const
{
return (mStatement != nullptr);
}

#endif // AREG_AREGEXTEND_DB_SQLITEROW_HPP
Loading
Loading