From 531c168c65d0bb60d7c9a8669ff67beb8b6e61cc Mon Sep 17 00:00:00 2001
From: Aregtech <49253642+aregtech@users.noreply.github.com>
Date: Wed, 29 Nov 2023 19:02:31 +0400
Subject: [PATCH] Tested and enabled remote logging, fixed bugs in ring stack.
(#268)
* Tested and enabled remote logging, fixed bugs in ring stack.
* Fixed reading configuration for queue size.
* Fixed tests and segmentation fault issue.
---
examples/04_trace/config/areg.init | 50 +--
examples/10_locsvc/locservice/src/main.cpp | 4 +-
framework/areg.vcxproj | 2 +
framework/areg.vcxproj.filters | 6 +
framework/areg/appbase/Application.hpp | 23 +-
framework/areg/appbase/NEApplication.hpp | 6 +-
.../areg/appbase/private/Application.cpp | 21 +-
framework/areg/base/SharedBuffer.hpp | 17 +-
framework/areg/base/SynchObjects.hpp | 3 +-
framework/areg/base/TERingStack.hpp | 60 +--
framework/areg/base/Thread.hpp | 31 +-
framework/areg/base/private/NEMath.cpp | 271 ++++++------
framework/areg/base/private/NEString.cpp | 415 +++++++++---------
framework/areg/base/private/SharedBuffer.cpp | 11 +
framework/areg/base/private/Thread.cpp | 68 ++-
.../private/posix/IESynchObjectBaseIX.hpp | 2 +-
.../areg/base/private/posix/NESocketPosix.cpp | 4 -
.../base/private/posix/SynchLockAndWaitIX.cpp | 47 +-
.../base/private/posix/SynchLockAndWaitIX.hpp | 21 +-
.../base/private/posix/SynchObjectsPosix.cpp | 7 +-
.../base/private/posix/WaitableMutexIX.cpp | 10 +-
.../areg/base/private/win32/ThreadWin32.cpp | 2 +-
.../private/posix/TimerManagerPosix.cpp | 28 --
.../private/posix/WatchdogManagerPosix.cpp | 24 -
framework/areg/ipc/ServerConnectionBase.hpp | 2 +-
.../areg/ipc/ServiceClientConnectionBase.hpp | 21 +-
.../areg/ipc/private/NERemoteService.cpp | 20 +-
framework/areg/ipc/private/RouterClient.cpp | 8 +-
.../private/ServiceClientConnectionBase.cpp | 2 +-
.../areg/ipc/private/SocketConnectionBase.cpp | 42 +-
framework/areg/persist/ConfigManager.hpp | 141 ++++--
.../areg/persist/IEConfigurationListener.hpp | 96 ++++
framework/areg/persist/NEPersistence.hpp | 54 +--
framework/areg/persist/Property.hpp | 9 +
framework/areg/persist/private/CMakeLists.txt | 1 +
.../areg/persist/private/ConfigManager.cpp | 82 +++-
.../private/IEConfigurationListener.cpp | 19 +
framework/areg/persist/private/Makefile | 13 +-
framework/areg/resources/areg.init | 19 +-
framework/areg/trace/NETrace.hpp | 97 ++--
.../areg/trace/private/DebugOutputLogger.cpp | 14 +-
framework/areg/trace/private/FileLogger.cpp | 14 +-
.../areg/trace/private/LayoutManager.cpp | 8 +
framework/areg/trace/private/Layouts.cpp | 142 +++++-
framework/areg/trace/private/Layouts.hpp | 178 +++++++-
framework/areg/trace/private/LogMessage.cpp | 11 +-
framework/areg/trace/private/LogMessage.hpp | 18 +-
framework/areg/trace/private/NELogging.hpp | 2 +
framework/areg/trace/private/NETrace.cpp | 92 ++--
framework/areg/trace/private/NetTcpLogger.cpp | 82 +++-
framework/areg/trace/private/NetTcpLogger.hpp | 2 +-
.../areg/trace/private/ScopeNodeBase.cpp | 4 +-
framework/areg/trace/private/ScopeNodes.cpp | 8 +-
framework/areg/trace/private/TraceEvent.cpp | 12 +-
framework/areg/trace/private/TraceEvent.hpp | 12 +-
framework/areg/trace/private/TraceManager.cpp | 27 +-
framework/areg/trace/private/TraceManager.hpp | 26 +-
framework/areg/trace/private/TraceMessage.cpp | 14 +-
.../private/ServiceCommunicatonBase.cpp | 4 +-
framework/logger/app/Logger.hpp | 43 +-
framework/logger/app/private/Logger.cpp | 43 +-
.../logger/service/LoggerServerService.hpp | 1 +
.../private/LoggerMessageProcessor.cpp | 1 +
.../service/private/LoggerServerService.cpp | 22 +-
.../tcp/private/RouterServerService.cpp | 34 +-
65 files changed, 1634 insertions(+), 939 deletions(-)
create mode 100644 framework/areg/persist/IEConfigurationListener.hpp
create mode 100644 framework/areg/persist/private/IEConfigurationListener.cpp
diff --git a/examples/04_trace/config/areg.init b/examples/04_trace/config/areg.init
index 6deab6080..462433390 100644
--- a/examples/04_trace/config/areg.init
+++ b/examples/04_trace/config/areg.init
@@ -63,6 +63,8 @@
# Meaning of Layout format:
# The Layout Format is relevant only when logs the messages in the plain text file.
# The Layout Format specification fields are following:
+ %a -- outputs the ID of a logging object set by the logger.
+ %b -- outputs the module name of the logging object.
# %c -- output tick-count value since process start
# %d -- output day and time data
# %e -- output module (process) ID
@@ -111,57 +113,17 @@ log::*::enable = true # Global logging ena
log::*::enable::remote = false # Remote logging enable / disable flag
log::*::enable::file = true # File logging enable / disable flag
log::*::enable::debug = false # Debug output console logging enable / disable flag
-log::*::enable::db = false # Database logging enable / disable flag
log::*::file::location = ./logs/%appname%_%time%.log # Log file location and masks
log::*::file::append = false # Append logs at the end of file
-log::*::remote::stack = 100 # Queue stack size in remote logging, 0 means no queuing
+log::*::remote::queue = 100 # Queue stack size in remote logging, 0 means no queuing
log::*::remote::service = logger # The service name of the remote logging
-# ---------------------------------------------------------------------------
-# Database logging settings (not supported at the moment!!!)
-# ---------------------------------------------------------------------------
-log::*::db::location = # Database location
-log::*::db::append = true # Append logs
-log::*::db::driver = # Database driver
-log::*::db::address = 127.0.0.1 # Database connection IP-address
-log::*::db::port = 1234 # Database connection IP-port
-log::*::db::username = areg # Database connection user name
-log::*::db::password = areg # Database connection password
-log::*::db::name = # Database name
-
# ---------------------------------------------------------------------------
# Log message layout in the file
# ---------------------------------------------------------------------------
-log::*::layout::enter = %d: [ %t %x.%z: Enter -->]%n # Enter scope layout
-log::*::layout::message = %d: [ %t %p >>> ] %m%n # Log message layout
-log::*::layout::exit = %d: [ %t %x.%z: Exit <-- ]%n # Exit scope layout
-
-# ###########################################################################
-# Remote services
-# ###########################################################################
-
-# ---------------------------------------------------------------------------
-# List of remote services
-# ---------------------------------------------------------------------------
-service::*::list = router | logger # The list of available remote services
-
-# ---------------------------------------------------------------------------
-# Message router settings
-# ---------------------------------------------------------------------------
-router::*::service = mcrouter # The name of the router service (process name)
-router::*::connect = tcpip # The list of supported communication protocols
-router::*::enable::tcpip = true # Communication protocol enable / disable flag
-router::*::address::tcpip = 127.0.0.1 # Protocol specific connection IP-address
-router::*::port::tcpip = 8181 # Protocol specific connection port number
-
-# ---------------------------------------------------------------------------
-# Remote logger settings
-# ---------------------------------------------------------------------------
-logger::*::service = logger # The name of the router service (process name)
-logger::*::connect = tcpip # The list of supported communication protocols
-logger::*::enable::tcpip = true # Communication protocol enable / disable flag
-logger::*::address::tcpip = 127.0.0.1 # Protocol specific connection IP-address
-logger::*::port::tcpip = 8282 # Protocol specific connection port number
+log::*::layout::enter = %d: [ %t %x.%z: Enter -->]%n # Enter scope layout
+log::*::layout::message = %d: [ %t %p >>> ] %m%n # Log message layout
+log::*::layout::exit = %d: [ %t %x.%z: Exit <-- ]%n # Exit scope layout
# #######################################
# Application(s) Scopes
diff --git a/examples/10_locsvc/locservice/src/main.cpp b/examples/10_locsvc/locservice/src/main.cpp
index 9c6957223..bc84d8fcb 100644
--- a/examples/10_locsvc/locservice/src/main.cpp
+++ b/examples/10_locsvc/locservice/src/main.cpp
@@ -75,8 +75,8 @@ int main()
std::cout << "A Demo to demonstrate simple request, response and broadcast ..." << std::endl;
// force to start logging with default settings
- TRACER_CONFIGURE_AND_START( nullptr );
- Application::initApplication( true, true, false, true, true, nullptr );
+ Application::initApplication( true, true, false, true, false, nullptr );
+ TRACER_CONFIGURE_AND_START(nullptr);
do
{
diff --git a/framework/areg.vcxproj b/framework/areg.vcxproj
index 5e94aefe6..b137ed2da 100644
--- a/framework/areg.vcxproj
+++ b/framework/areg.vcxproj
@@ -220,6 +220,7 @@
+
@@ -400,6 +401,7 @@
+
diff --git a/framework/areg.vcxproj.filters b/framework/areg.vcxproj.filters
index 770d7fe0e..b5d6c8908 100644
--- a/framework/areg.vcxproj.filters
+++ b/framework/areg.vcxproj.filters
@@ -561,6 +561,9 @@
Source Files
+
+ Source Files
+
@@ -1112,6 +1115,9 @@
Header Files
+
+ Header Files
+
diff --git a/framework/areg/appbase/Application.hpp b/framework/areg/appbase/Application.hpp
index 014c91520..a4d4e3960 100644
--- a/framework/areg/appbase/Application.hpp
+++ b/framework/areg/appbase/Application.hpp
@@ -28,6 +28,11 @@
#include "areg/component/NERegistry.hpp"
#include "areg/persist/ConfigManager.hpp"
+ /************************************************************************
+ * Dependencies.
+ ************************************************************************/
+class IEConfigurationListener;
+
//////////////////////////////////////////////////////////////////////////
// Dependencies
//////////////////////////////////////////////////////////////////////////
@@ -86,6 +91,9 @@ class AREG_API Application
* \param startTimer If true, application starts timer manager. If Service Managers, Timer Manager automatically starts.
* \param startWatchdog If true, application starts watchdog manager, so that it can track the component threads.
* \param configFile If nullptr or empty, configures Tracing from specified file. Default location is './config/areg.init' (NEApplication::DEFAULT_CONFIG_FILE)
+ * \param listener A pointer to the configuration listener. If the pointer is valid, the listener is notified before and after loading configuration,
+ * as well as if loading configuration fails and the default configuration is set.
+ * By default, the pointer to listener is null, so that no notification is triggered.
* \see release, loadModel
*
* \example Initialize Application
@@ -109,7 +117,8 @@ class AREG_API Application
, bool startRouting = true
, bool startTimer = true
, bool startWatchdog = false
- , const char * configFile = NEApplication::DEFAULT_CONFIG_FILE.data() );
+ , const char * configFile = NEApplication::DEFAULT_CONFIG_FILE.data()
+ , IEConfigurationListener * listener = nullptr);
/**
* \brief Call to stop all components, unload models, stop services and release resources.
@@ -361,10 +370,12 @@ class AREG_API Application
* \brief Loads the configuration from the given file.
* \param fileName The relative or absolute path to the file to read configurations.
* If nullptr, loads configuration from default file './config/areg.init' (NEApplication::DEFAULT_CONFIG_FILE).
+ * \param listener The pointer to the configuration listener. If valid, the notifications are triggered before and after
+ * reading configuration from file. If listener is null or loading configuration failed, no notification is triggered.
* \return Returns true if succeeded to load configuration.
* If fails, loads default configuration and returns false.
**/
- static bool loadConfiguration(const char * fileName = nullptr);
+ static bool loadConfiguration(const char * fileName = nullptr, IEConfigurationListener * listener = nullptr);
/**
* \brief Saves current configuration in the given file.
@@ -374,17 +385,21 @@ class AREG_API Application
* If nullptr, saves configuration in the same file that was read.
* If default configuration was loaded, saves all configuration in the
* default file './config/areg.init' (NEApplication::DEFAULT_CONFIG_FILE).
+ * \param listener The pointer to the configuration listener. If valid, the notifications are triggered before and after
+ * saving configuration to file. If listener is null or saving configuration failed, no notification is triggered.
* \return Returns true if succeeded to save configuration.
* Otherwise, returns false.
**/
- static bool saveConfiguration(const char * fileName = nullptr);
+ static bool saveConfiguration(const char * fileName = nullptr, IEConfigurationListener * listener = nullptr);
/**
* \brief Loads default configuration properties defined in NEApplication::DefaultReadonlyProperties
* and in the NEApplication::DefaultLogScopesConfig. This will discard the previous configuration
* if the application was already configured.
+ * \param listener The pointer to the configuration listener. If valid, the notifications are triggered if default
+ * configuration is set. If listener is null, no notification is triggered.
**/
- static void setupDefaultConfiguration(void);
+ static void setupDefaultConfiguration(IEConfigurationListener * listener = nullptr);
/**
* \brief Returns true if the application is already configured.
diff --git a/framework/areg/appbase/NEApplication.hpp b/framework/areg/appbase/NEApplication.hpp
index cea506b98..61aa1f0ec 100644
--- a/framework/areg/appbase/NEApplication.hpp
+++ b/framework/areg/appbase/NEApplication.hpp
@@ -146,7 +146,7 @@ namespace NEApplication
* \brief NEApplication::DEFAULT_LOG_QUEUE_SIZE
* The default size to queue logs in the stack, used for remote logging.
**/
- constexpr uint32_t DEFAULT_LOG_QUEUE_SIZE { 30 };
+ constexpr uint32_t DEFAULT_LOG_QUEUE_SIZE { 100 };
/**
* \brief NEApplication::DEFAULT_LOG_FILE
@@ -227,13 +227,13 @@ namespace NEApplication
, { {"log" , "*" , "version" , "" }, NETrace::LOG_VERSION } //!< The logging version.
, { {"log" , "*" , "target" , "" }, "remote | file | debug | db" } //!< The logging types.
, { {"log" , "*" , "enable" , "" }, "true" } //!< The logging enabled / disabled status.
- , { {"log" , "*" , "enable" , "remote" }, "false" } //!< The logging in remote log collector enabled / disabled flag.
+ , { {"log" , "*" , "enable" , "remote" }, "true" } //!< The logging in remote log collector enabled / disabled flag.
, { {"log" , "*" , "enable" , "file" }, "true" } //!< The logging in file enabled / disabled flag.
, { {"log" , "*" , "enable" , "output" }, "false" } //!< The logging in output console enabled / disabled flag.
, { {"log" , "*" , "enable" , "db" }, "false" } //!< The logging in database enabled / disabled flag.
, { {"log" , "*" , "file" , "location"}, DEFAULT_LOG_FILE } //!< The log file location and file name mask.
, { {"log" , "*" , "file" , "append" }, "false" } //!< The flag to append logs into the file.
- , { {"log" , "*" , "remote" , "size" }, "100" } //!< The queue size of remote logging.
+ , { {"log" , "*" , "remote" , "queue" }, "100" } //!< The queue size of remote logging.
, { {"log" , "*" , "remote" , "service" }, "logger" } //!< The service name of the remote logging.
, { {"log" , "*" , "layout" , "enter" }, DEFAULT_LAYOUT_SCOPE_EXIT } //!< The layout of enter scope message.
, { {"log" , "*" , "layout" , "message" }, DEFAULT_LAYOUT_LOG_MESSAGE } //!< The layout of log message.
diff --git a/framework/areg/appbase/private/Application.cpp b/framework/areg/appbase/private/Application.cpp
index 11c8106af..2254f7953 100644
--- a/framework/areg/appbase/private/Application.cpp
+++ b/framework/areg/appbase/private/Application.cpp
@@ -52,7 +52,8 @@ void Application::initApplication( bool startTracing /*= true */
, bool startRouting /*= true */
, bool startTimer /*= true */
, bool startWatchdog /*= true */
- , const char * configFile /*= NEApplication::DEFAULT_CONFIG_FILE */)
+ , const char * configFile /*= NEApplication::DEFAULT_CONFIG_FILE */
+ , IEConfigurationListener* listener /*= nullptr*/)
{
OUTPUT_DBG("Going to initialize application");
Application::_setAppState(Application::eAppState::AppStateInitializing);
@@ -61,7 +62,7 @@ void Application::initApplication( bool startTracing /*= true */
Application::setWorkingDirectory( nullptr );
startTimer = startTimer == false ? startServicing : startTimer;
- Application::loadConfiguration(NEString::isEmpty(configFile) ? NEApplication::DEFAULT_CONFIG_FILE.data() : configFile);
+ Application::loadConfiguration(NEString::isEmpty(configFile) ? NEApplication::DEFAULT_CONFIG_FILE.data() : configFile, listener);
if (startTracing)
{
@@ -405,38 +406,38 @@ ConfigManager& Application::getConfigManager(void)
return Application::getInstance().mConfigManager;
}
-bool Application::loadConfiguration(const char* fileName)
+bool Application::loadConfiguration(const char* fileName /*= nullptr*/, IEConfigurationListener * listener /*= nullptr*/)
{
Application& theApp = Application::getInstance();
bool result{ true };
- if (theApp.mConfigManager.readConfig(fileName == nullptr ? NEApplication::DEFAULT_CONFIG_FILE : fileName) == false)
+ if (theApp.mConfigManager.readConfig(fileName == nullptr ? NEApplication::DEFAULT_CONFIG_FILE : fileName, listener) == false)
{
result = false;
- Application::setupDefaultConfiguration();
+ Application::setupDefaultConfiguration(listener);
}
return result;
}
-bool Application::saveConfiguration(const char* fileName)
+bool Application::saveConfiguration(const char* fileName /*= nullptr*/, IEConfigurationListener * listener /*= nullptr*/)
{
Application& theApp = Application::getInstance();
return theApp.mConfigManager.saveConfig(fileName);
}
-void Application::setupDefaultConfiguration(void)
+void Application::setupDefaultConfiguration(IEConfigurationListener * listener /*= nullptr*/)
{
Application& theApp = Application::getInstance();
const String& module = Process::getInstance().getAppName();
const uint32_t countReadonly{ MACRO_ARRAYLEN(NEApplication::DefaultReadonlyProperties) };
- ConfigManager::ListProperties defReadonly(countReadonly);
+ NEPersistence::ListProperties defReadonly(countReadonly);
for (const auto & entry : NEApplication::DefaultReadonlyProperties)
{
defReadonly.add(Property(entry.configKey.section, entry.configKey.module, entry.configKey.property, entry.configKey.position, entry.configValue, String::EmptyString));
}
- ConfigManager::ListProperties defWritable;
+ NEPersistence::ListProperties defWritable;
for (const auto& entry : NEApplication::DefaultLogScopesConfig)
{
if (module == entry.configKey.module)
@@ -445,7 +446,7 @@ void Application::setupDefaultConfiguration(void)
}
}
- theApp.mConfigManager.setConfiguration(defReadonly, defWritable);
+ theApp.mConfigManager.setConfiguration(defReadonly, defWritable, listener);
}
bool Application::isConfigured(void)
diff --git a/framework/areg/base/SharedBuffer.hpp b/framework/areg/base/SharedBuffer.hpp
index e95d5daa9..538bc9996 100644
--- a/framework/areg/base/SharedBuffer.hpp
+++ b/framework/areg/base/SharedBuffer.hpp
@@ -71,7 +71,7 @@ class AREG_API SharedBuffer : public BufferStreamBase // This is data streaming
explicit SharedBuffer(unsigned int blockSize = NEMemory::BLOCK_SIZE);
/**
- * \brief Constructor to reserve space for byte buffer object
+ * \brief Reserves the space in the byte buffer to write data and sets block size.
* \param reserveSize Size in bytes to reserve
* \param blockSize The size of minimum block size to increase on resize.
* It is aligned to NEMemory::BLOCK_SIZE (minimum size)
@@ -79,7 +79,7 @@ class AREG_API SharedBuffer : public BufferStreamBase // This is data streaming
SharedBuffer( unsigned int reserveSize, unsigned int blockSize );
/**
- * \brief Initialization constructor, writes given data into byte buffer
+ * \brief Reserves space and writes given data into byte buffer.
* \param buffer The data to initialize byte buffer
* \param size The length in bytes of data
* \param blockSize The size of minimum block size to increase on resize.
@@ -87,6 +87,19 @@ class AREG_API SharedBuffer : public BufferStreamBase // This is data streaming
**/
SharedBuffer( const unsigned char * buffer, unsigned int size, unsigned int blockSize = NEMemory::BLOCK_SIZE );
+ /**
+ * \brief Reserves requested space in bytes and writes given data into byte buffer.
+ * The reserved space should at least the size of the buffer to write.
+ * If the requested space to reserve is smaller than the size of the buffer,
+ * it will be increased to the size of the buffer.
+ * \brief reserveSize Number of bytes to reserve in the shared buffer.
+ * \param buffer The data to initialize byte buffer
+ * \param size The length in bytes of data
+ * \param blockSize The size of minimum block size to increase on resize.
+ * It is aligned to NEMemory::BLOCK_SIZE (minimum size)
+ **/
+ SharedBuffer(unsigned int reserveSize, const unsigned char* buffer, unsigned int size, unsigned int blockSize = NEMemory::BLOCK_SIZE);
+
/**
* \brief Initialization constructor, writes given null-terminated string into byte buffer.
* It will write including EOS character ('\0').
diff --git a/framework/areg/base/SynchObjects.hpp b/framework/areg/base/SynchObjects.hpp
index b14bba957..380486c7d 100644
--- a/framework/areg/base/SynchObjects.hpp
+++ b/framework/areg/base/SynchObjects.hpp
@@ -167,7 +167,8 @@ friend class MultiLock;
inline virtual bool lock( unsigned int timeout = NECommon::WAIT_INFINITE ) override;
/**
- * \brief Unlocks / Release mutex.
+ * \brief Unlocks / Release mutex. The calling thread should have mutex ownership
+ * to call the method. Otherwise, the mutex locked state is not changed.
* \return Returns true if succeeded.
**/
inline virtual bool unlock( void ) override;
diff --git a/framework/areg/base/TERingStack.hpp b/framework/areg/base/TERingStack.hpp
index a39738646..9d10ea000 100644
--- a/framework/areg/base/TERingStack.hpp
+++ b/framework/areg/base/TERingStack.hpp
@@ -455,17 +455,12 @@ template
TERingStack::TERingStack( IEResourceLock & synchObject, uint32_t initCapacity /*= 0*/, NECommon::eRingOverlap onOverlap /*= NECommon::eRingOverlap::StopOnOverlap*/ )
: mSynchObject ( synchObject )
, mOnOverlap ( onOverlap )
- , mStackList ( nullptr )
+ , mStackList ( initCapacity != 0 ? reinterpret_cast(DEBUG_NEW unsigned char[initCapacity * sizeof(VALUE)]) : nullptr )
, mElemCount ( 0 )
- , mCapacity ( 0 )
+ , mCapacity ( mStackList != nullptr ? initCapacity : 0 )
, mStartPosition( 0 )
, mLastPosition ( 0 )
{
- if ( initCapacity > 0 )
- {
- mStackList = reinterpret_cast(DEBUG_NEW unsigned char [ initCapacity * sizeof(VALUE) ]);
- mCapacity = mStackList != nullptr ? initCapacity : 0;
- }
}
template
@@ -555,10 +550,9 @@ uint32_t TERingStack::pushLast( const VALUE& newElement )
{
Lock lock(mSynchObject);
- if ( mElemCount + 1 <= mCapacity )
+ if ( (mElemCount + 1) <= mCapacity )
{
- ASSERT( mCapacity > 0 );
- ASSERT( mStartPosition != mLastPosition || mElemCount == 0 );
+ ASSERT( (mStartPosition != mLastPosition) || (mElemCount == 0) );
VALUE * block = mStackList + mLastPosition;
NEMemory::constructElems(block, 1);
@@ -572,7 +566,7 @@ uint32_t TERingStack::pushLast( const VALUE& newElement )
{
case NECommon::eRingOverlap::ShiftOnOverlap:
ASSERT( mLastPosition == mStartPosition );
- if ( mCapacity > 0 )
+ if ( mCapacity != 0 )
{
VALUE * block = mStackList + mLastPosition;
NEMemory::destroyElems(block, 1);
@@ -589,7 +583,7 @@ uint32_t TERingStack::pushLast( const VALUE& newElement )
break;
case NECommon::eRingOverlap::ResizeOnOvelap:
- if ( reserve( static_cast(mCapacity > 0 ? mCapacity : 1) * 2 ) > (mElemCount + 1 ))
+ if ( reserve( static_cast(mCapacity != 0 ? mCapacity : 1) * 2 ) > (mElemCount + 1 ))
{
ASSERT(mCapacity >= mElemCount + 1);
VALUE * block = mStackList + mLastPosition;
@@ -619,18 +613,15 @@ uint32_t TERingStack::pushFirst( const VALUE& newElement )
{
Lock lock(mSynchObject);
- if ( mElemCount + 1 <= mCapacity )
+ if ( (mElemCount + 1) <= mCapacity )
{
- ASSERT( mCapacity > 0 );
- ASSERT( mStartPosition != mLastPosition || mElemCount == 0 );
+ ASSERT( (mStartPosition != mLastPosition) || (mElemCount == 0) );
- mStartPosition = mStartPosition > 0 ? mStartPosition - 1 : mCapacity - 1;
+ mStartPosition = mStartPosition != 0 ? mStartPosition - 1 : mCapacity - 1;
VALUE * block = mStackList + mStartPosition;
NEMemory::constructElems(block, 1);
*block = newElement;
++ mElemCount;
-
- ASSERT( mStartPosition != mLastPosition || mElemCount == mCapacity );
}
else
{
@@ -638,9 +629,9 @@ uint32_t TERingStack::pushFirst( const VALUE& newElement )
{
case NECommon::eRingOverlap::ShiftOnOverlap:
ASSERT( mLastPosition == mStartPosition );
- if ( mCapacity > 0 )
+ if ( mCapacity != 0 )
{
- mStartPosition = mStartPosition > 0 ? mStartPosition - 1 : mCapacity - 1;
+ mStartPosition = mStartPosition != 0 ? mStartPosition - 1 : mCapacity - 1;
VALUE * block = mStackList + mStartPosition;
NEMemory::destroyElems(block, 1);
NEMemory::constructElems(block, 1);
@@ -655,10 +646,10 @@ uint32_t TERingStack::pushFirst( const VALUE& newElement )
break;
case NECommon::eRingOverlap::ResizeOnOvelap:
- if ( reserve( static_cast(mCapacity > 0 ? mCapacity : 1) * 2 ) > (mElemCount + 1 ))
+ if ( reserve( static_cast(mCapacity != 0 ? mCapacity : 1) * 2 ) > (mElemCount + 1 ))
{
ASSERT(mCapacity >= mElemCount + 1);
- mStartPosition = mStartPosition > 0 ? mStartPosition - 1 : mCapacity - 1;
+ mStartPosition = mStartPosition != 0 ? mStartPosition - 1 : mCapacity - 1;
VALUE * block = mStackList + mStartPosition;
NEMemory::constructElems(block, 1);
*block = newElement;
@@ -687,17 +678,14 @@ VALUE TERingStack::popFirst( void )
ASSERT( isEmpty() == false );
VALUE result{ };
- if ( mElemCount > 0 )
+ if ( mElemCount != 0 )
{
- ASSERT( mCapacity > 0 );
- ASSERT( mStartPosition != mLastPosition );
+ ASSERT( mCapacity != 0 );
result = mStackList[mStartPosition];
NEMemory::destroyElems( mStackList + mStartPosition, 1 );
mStartPosition = (mStartPosition + 1) % mCapacity;
-- mElemCount;
-
- ASSERT( (mStartPosition != mLastPosition) || (mElemCount == 0) );
}
else
{
@@ -717,9 +705,9 @@ uint32_t TERingStack::copy( const TERingStack & source )
Lock lock2(source.mSynchObject);
uint32_t srcStart = source.mStartPosition;
- if ( mCapacity - mElemCount >= source.mElemCount )
+ if ( (mCapacity - mElemCount) >= source.mElemCount )
{
- for (uint32_t i = 0; i < source.mElemCount; i ++, result ++ )
+ for (uint32_t i = 0; i < source.mElemCount; ++ i, ++ result )
{
VALUE * block = mStackList + mLastPosition;
NEMemory::constructElems(block, 1);
@@ -735,9 +723,9 @@ uint32_t TERingStack::copy( const TERingStack & source )
{
case NECommon::eRingOverlap::ShiftOnOverlap:
ASSERT( mLastPosition == mStartPosition );
- if ( mCapacity > 0 )
+ if ( mCapacity != 0 )
{
- for (uint32_t i = 0; i < source.mElemCount; i ++, result ++ )
+ for (uint32_t i = 0; i < source.mElemCount; ++ i, ++ result )
{
VALUE * block = mStackList + mLastPosition;
NEMemory::destroyElems(block, 1);
@@ -756,10 +744,10 @@ uint32_t TERingStack::copy( const TERingStack & source )
break;
case NECommon::eRingOverlap::ResizeOnOvelap:
- if ( reserve( static_cast(mCapacity > 0 ? mCapacity : 1) * 2 ) > (mElemCount + 1 ))
+ if ( reserve( static_cast(mCapacity != 0 ? mCapacity : 1) * 2 ) > (mElemCount + 1 ))
{
- ASSERT(mCapacity >= mElemCount + 1);
- for (uint32_t i = 0; i < source.mElemCount; i ++, result ++ )
+ ASSERT(mCapacity >= (mElemCount + 1));
+ for (uint32_t i = 0; i < source.mElemCount; ++ i, ++ result )
{
VALUE * block = mStackList + mLastPosition;
NEMemory::constructElems(block, 1);
@@ -797,7 +785,7 @@ uint32_t TERingStack::reserve(uint32_t newCapacity )
if ( newCapacity > mCapacity )
{
- VALUE * newList = newCapacity > 0 ? reinterpret_cast( DEBUG_NEW unsigned char[ newCapacity ] ) : nullptr;
+ VALUE * newList = newCapacity != 0 ? reinterpret_cast( DEBUG_NEW unsigned char[ newCapacity ] ) : nullptr;
uint32_t dstLast = 0;
uint32_t srcStart = mStartPosition;
uint32_t elemCount = newCapacity > mElemCount ? mElemCount : newCapacity;
@@ -805,7 +793,7 @@ uint32_t TERingStack::reserve(uint32_t newCapacity )
if ( newList != nullptr )
{
NEMemory::constructElems(static_cast(newList), elemCount);
- for (uint32_t i = 0; i < elemCount; i ++ )
+ for ( uint32_t i = 0; i < elemCount; ++ i )
{
newList[dstLast ++] = mStackList[srcStart];
srcStart = ( srcStart + 1 ) % mCapacity;
diff --git a/framework/areg/base/Thread.hpp b/framework/areg/base/Thread.hpp
index a196a3010..b81e570ba 100644
--- a/framework/areg/base/Thread.hpp
+++ b/framework/areg/base/Thread.hpp
@@ -647,15 +647,20 @@ class AREG_API Thread : public RuntimeObject
/************************************************************************/
// Resource controlling and mapping variables
/************************************************************************/
-#if defined(_MSC_VER) && (_MSC_VER > 1200)
- #pragma warning(disable: 4251)
-#endif // _MSC_VER
- static MapThreadHandleResource _mapThreadhHandle; //!< Map of thread object where key is thread handle
- static MapThreadNameResource _mapThreadName; //!< Map of thread object where key is thread name
- static MapThreadIDResource _mapThreadId; //!< Map of thread object where key is thread ID
-#if defined(_MSC_VER) && (_MSC_VER > 1200)
- #pragma warning(default: 4251)
-#endif // _MSC_VER
+ /**
+ * \brief Returns static map of thread object where key is thread handle.
+ **/
+ static Thread::MapThreadHandleResource & _getMapThreadhHandle();
+
+ /**
+ * \brief Returns static map of thread object where key is thread name.
+ **/
+ static Thread::MapThreadNameResource & _getMapThreadName();
+
+ /**
+ * \brief Returns static map of thread object where key is thread ID
+ **/
+ static Thread::MapThreadIDResource & _getMapThreadId();
//////////////////////////////////////////////////////////////////////////
// Forbidden calls
@@ -671,12 +676,12 @@ class AREG_API Thread : public RuntimeObject
inline Thread* Thread::_findThreadByHandle(THREADHANDLE threadHandle)
{
- return Thread::_mapThreadhHandle.findResourceObject(threadHandle);
+ return Thread::_getMapThreadhHandle().findResourceObject(threadHandle);
}
inline THREADHANDLE Thread::_findThreadHandleById( id_type threadId)
{
- Thread * result = Thread::_mapThreadId.findResourceObject(threadId);
+ Thread * result = Thread::_getMapThreadId().findResourceObject(threadId);
return (result != nullptr ? result->mThreadHandle : nullptr);
}
@@ -717,12 +722,12 @@ inline const ThreadAddress & Thread::getAddress( void ) const
inline Thread* Thread::findThreadByName(const String & threadName)
{
- return (!threadName.isEmpty() ? Thread::_mapThreadName.findResourceObject(threadName) : nullptr);
+ return (!threadName.isEmpty() ? Thread::_getMapThreadName().findResourceObject(threadName) : nullptr);
}
inline Thread* Thread::findThreadById( id_type threadId)
{
- return Thread::_mapThreadId.findResourceObject(threadId);
+ return Thread::_getMapThreadId().findResourceObject(threadId);
}
inline Thread* Thread::findThreadByAddress(const ThreadAddress& threadAddress)
diff --git a/framework/areg/base/private/NEMath.cpp b/framework/areg/base/private/NEMath.cpp
index 655a9e61b..c25b0c919 100644
--- a/framework/areg/base/private/NEMath.cpp
+++ b/framework/areg/base/private/NEMath.cpp
@@ -18,140 +18,143 @@
#include "areg/base/NEMath.hpp"
#include
-/**
- * \brief 32-bit CRC (Cyclic Redundancy Check) lookup table (polynomial = 0x04C11DB7) with size 1024 bytes (256 x 4).
- * CRC polynomial: X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X+1
- **/
-static constexpr unsigned char _crc32LookupTable[] = {
- 0x00, 0x00, 0x00, 0x00, 0x96, 0x30, 0x07, 0x77,
- 0x2C, 0x61, 0x0E, 0xEE, 0xBA, 0x51, 0x09, 0x99,
- 0x19, 0xC4, 0x6D, 0x07, 0x8F, 0xF4, 0x6A, 0x70,
- 0x35, 0xA5, 0x63, 0xE9, 0xA3, 0x95, 0x64, 0x9E,
- 0x32, 0x88, 0xDB, 0x0E, 0xA4, 0xB8, 0xDC, 0x79,
- 0x1E, 0xE9, 0xD5, 0xE0, 0x88, 0xD9, 0xD2, 0x97,
- 0x2B, 0x4C, 0xB6, 0x09, 0xBD, 0x7C, 0xB1, 0x7E,
- 0x07, 0x2D, 0xB8, 0xE7, 0x91, 0x1D, 0xBF, 0x90,
- 0x64, 0x10, 0xB7, 0x1D, 0xF2, 0x20, 0xB0, 0x6A,
- 0x48, 0x71, 0xB9, 0xF3, 0xDE, 0x41, 0xBE, 0x84,
- 0x7D, 0xD4, 0xDA, 0x1A, 0xEB, 0xE4, 0xDD, 0x6D,
- 0x51, 0xB5, 0xD4, 0xF4, 0xC7, 0x85, 0xD3, 0x83,
- 0x56, 0x98, 0x6C, 0x13, 0xC0, 0xA8, 0x6B, 0x64,
- 0x7A, 0xF9, 0x62, 0xFD, 0xEC, 0xC9, 0x65, 0x8A,
- 0x4F, 0x5C, 0x01, 0x14, 0xD9, 0x6C, 0x06, 0x63,
- 0x63, 0x3D, 0x0F, 0xFA, 0xF5, 0x0D, 0x08, 0x8D,
- 0xC8, 0x20, 0x6E, 0x3B, 0x5E, 0x10, 0x69, 0x4C,
- 0xE4, 0x41, 0x60, 0xD5, 0x72, 0x71, 0x67, 0xA2,
- 0xD1, 0xE4, 0x03, 0x3C, 0x47, 0xD4, 0x04, 0x4B,
- 0xFD, 0x85, 0x0D, 0xD2, 0x6B, 0xB5, 0x0A, 0xA5,
- 0xFA, 0xA8, 0xB5, 0x35, 0x6C, 0x98, 0xB2, 0x42,
- 0xD6, 0xC9, 0xBB, 0xDB, 0x40, 0xF9, 0xBC, 0xAC,
- 0xE3, 0x6C, 0xD8, 0x32, 0x75, 0x5C, 0xDF, 0x45,
- 0xCF, 0x0D, 0xD6, 0xDC, 0x59, 0x3D, 0xD1, 0xAB,
- 0xAC, 0x30, 0xD9, 0x26, 0x3A, 0x00, 0xDE, 0x51,
- 0x80, 0x51, 0xD7, 0xC8, 0x16, 0x61, 0xD0, 0xBF,
- 0xB5, 0xF4, 0xB4, 0x21, 0x23, 0xC4, 0xB3, 0x56,
- 0x99, 0x95, 0xBA, 0xCF, 0x0F, 0xA5, 0xBD, 0xB8,
- 0x9E, 0xB8, 0x02, 0x28, 0x08, 0x88, 0x05, 0x5F,
- 0xB2, 0xD9, 0x0C, 0xC6, 0x24, 0xE9, 0x0B, 0xB1,
- 0x87, 0x7C, 0x6F, 0x2F, 0x11, 0x4C, 0x68, 0x58,
- 0xAB, 0x1D, 0x61, 0xC1, 0x3D, 0x2D, 0x66, 0xB6,
- 0x90, 0x41, 0xDC, 0x76, 0x06, 0x71, 0xDB, 0x01,
- 0xBC, 0x20, 0xD2, 0x98, 0x2A, 0x10, 0xD5, 0xEF,
- 0x89, 0x85, 0xB1, 0x71, 0x1F, 0xB5, 0xB6, 0x06,
- 0xA5, 0xE4, 0xBF, 0x9F, 0x33, 0xD4, 0xB8, 0xE8,
- 0xA2, 0xC9, 0x07, 0x78, 0x34, 0xF9, 0x00, 0x0F,
- 0x8E, 0xA8, 0x09, 0x96, 0x18, 0x98, 0x0E, 0xE1,
- 0xBB, 0x0D, 0x6A, 0x7F, 0x2D, 0x3D, 0x6D, 0x08,
- 0x97, 0x6C, 0x64, 0x91, 0x01, 0x5C, 0x63, 0xE6,
- 0xF4, 0x51, 0x6B, 0x6B, 0x62, 0x61, 0x6C, 0x1C,
- 0xD8, 0x30, 0x65, 0x85, 0x4E, 0x00, 0x62, 0xF2,
- 0xED, 0x95, 0x06, 0x6C, 0x7B, 0xA5, 0x01, 0x1B,
- 0xC1, 0xF4, 0x08, 0x82, 0x57, 0xC4, 0x0F, 0xF5,
- 0xC6, 0xD9, 0xB0, 0x65, 0x50, 0xE9, 0xB7, 0x12,
- 0xEA, 0xB8, 0xBE, 0x8B, 0x7C, 0x88, 0xB9, 0xFC,
- 0xDF, 0x1D, 0xDD, 0x62, 0x49, 0x2D, 0xDA, 0x15,
- 0xF3, 0x7C, 0xD3, 0x8C, 0x65, 0x4C, 0xD4, 0xFB,
- 0x58, 0x61, 0xB2, 0x4D, 0xCE, 0x51, 0xB5, 0x3A,
- 0x74, 0x00, 0xBC, 0xA3, 0xE2, 0x30, 0xBB, 0xD4,
- 0x41, 0xA5, 0xDF, 0x4A, 0xD7, 0x95, 0xD8, 0x3D,
- 0x6D, 0xC4, 0xD1, 0xA4, 0xFB, 0xF4, 0xD6, 0xD3,
- 0x6A, 0xE9, 0x69, 0x43, 0xFC, 0xD9, 0x6E, 0x34,
- 0x46, 0x88, 0x67, 0xAD, 0xD0, 0xB8, 0x60, 0xDA,
- 0x73, 0x2D, 0x04, 0x44, 0xE5, 0x1D, 0x03, 0x33,
- 0x5F, 0x4C, 0x0A, 0xAA, 0xC9, 0x7C, 0x0D, 0xDD,
- 0x3C, 0x71, 0x05, 0x50, 0xAA, 0x41, 0x02, 0x27,
- 0x10, 0x10, 0x0B, 0xBE, 0x86, 0x20, 0x0C, 0xC9,
- 0x25, 0xB5, 0x68, 0x57, 0xB3, 0x85, 0x6F, 0x20,
- 0x09, 0xD4, 0x66, 0xB9, 0x9F, 0xE4, 0x61, 0xCE,
- 0x0E, 0xF9, 0xDE, 0x5E, 0x98, 0xC9, 0xD9, 0x29,
- 0x22, 0x98, 0xD0, 0xB0, 0xB4, 0xA8, 0xD7, 0xC7,
- 0x17, 0x3D, 0xB3, 0x59, 0x81, 0x0D, 0xB4, 0x2E,
- 0x3B, 0x5C, 0xBD, 0xB7, 0xAD, 0x6C, 0xBA, 0xC0,
- 0x20, 0x83, 0xB8, 0xED, 0xB6, 0xB3, 0xBF, 0x9A,
- 0x0C, 0xE2, 0xB6, 0x03, 0x9A, 0xD2, 0xB1, 0x74,
- 0x39, 0x47, 0xD5, 0xEA, 0xAF, 0x77, 0xD2, 0x9D,
- 0x15, 0x26, 0xDB, 0x04, 0x83, 0x16, 0xDC, 0x73,
- 0x12, 0x0B, 0x63, 0xE3, 0x84, 0x3B, 0x64, 0x94,
- 0x3E, 0x6A, 0x6D, 0x0D, 0xA8, 0x5A, 0x6A, 0x7A,
- 0x0B, 0xCF, 0x0E, 0xE4, 0x9D, 0xFF, 0x09, 0x93,
- 0x27, 0xAE, 0x00, 0x0A, 0xB1, 0x9E, 0x07, 0x7D,
- 0x44, 0x93, 0x0F, 0xF0, 0xD2, 0xA3, 0x08, 0x87,
- 0x68, 0xF2, 0x01, 0x1E, 0xFE, 0xC2, 0x06, 0x69,
- 0x5D, 0x57, 0x62, 0xF7, 0xCB, 0x67, 0x65, 0x80,
- 0x71, 0x36, 0x6C, 0x19, 0xE7, 0x06, 0x6B, 0x6E,
- 0x76, 0x1B, 0xD4, 0xFE, 0xE0, 0x2B, 0xD3, 0x89,
- 0x5A, 0x7A, 0xDA, 0x10, 0xCC, 0x4A, 0xDD, 0x67,
- 0x6F, 0xDF, 0xB9, 0xF9, 0xF9, 0xEF, 0xBE, 0x8E,
- 0x43, 0xBE, 0xB7, 0x17, 0xD5, 0x8E, 0xB0, 0x60,
- 0xE8, 0xA3, 0xD6, 0xD6, 0x7E, 0x93, 0xD1, 0xA1,
- 0xC4, 0xC2, 0xD8, 0x38, 0x52, 0xF2, 0xDF, 0x4F,
- 0xF1, 0x67, 0xBB, 0xD1, 0x67, 0x57, 0xBC, 0xA6,
- 0xDD, 0x06, 0xB5, 0x3F, 0x4B, 0x36, 0xB2, 0x48,
- 0xDA, 0x2B, 0x0D, 0xD8, 0x4C, 0x1B, 0x0A, 0xAF,
- 0xF6, 0x4A, 0x03, 0x36, 0x60, 0x7A, 0x04, 0x41,
- 0xC3, 0xEF, 0x60, 0xDF, 0x55, 0xDF, 0x67, 0xA8,
- 0xEF, 0x8E, 0x6E, 0x31, 0x79, 0xBE, 0x69, 0x46,
- 0x8C, 0xB3, 0x61, 0xCB, 0x1A, 0x83, 0x66, 0xBC,
- 0xA0, 0xD2, 0x6F, 0x25, 0x36, 0xE2, 0x68, 0x52,
- 0x95, 0x77, 0x0C, 0xCC, 0x03, 0x47, 0x0B, 0xBB,
- 0xB9, 0x16, 0x02, 0x22, 0x2F, 0x26, 0x05, 0x55,
- 0xBE, 0x3B, 0xBA, 0xC5, 0x28, 0x0B, 0xBD, 0xB2,
- 0x92, 0x5A, 0xB4, 0x2B, 0x04, 0x6A, 0xB3, 0x5C,
- 0xA7, 0xFF, 0xD7, 0xC2, 0x31, 0xCF, 0xD0, 0xB5,
- 0x8B, 0x9E, 0xD9, 0x2C, 0x1D, 0xAE, 0xDE, 0x5B,
- 0xB0, 0xC2, 0x64, 0x9B, 0x26, 0xF2, 0x63, 0xEC,
- 0x9C, 0xA3, 0x6A, 0x75, 0x0A, 0x93, 0x6D, 0x02,
- 0xA9, 0x06, 0x09, 0x9C, 0x3F, 0x36, 0x0E, 0xEB,
- 0x85, 0x67, 0x07, 0x72, 0x13, 0x57, 0x00, 0x05,
- 0x82, 0x4A, 0xBF, 0x95, 0x14, 0x7A, 0xB8, 0xE2,
- 0xAE, 0x2B, 0xB1, 0x7B, 0x38, 0x1B, 0xB6, 0x0C,
- 0x9B, 0x8E, 0xD2, 0x92, 0x0D, 0xBE, 0xD5, 0xE5,
- 0xB7, 0xEF, 0xDC, 0x7C, 0x21, 0xDF, 0xDB, 0x0B,
- 0xD4, 0xD2, 0xD3, 0x86, 0x42, 0xE2, 0xD4, 0xF1,
- 0xF8, 0xB3, 0xDD, 0x68, 0x6E, 0x83, 0xDA, 0x1F,
- 0xCD, 0x16, 0xBE, 0x81, 0x5B, 0x26, 0xB9, 0xF6,
- 0xE1, 0x77, 0xB0, 0x6F, 0x77, 0x47, 0xB7, 0x18,
- 0xE6, 0x5A, 0x08, 0x88, 0x70, 0x6A, 0x0F, 0xFF,
- 0xCA, 0x3B, 0x06, 0x66, 0x5C, 0x0B, 0x01, 0x11,
- 0xFF, 0x9E, 0x65, 0x8F, 0x69, 0xAE, 0x62, 0xF8,
- 0xD3, 0xFF, 0x6B, 0x61, 0x45, 0xCF, 0x6C, 0x16,
- 0x78, 0xE2, 0x0A, 0xA0, 0xEE, 0xD2, 0x0D, 0xD7,
- 0x54, 0x83, 0x04, 0x4E, 0xC2, 0xB3, 0x03, 0x39,
- 0x61, 0x26, 0x67, 0xA7, 0xF7, 0x16, 0x60, 0xD0,
- 0x4D, 0x47, 0x69, 0x49, 0xDB, 0x77, 0x6E, 0x3E,
- 0x4A, 0x6A, 0xD1, 0xAE, 0xDC, 0x5A, 0xD6, 0xD9,
- 0x66, 0x0B, 0xDF, 0x40, 0xF0, 0x3B, 0xD8, 0x37,
- 0x53, 0xAE, 0xBC, 0xA9, 0xC5, 0x9E, 0xBB, 0xDE,
- 0x7F, 0xCF, 0xB2, 0x47, 0xE9, 0xFF, 0xB5, 0x30,
- 0x1C, 0xF2, 0xBD, 0xBD, 0x8A, 0xC2, 0xBA, 0xCA,
- 0x30, 0x93, 0xB3, 0x53, 0xA6, 0xA3, 0xB4, 0x24,
- 0x05, 0x36, 0xD0, 0xBA, 0x93, 0x06, 0xD7, 0xCD,
- 0x29, 0x57, 0xDE, 0x54, 0xBF, 0x67, 0xD9, 0x23,
- 0x2E, 0x7A, 0x66, 0xB3, 0xB8, 0x4A, 0x61, 0xC4,
- 0x02, 0x1B, 0x68, 0x5D, 0x94, 0x2B, 0x6F, 0x2A,
- 0x37, 0xBE, 0x0B, 0xB4, 0xA1, 0x8E, 0x0C, 0xC3,
- 0x1B, 0xDF, 0x05, 0x5A, 0x8D, 0xEF, 0x02, 0x2D,
-};
+namespace
+{
+ /**
+ * \brief 32-bit CRC (Cyclic Redundancy Check) lookup table (polynomial = 0x04C11DB7) with size 1024 bytes (256 x 4).
+ * CRC polynomial: X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X+1
+ **/
+ constexpr unsigned char _crc32LookupTable[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x96, 0x30, 0x07, 0x77,
+ 0x2C, 0x61, 0x0E, 0xEE, 0xBA, 0x51, 0x09, 0x99,
+ 0x19, 0xC4, 0x6D, 0x07, 0x8F, 0xF4, 0x6A, 0x70,
+ 0x35, 0xA5, 0x63, 0xE9, 0xA3, 0x95, 0x64, 0x9E,
+ 0x32, 0x88, 0xDB, 0x0E, 0xA4, 0xB8, 0xDC, 0x79,
+ 0x1E, 0xE9, 0xD5, 0xE0, 0x88, 0xD9, 0xD2, 0x97,
+ 0x2B, 0x4C, 0xB6, 0x09, 0xBD, 0x7C, 0xB1, 0x7E,
+ 0x07, 0x2D, 0xB8, 0xE7, 0x91, 0x1D, 0xBF, 0x90,
+ 0x64, 0x10, 0xB7, 0x1D, 0xF2, 0x20, 0xB0, 0x6A,
+ 0x48, 0x71, 0xB9, 0xF3, 0xDE, 0x41, 0xBE, 0x84,
+ 0x7D, 0xD4, 0xDA, 0x1A, 0xEB, 0xE4, 0xDD, 0x6D,
+ 0x51, 0xB5, 0xD4, 0xF4, 0xC7, 0x85, 0xD3, 0x83,
+ 0x56, 0x98, 0x6C, 0x13, 0xC0, 0xA8, 0x6B, 0x64,
+ 0x7A, 0xF9, 0x62, 0xFD, 0xEC, 0xC9, 0x65, 0x8A,
+ 0x4F, 0x5C, 0x01, 0x14, 0xD9, 0x6C, 0x06, 0x63,
+ 0x63, 0x3D, 0x0F, 0xFA, 0xF5, 0x0D, 0x08, 0x8D,
+ 0xC8, 0x20, 0x6E, 0x3B, 0x5E, 0x10, 0x69, 0x4C,
+ 0xE4, 0x41, 0x60, 0xD5, 0x72, 0x71, 0x67, 0xA2,
+ 0xD1, 0xE4, 0x03, 0x3C, 0x47, 0xD4, 0x04, 0x4B,
+ 0xFD, 0x85, 0x0D, 0xD2, 0x6B, 0xB5, 0x0A, 0xA5,
+ 0xFA, 0xA8, 0xB5, 0x35, 0x6C, 0x98, 0xB2, 0x42,
+ 0xD6, 0xC9, 0xBB, 0xDB, 0x40, 0xF9, 0xBC, 0xAC,
+ 0xE3, 0x6C, 0xD8, 0x32, 0x75, 0x5C, 0xDF, 0x45,
+ 0xCF, 0x0D, 0xD6, 0xDC, 0x59, 0x3D, 0xD1, 0xAB,
+ 0xAC, 0x30, 0xD9, 0x26, 0x3A, 0x00, 0xDE, 0x51,
+ 0x80, 0x51, 0xD7, 0xC8, 0x16, 0x61, 0xD0, 0xBF,
+ 0xB5, 0xF4, 0xB4, 0x21, 0x23, 0xC4, 0xB3, 0x56,
+ 0x99, 0x95, 0xBA, 0xCF, 0x0F, 0xA5, 0xBD, 0xB8,
+ 0x9E, 0xB8, 0x02, 0x28, 0x08, 0x88, 0x05, 0x5F,
+ 0xB2, 0xD9, 0x0C, 0xC6, 0x24, 0xE9, 0x0B, 0xB1,
+ 0x87, 0x7C, 0x6F, 0x2F, 0x11, 0x4C, 0x68, 0x58,
+ 0xAB, 0x1D, 0x61, 0xC1, 0x3D, 0x2D, 0x66, 0xB6,
+ 0x90, 0x41, 0xDC, 0x76, 0x06, 0x71, 0xDB, 0x01,
+ 0xBC, 0x20, 0xD2, 0x98, 0x2A, 0x10, 0xD5, 0xEF,
+ 0x89, 0x85, 0xB1, 0x71, 0x1F, 0xB5, 0xB6, 0x06,
+ 0xA5, 0xE4, 0xBF, 0x9F, 0x33, 0xD4, 0xB8, 0xE8,
+ 0xA2, 0xC9, 0x07, 0x78, 0x34, 0xF9, 0x00, 0x0F,
+ 0x8E, 0xA8, 0x09, 0x96, 0x18, 0x98, 0x0E, 0xE1,
+ 0xBB, 0x0D, 0x6A, 0x7F, 0x2D, 0x3D, 0x6D, 0x08,
+ 0x97, 0x6C, 0x64, 0x91, 0x01, 0x5C, 0x63, 0xE6,
+ 0xF4, 0x51, 0x6B, 0x6B, 0x62, 0x61, 0x6C, 0x1C,
+ 0xD8, 0x30, 0x65, 0x85, 0x4E, 0x00, 0x62, 0xF2,
+ 0xED, 0x95, 0x06, 0x6C, 0x7B, 0xA5, 0x01, 0x1B,
+ 0xC1, 0xF4, 0x08, 0x82, 0x57, 0xC4, 0x0F, 0xF5,
+ 0xC6, 0xD9, 0xB0, 0x65, 0x50, 0xE9, 0xB7, 0x12,
+ 0xEA, 0xB8, 0xBE, 0x8B, 0x7C, 0x88, 0xB9, 0xFC,
+ 0xDF, 0x1D, 0xDD, 0x62, 0x49, 0x2D, 0xDA, 0x15,
+ 0xF3, 0x7C, 0xD3, 0x8C, 0x65, 0x4C, 0xD4, 0xFB,
+ 0x58, 0x61, 0xB2, 0x4D, 0xCE, 0x51, 0xB5, 0x3A,
+ 0x74, 0x00, 0xBC, 0xA3, 0xE2, 0x30, 0xBB, 0xD4,
+ 0x41, 0xA5, 0xDF, 0x4A, 0xD7, 0x95, 0xD8, 0x3D,
+ 0x6D, 0xC4, 0xD1, 0xA4, 0xFB, 0xF4, 0xD6, 0xD3,
+ 0x6A, 0xE9, 0x69, 0x43, 0xFC, 0xD9, 0x6E, 0x34,
+ 0x46, 0x88, 0x67, 0xAD, 0xD0, 0xB8, 0x60, 0xDA,
+ 0x73, 0x2D, 0x04, 0x44, 0xE5, 0x1D, 0x03, 0x33,
+ 0x5F, 0x4C, 0x0A, 0xAA, 0xC9, 0x7C, 0x0D, 0xDD,
+ 0x3C, 0x71, 0x05, 0x50, 0xAA, 0x41, 0x02, 0x27,
+ 0x10, 0x10, 0x0B, 0xBE, 0x86, 0x20, 0x0C, 0xC9,
+ 0x25, 0xB5, 0x68, 0x57, 0xB3, 0x85, 0x6F, 0x20,
+ 0x09, 0xD4, 0x66, 0xB9, 0x9F, 0xE4, 0x61, 0xCE,
+ 0x0E, 0xF9, 0xDE, 0x5E, 0x98, 0xC9, 0xD9, 0x29,
+ 0x22, 0x98, 0xD0, 0xB0, 0xB4, 0xA8, 0xD7, 0xC7,
+ 0x17, 0x3D, 0xB3, 0x59, 0x81, 0x0D, 0xB4, 0x2E,
+ 0x3B, 0x5C, 0xBD, 0xB7, 0xAD, 0x6C, 0xBA, 0xC0,
+ 0x20, 0x83, 0xB8, 0xED, 0xB6, 0xB3, 0xBF, 0x9A,
+ 0x0C, 0xE2, 0xB6, 0x03, 0x9A, 0xD2, 0xB1, 0x74,
+ 0x39, 0x47, 0xD5, 0xEA, 0xAF, 0x77, 0xD2, 0x9D,
+ 0x15, 0x26, 0xDB, 0x04, 0x83, 0x16, 0xDC, 0x73,
+ 0x12, 0x0B, 0x63, 0xE3, 0x84, 0x3B, 0x64, 0x94,
+ 0x3E, 0x6A, 0x6D, 0x0D, 0xA8, 0x5A, 0x6A, 0x7A,
+ 0x0B, 0xCF, 0x0E, 0xE4, 0x9D, 0xFF, 0x09, 0x93,
+ 0x27, 0xAE, 0x00, 0x0A, 0xB1, 0x9E, 0x07, 0x7D,
+ 0x44, 0x93, 0x0F, 0xF0, 0xD2, 0xA3, 0x08, 0x87,
+ 0x68, 0xF2, 0x01, 0x1E, 0xFE, 0xC2, 0x06, 0x69,
+ 0x5D, 0x57, 0x62, 0xF7, 0xCB, 0x67, 0x65, 0x80,
+ 0x71, 0x36, 0x6C, 0x19, 0xE7, 0x06, 0x6B, 0x6E,
+ 0x76, 0x1B, 0xD4, 0xFE, 0xE0, 0x2B, 0xD3, 0x89,
+ 0x5A, 0x7A, 0xDA, 0x10, 0xCC, 0x4A, 0xDD, 0x67,
+ 0x6F, 0xDF, 0xB9, 0xF9, 0xF9, 0xEF, 0xBE, 0x8E,
+ 0x43, 0xBE, 0xB7, 0x17, 0xD5, 0x8E, 0xB0, 0x60,
+ 0xE8, 0xA3, 0xD6, 0xD6, 0x7E, 0x93, 0xD1, 0xA1,
+ 0xC4, 0xC2, 0xD8, 0x38, 0x52, 0xF2, 0xDF, 0x4F,
+ 0xF1, 0x67, 0xBB, 0xD1, 0x67, 0x57, 0xBC, 0xA6,
+ 0xDD, 0x06, 0xB5, 0x3F, 0x4B, 0x36, 0xB2, 0x48,
+ 0xDA, 0x2B, 0x0D, 0xD8, 0x4C, 0x1B, 0x0A, 0xAF,
+ 0xF6, 0x4A, 0x03, 0x36, 0x60, 0x7A, 0x04, 0x41,
+ 0xC3, 0xEF, 0x60, 0xDF, 0x55, 0xDF, 0x67, 0xA8,
+ 0xEF, 0x8E, 0x6E, 0x31, 0x79, 0xBE, 0x69, 0x46,
+ 0x8C, 0xB3, 0x61, 0xCB, 0x1A, 0x83, 0x66, 0xBC,
+ 0xA0, 0xD2, 0x6F, 0x25, 0x36, 0xE2, 0x68, 0x52,
+ 0x95, 0x77, 0x0C, 0xCC, 0x03, 0x47, 0x0B, 0xBB,
+ 0xB9, 0x16, 0x02, 0x22, 0x2F, 0x26, 0x05, 0x55,
+ 0xBE, 0x3B, 0xBA, 0xC5, 0x28, 0x0B, 0xBD, 0xB2,
+ 0x92, 0x5A, 0xB4, 0x2B, 0x04, 0x6A, 0xB3, 0x5C,
+ 0xA7, 0xFF, 0xD7, 0xC2, 0x31, 0xCF, 0xD0, 0xB5,
+ 0x8B, 0x9E, 0xD9, 0x2C, 0x1D, 0xAE, 0xDE, 0x5B,
+ 0xB0, 0xC2, 0x64, 0x9B, 0x26, 0xF2, 0x63, 0xEC,
+ 0x9C, 0xA3, 0x6A, 0x75, 0x0A, 0x93, 0x6D, 0x02,
+ 0xA9, 0x06, 0x09, 0x9C, 0x3F, 0x36, 0x0E, 0xEB,
+ 0x85, 0x67, 0x07, 0x72, 0x13, 0x57, 0x00, 0x05,
+ 0x82, 0x4A, 0xBF, 0x95, 0x14, 0x7A, 0xB8, 0xE2,
+ 0xAE, 0x2B, 0xB1, 0x7B, 0x38, 0x1B, 0xB6, 0x0C,
+ 0x9B, 0x8E, 0xD2, 0x92, 0x0D, 0xBE, 0xD5, 0xE5,
+ 0xB7, 0xEF, 0xDC, 0x7C, 0x21, 0xDF, 0xDB, 0x0B,
+ 0xD4, 0xD2, 0xD3, 0x86, 0x42, 0xE2, 0xD4, 0xF1,
+ 0xF8, 0xB3, 0xDD, 0x68, 0x6E, 0x83, 0xDA, 0x1F,
+ 0xCD, 0x16, 0xBE, 0x81, 0x5B, 0x26, 0xB9, 0xF6,
+ 0xE1, 0x77, 0xB0, 0x6F, 0x77, 0x47, 0xB7, 0x18,
+ 0xE6, 0x5A, 0x08, 0x88, 0x70, 0x6A, 0x0F, 0xFF,
+ 0xCA, 0x3B, 0x06, 0x66, 0x5C, 0x0B, 0x01, 0x11,
+ 0xFF, 0x9E, 0x65, 0x8F, 0x69, 0xAE, 0x62, 0xF8,
+ 0xD3, 0xFF, 0x6B, 0x61, 0x45, 0xCF, 0x6C, 0x16,
+ 0x78, 0xE2, 0x0A, 0xA0, 0xEE, 0xD2, 0x0D, 0xD7,
+ 0x54, 0x83, 0x04, 0x4E, 0xC2, 0xB3, 0x03, 0x39,
+ 0x61, 0x26, 0x67, 0xA7, 0xF7, 0x16, 0x60, 0xD0,
+ 0x4D, 0x47, 0x69, 0x49, 0xDB, 0x77, 0x6E, 0x3E,
+ 0x4A, 0x6A, 0xD1, 0xAE, 0xDC, 0x5A, 0xD6, 0xD9,
+ 0x66, 0x0B, 0xDF, 0x40, 0xF0, 0x3B, 0xD8, 0x37,
+ 0x53, 0xAE, 0xBC, 0xA9, 0xC5, 0x9E, 0xBB, 0xDE,
+ 0x7F, 0xCF, 0xB2, 0x47, 0xE9, 0xFF, 0xB5, 0x30,
+ 0x1C, 0xF2, 0xBD, 0xBD, 0x8A, 0xC2, 0xBA, 0xCA,
+ 0x30, 0x93, 0xB3, 0x53, 0xA6, 0xA3, 0xB4, 0x24,
+ 0x05, 0x36, 0xD0, 0xBA, 0x93, 0x06, 0xD7, 0xCD,
+ 0x29, 0x57, 0xDE, 0x54, 0xBF, 0x67, 0xD9, 0x23,
+ 0x2E, 0x7A, 0x66, 0xB3, 0xB8, 0x4A, 0x61, 0xC4,
+ 0x02, 0x1B, 0x68, 0x5D, 0x94, 0x2B, 0x6F, 0x2A,
+ 0x37, 0xBE, 0x0B, 0xB4, 0xA1, 0x8E, 0x0C, 0xC3,
+ 0x1B, 0xDF, 0x05, 0x5A, 0x8D, 0xEF, 0x02, 0x2D,
+ };
+}
AREG_API_IMPL unsigned int NEMath::crc32Calculate( const unsigned char* data, int size )
{
diff --git a/framework/areg/base/private/NEString.cpp b/framework/areg/base/private/NEString.cpp
index e3ab5858e..990058d05 100644
--- a/framework/areg/base/private/NEString.cpp
+++ b/framework/areg/base/private/NEString.cpp
@@ -35,215 +35,218 @@
#define SYMBOL static_cast(NEString::eCharDefs::CD_Symbol | NEString::eCharDefs::CD_Printable ) /* All symbols */
#define LETTER static_cast(NEString::eCharDefs::CD_Letter | NEString::eCharDefs::CD_Printable ) /* All letters */
-// ISO 8859-1
-static constexpr unsigned short ASCII_ISO8859_1_Table[] =
+namespace
{
- /* 0 - 0 */ EOFS | EOFL // '\0', end of string
- /* 1 - 4 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 1 == SOH , 2 == STX , 3 == ETX , 4 == EOT
- /* 5 - 8 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 5 == ENQ , 6 == ACK , 7 == BEL , 8 == '\b'
- /* 9 - 12 */ , PRINT | CTRL | SPACE , EOFL | CTRL | PRINT , PRINT | CTRL , EOFL | CTRL // 9 == '\t' , 10 == '\n' , 11 == '\v' , 12 == '\f'
- /* 13 - 16 */ , DEOL | CTRL | PRINT , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 13 == '\r' , 14 == SO , 15 == SI , 16 == DLE
- /* 17 - 20 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 17 == DC1 , 18 == DC2 , 19 == DC3 , 20 == DC4
- /* 21 - 24 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 21 == NAK , 22 == SYN , 23 == ETB , 24 == CAN
- /* 25 - 28 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 25 == EM , 26 == SUB , 27 == ESC , 28 == FS
- /* 29 - 32 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , PRINT | SPACE // 29 == GS , 30 == RS , 31 == US , 32 == ' '
- /* 33 - 36 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 33 == '!' , 34 == '\"' , 35 == '#' , 36 == '$'
- /* 37 - 40 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 37 == '%' , 38 == '&' , 39 == '\'' , 40 == '('
- /* 41 - 44 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 41 == ')' , 42 == '*' , 43 == '+' , 44 == ','
- /* 45 - 48 */ , SYMBOL , SYMBOL , SYMBOL , NUMBER // 45 == '-' , 46 == '.' , 47 == '/' , 48 == '0'
- /* 49 - 52 */ , NUMBER , NUMBER , NUMBER , NUMBER // 49 == '1' , 50 == '2' , 51 == '3' , 52 == '4'
- /* 53 - 56 */ , NUMBER , NUMBER , NUMBER , NUMBER // 53 == '5' , 54 == '6' , 55 == '7' , 56 == '8'
- /* 57 - 60 */ , NUMBER , SYMBOL , SYMBOL , SYMBOL // 57 == '9' , 58 == ':' , 59 == ';' , 60 == '<'
- /* 61 - 64 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 61 == '=' , 62 == '>' , 63 == '?' , 64 == '@'
- /* 65 - 68 */ , LETTER , LETTER , LETTER , LETTER // 65 == 'A' , 66 == 'B' , 67 == 'C' , 68 == 'D'
- /* 69 - 72 */ , LETTER , LETTER , LETTER , LETTER // 69 == 'E' , 70 == 'F' , 71 == 'G' , 72 == 'H'
- /* 73 - 76 */ , LETTER , LETTER , LETTER , LETTER // 73 == 'I' , 74 == 'J' , 74 == 'K' , 76 == 'L'
- /* 77 - 80 */ , LETTER , LETTER , LETTER , LETTER // 77 == 'M' , 78 == 'N' , 79 == 'O' , 80 == 'P'
- /* 81 - 84 */ , LETTER , LETTER , LETTER , LETTER // 81 == 'Q' , 82 == 'R' , 83 == 'S' , 84 == 'T'
- /* 85 - 88 */ , LETTER , LETTER , LETTER , LETTER // 85 == 'U' , 86 == 'V' , 87 == 'W' , 88 == 'X'
- /* 89 - 92 */ , LETTER , LETTER , SYMBOL , SYMBOL // 89 == 'Y' , 90 == 'Z' , 91 == '[' , 92 == '\\'
- /* 93 - 96 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 93 == ']' , 94 == '^' , 95 == '_' , 96 == '`'
- /* 97 - 100 */ , LETTER , LETTER , LETTER , LETTER // 97 == 'a' , 98 == 'b' , 99 == 'c' , 100 == 'd'
- /* 101 - 104 */ , LETTER , LETTER , LETTER , LETTER // 101 == 'e' , 102 == 'f' , 103 == 'g' , 104 == 'h'
- /* 105 - 108 */ , LETTER , LETTER , LETTER , LETTER // 105 == 'i' , 106 == 'j' , 107 == 'k' , 108 == 'l'
- /* 109 - 112 */ , LETTER , LETTER , LETTER , LETTER // 109 == 'm' , 110 == 'n' , 111 == 'o' , 112 == 'p'
- /* 113 - 116 */ , LETTER , LETTER , LETTER , LETTER // 113 == 'q' , 114 == 'r' , 115 == 's' , 116 == 't'
- /* 117 - 120 */ , LETTER , LETTER , LETTER , LETTER // 117 == 'u' , 118 == 'v' , 119 == 'w' , 120 == 'x'
- /* 121 - 124 */ , LETTER , LETTER , SYMBOL , SYMBOL // 121 == 'y' , 122 == 'z' , 123 == '{' , 124 == '|'
- /* 125 - 128 */ , SYMBOL , SYMBOL , CTRL | EOFL , SYMBOL // 125 == '}' , 126 == '~' , 127 == DEL , 128 == '�'
- /* 129 - 132 */ , EOFL , SYMBOL , SYMBOL , SYMBOL // 129 , 130 == '�' , 131 == '�' , 132 == '�'
- /* 133 - 136 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 133 == '�' , 134 == '�' , 135 == '�' , 136 == '�'
- /* 137 - 140 */ , SYMBOL , LETTER , SYMBOL , LETTER // 137 == '�' , 138 == '�' , 139 == '�' , 140 == '�'
- /* 141 - 144 */ , EOFL , LETTER , EOFL , EOFL // 141 , 142 == '�' , 143 , 144
- /* 145 - 148 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 145 == '�' , 146 == '�' , 147 == '�' , 148 == '�'
- /* 149 - 152 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 149 == '�' , 150 == '�' , 151 == '�' , 152 == '�"
- /* 153 - 156 */ , SYMBOL , LETTER , SYMBOL , LETTER // 153 == '�' , 154 == '�' , 155 == '�' , 156 == '�'
- /* 157 - 160 */ , EOFL , LETTER , LETTER , SYMBOL // 157 , 158 == '�' , 159 == '�' , 160 == '�'
- /* 161 - 164 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 161 == '�' , 162 == '�' , 163 == '�' , 164 == '�'
- /* 165 - 168 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 165 == '�' , 166 == '�' , 167 == '�' , 168 == '�'
- /* 169 - 172 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 169 == '�' , 170 == '�' , 171 == '�' , 172 == '�'
- /* 173 - 176 */ , CTRL , SYMBOL , SYMBOL , SYMBOL // 173 , 174 == '�' , 175 == '�' , 176 == '�'
- /* 177 - 180 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 177 == '�' , 178 == '�' , 179 == '�' , 180 == '�'
- /* 181 - 184 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 181 == '�' , 182 == '�' , 183 == '�' , 184 == '�'
- /* 185 - 188 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 185 == '�' , 186 == '�' , 187 == '�' , 188 == '�'
- /* 189 - 192 */ , SYMBOL , SYMBOL , SYMBOL , LETTER // 189 == '�' , 190 == '�' , 191 == '�' , 192 == '�'
- /* 193 - 196 */ , LETTER , LETTER , LETTER , LETTER // 193 == '�' , 194 == '�' , 195 == '�' , 196 == '�'
- /* 197 - 200 */ , LETTER , LETTER , LETTER , LETTER // 197 == '�' , 198 == '�' , 199 == '�' , 200 == '�'
- /* 201 - 204 */ , LETTER , LETTER , LETTER , LETTER // 201 == '�' , 202 == '�' , 203 == '�' , 204 == '�'
- /* 205 - 208 */ , LETTER , LETTER , LETTER , LETTER // 205 == '�' , 206 == '�' , 207 == '�' , 208 == '�'
- /* 209 - 212 */ , LETTER , LETTER , LETTER , LETTER // 209 == '�' , 210 == '�' , 211 == '�' , 212 == '�'
- /* 213 - 216 */ , LETTER , LETTER , SYMBOL , LETTER // 213 == '�' , 214 == '�' , 215 == '�' , 216 == '�'
- /* 217 - 220 */ , LETTER , LETTER , LETTER , LETTER // 217 == '�' , 218 == '�' , 219 == '�' , 220 == '�'
- /* 221 - 224 */ , LETTER , LETTER , LETTER , LETTER // 221 == '�' , 222 == '�' , 223 == '�' , 224 == '�'
- /* 225 - 228 */ , LETTER , LETTER , LETTER , LETTER // 225 == '�' , 226 == '�' , 227 == '�' , 228 == '�'
- /* 229 - 232 */ , LETTER , LETTER , LETTER , LETTER // 229 == '�' , 230 == '�' , 231 == '�' , 232 == '�'
- /* 233 - 236 */ , LETTER , LETTER , LETTER , LETTER // 233 == '�' , 234 == '�' , 235 == '�' , 236 == '�'
- /* 237 - 240 */ , LETTER , LETTER , LETTER , LETTER // 237 == '�' , 238 == '�' , 239 == '�' , 240 == '�'
- /* 241 - 244 */ , LETTER , LETTER , LETTER , LETTER // 241 == '�' , 242 == '�' , 243 == '�' , 244 == '�'
- /* 245 - 248 */ , LETTER , LETTER , SYMBOL , LETTER // 245 == '�' , 246 == '�' , 247 == '�' , 248 == '�'
- /* 249 - 252 */ , LETTER , LETTER , LETTER , LETTER // 249 == '�' , 250 == '�' , 251 == '�' , 252 == '�'
- /* 253 - 255 */ , LETTER , LETTER , LETTER // 253 == '�' , 254 == '�' , 255 == '�'
-};
+ // ISO 8859-1
+ constexpr unsigned short ASCII_ISO8859_1_Table[] =
+ {
+ /* 0 - 0 */ EOFS | EOFL // '\0', end of string
+ /* 1 - 4 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 1 == SOH , 2 == STX , 3 == ETX , 4 == EOT
+ /* 5 - 8 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 5 == ENQ , 6 == ACK , 7 == BEL , 8 == '\b'
+ /* 9 - 12 */ , PRINT | CTRL | SPACE , EOFL | CTRL | PRINT , PRINT | CTRL , EOFL | CTRL // 9 == '\t' , 10 == '\n' , 11 == '\v' , 12 == '\f'
+ /* 13 - 16 */ , DEOL | CTRL | PRINT , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 13 == '\r' , 14 == SO , 15 == SI , 16 == DLE
+ /* 17 - 20 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 17 == DC1 , 18 == DC2 , 19 == DC3 , 20 == DC4
+ /* 21 - 24 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 21 == NAK , 22 == SYN , 23 == ETB , 24 == CAN
+ /* 25 - 28 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL // 25 == EM , 26 == SUB , 27 == ESC , 28 == FS
+ /* 29 - 32 */ , EOFL | CTRL , EOFL | CTRL , EOFL | CTRL , PRINT | SPACE // 29 == GS , 30 == RS , 31 == US , 32 == ' '
+ /* 33 - 36 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 33 == '!' , 34 == '\"' , 35 == '#' , 36 == '$'
+ /* 37 - 40 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 37 == '%' , 38 == '&' , 39 == '\'' , 40 == '('
+ /* 41 - 44 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 41 == ')' , 42 == '*' , 43 == '+' , 44 == ','
+ /* 45 - 48 */ , SYMBOL , SYMBOL , SYMBOL , NUMBER // 45 == '-' , 46 == '.' , 47 == '/' , 48 == '0'
+ /* 49 - 52 */ , NUMBER , NUMBER , NUMBER , NUMBER // 49 == '1' , 50 == '2' , 51 == '3' , 52 == '4'
+ /* 53 - 56 */ , NUMBER , NUMBER , NUMBER , NUMBER // 53 == '5' , 54 == '6' , 55 == '7' , 56 == '8'
+ /* 57 - 60 */ , NUMBER , SYMBOL , SYMBOL , SYMBOL // 57 == '9' , 58 == ':' , 59 == ';' , 60 == '<'
+ /* 61 - 64 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 61 == '=' , 62 == '>' , 63 == '?' , 64 == '@'
+ /* 65 - 68 */ , LETTER , LETTER , LETTER , LETTER // 65 == 'A' , 66 == 'B' , 67 == 'C' , 68 == 'D'
+ /* 69 - 72 */ , LETTER , LETTER , LETTER , LETTER // 69 == 'E' , 70 == 'F' , 71 == 'G' , 72 == 'H'
+ /* 73 - 76 */ , LETTER , LETTER , LETTER , LETTER // 73 == 'I' , 74 == 'J' , 74 == 'K' , 76 == 'L'
+ /* 77 - 80 */ , LETTER , LETTER , LETTER , LETTER // 77 == 'M' , 78 == 'N' , 79 == 'O' , 80 == 'P'
+ /* 81 - 84 */ , LETTER , LETTER , LETTER , LETTER // 81 == 'Q' , 82 == 'R' , 83 == 'S' , 84 == 'T'
+ /* 85 - 88 */ , LETTER , LETTER , LETTER , LETTER // 85 == 'U' , 86 == 'V' , 87 == 'W' , 88 == 'X'
+ /* 89 - 92 */ , LETTER , LETTER , SYMBOL , SYMBOL // 89 == 'Y' , 90 == 'Z' , 91 == '[' , 92 == '\\'
+ /* 93 - 96 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 93 == ']' , 94 == '^' , 95 == '_' , 96 == '`'
+ /* 97 - 100 */ , LETTER , LETTER , LETTER , LETTER // 97 == 'a' , 98 == 'b' , 99 == 'c' , 100 == 'd'
+ /* 101 - 104 */ , LETTER , LETTER , LETTER , LETTER // 101 == 'e' , 102 == 'f' , 103 == 'g' , 104 == 'h'
+ /* 105 - 108 */ , LETTER , LETTER , LETTER , LETTER // 105 == 'i' , 106 == 'j' , 107 == 'k' , 108 == 'l'
+ /* 109 - 112 */ , LETTER , LETTER , LETTER , LETTER // 109 == 'm' , 110 == 'n' , 111 == 'o' , 112 == 'p'
+ /* 113 - 116 */ , LETTER , LETTER , LETTER , LETTER // 113 == 'q' , 114 == 'r' , 115 == 's' , 116 == 't'
+ /* 117 - 120 */ , LETTER , LETTER , LETTER , LETTER // 117 == 'u' , 118 == 'v' , 119 == 'w' , 120 == 'x'
+ /* 121 - 124 */ , LETTER , LETTER , SYMBOL , SYMBOL // 121 == 'y' , 122 == 'z' , 123 == '{' , 124 == '|'
+ /* 125 - 128 */ , SYMBOL , SYMBOL , CTRL | EOFL , SYMBOL // 125 == '}' , 126 == '~' , 127 == DEL , 128 == '�'
+ /* 129 - 132 */ , EOFL , SYMBOL , SYMBOL , SYMBOL // 129 , 130 == '�' , 131 == '�' , 132 == '�'
+ /* 133 - 136 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 133 == '�' , 134 == '�' , 135 == '�' , 136 == '�'
+ /* 137 - 140 */ , SYMBOL , LETTER , SYMBOL , LETTER // 137 == '�' , 138 == '�' , 139 == '�' , 140 == '�'
+ /* 141 - 144 */ , EOFL , LETTER , EOFL , EOFL // 141 , 142 == '�' , 143 , 144
+ /* 145 - 148 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 145 == '�' , 146 == '�' , 147 == '�' , 148 == '�'
+ /* 149 - 152 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 149 == '�' , 150 == '�' , 151 == '�' , 152 == '�"
+ /* 153 - 156 */ , SYMBOL , LETTER , SYMBOL , LETTER // 153 == '�' , 154 == '�' , 155 == '�' , 156 == '�'
+ /* 157 - 160 */ , EOFL , LETTER , LETTER , SYMBOL // 157 , 158 == '�' , 159 == '�' , 160 == '�'
+ /* 161 - 164 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 161 == '�' , 162 == '�' , 163 == '�' , 164 == '�'
+ /* 165 - 168 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 165 == '�' , 166 == '�' , 167 == '�' , 168 == '�'
+ /* 169 - 172 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 169 == '�' , 170 == '�' , 171 == '�' , 172 == '�'
+ /* 173 - 176 */ , CTRL , SYMBOL , SYMBOL , SYMBOL // 173 , 174 == '�' , 175 == '�' , 176 == '�'
+ /* 177 - 180 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 177 == '�' , 178 == '�' , 179 == '�' , 180 == '�'
+ /* 181 - 184 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 181 == '�' , 182 == '�' , 183 == '�' , 184 == '�'
+ /* 185 - 188 */ , SYMBOL , SYMBOL , SYMBOL , SYMBOL // 185 == '�' , 186 == '�' , 187 == '�' , 188 == '�'
+ /* 189 - 192 */ , SYMBOL , SYMBOL , SYMBOL , LETTER // 189 == '�' , 190 == '�' , 191 == '�' , 192 == '�'
+ /* 193 - 196 */ , LETTER , LETTER , LETTER , LETTER // 193 == '�' , 194 == '�' , 195 == '�' , 196 == '�'
+ /* 197 - 200 */ , LETTER , LETTER , LETTER , LETTER // 197 == '�' , 198 == '�' , 199 == '�' , 200 == '�'
+ /* 201 - 204 */ , LETTER , LETTER , LETTER , LETTER // 201 == '�' , 202 == '�' , 203 == '�' , 204 == '�'
+ /* 205 - 208 */ , LETTER , LETTER , LETTER , LETTER // 205 == '�' , 206 == '�' , 207 == '�' , 208 == '�'
+ /* 209 - 212 */ , LETTER , LETTER , LETTER , LETTER // 209 == '�' , 210 == '�' , 211 == '�' , 212 == '�'
+ /* 213 - 216 */ , LETTER , LETTER , SYMBOL , LETTER // 213 == '�' , 214 == '�' , 215 == '�' , 216 == '�'
+ /* 217 - 220 */ , LETTER , LETTER , LETTER , LETTER // 217 == '�' , 218 == '�' , 219 == '�' , 220 == '�'
+ /* 221 - 224 */ , LETTER , LETTER , LETTER , LETTER // 221 == '�' , 222 == '�' , 223 == '�' , 224 == '�'
+ /* 225 - 228 */ , LETTER , LETTER , LETTER , LETTER // 225 == '�' , 226 == '�' , 227 == '�' , 228 == '�'
+ /* 229 - 232 */ , LETTER , LETTER , LETTER , LETTER // 229 == '�' , 230 == '�' , 231 == '�' , 232 == '�'
+ /* 233 - 236 */ , LETTER , LETTER , LETTER , LETTER // 233 == '�' , 234 == '�' , 235 == '�' , 236 == '�'
+ /* 237 - 240 */ , LETTER , LETTER , LETTER , LETTER // 237 == '�' , 238 == '�' , 239 == '�' , 240 == '�'
+ /* 241 - 244 */ , LETTER , LETTER , LETTER , LETTER // 241 == '�' , 242 == '�' , 243 == '�' , 244 == '�'
+ /* 245 - 248 */ , LETTER , LETTER , SYMBOL , LETTER // 245 == '�' , 246 == '�' , 247 == '�' , 248 == '�'
+ /* 249 - 252 */ , LETTER , LETTER , LETTER , LETTER // 249 == '�' , 250 == '�' , 251 == '�' , 252 == '�'
+ /* 253 - 255 */ , LETTER , LETTER , LETTER // 253 == '�' , 254 == '�' , 255 == '�'
+ };
-// ISO 8859-1
-static constexpr unsigned char ASCII_ISO8859_1_Table_lower[] =
-{
- /* 0 - 0 */ 0 // '\0', end of string
- /* 1 - 4 */ , 1 , 2 , 3 , 4 // 1 == SOH , 2 == STX , 3 == ETX , 4 == EOT
- /* 5 - 8 */ , 5 , 6 , 7 , 8 // 5 == ENQ , 6 == ACK , 7 == BEL , 8 == '\b'
- /* 9 - 12 */ , 9 , 10 , 11 , 12 // 9 == '\t' , 10 == '\n' , 11 == '\v' , 12 == '\f'
- /* 13 - 16 */ , 13 , 14 , 15 , 16 // 13 == '\r' , 14 == SO , 15 == SI , 16 == DLE
- /* 17 - 20 */ , 17 , 18 , 19 , 20 // 17 == DC1 , 18 == DC2 , 19 == DC3 , 20 == DC4
- /* 21 - 24 */ , 21 , 22 , 23 , 24 // 21 == NAK , 22 == SYN , 23 == ETB , 24 == CAN
- /* 25 - 28 */ , 25 , 26 , 27 , 28 // 25 == EM , 26 == SUB , 27 == ESC , 28 == FS
- /* 29 - 32 */ , 29 , 30 , 31 , 32 // 29 == GS , 30 == RS , 31 == US , 32 == ' '
- /* 33 - 36 */ , 33 , 34 , 35 , 36 // 33 == '!' , 34 == '\"' , 35 == '#' , 36 == '$'
- /* 37 - 40 */ , 37 , 38 , 39 , 40 // 37 == '%' , 38 == '&' , 39 == '\'' , 40 == '('
- /* 41 - 44 */ , 41 , 42 , 43 , 44 // 41 == ')' , 42 == '*' , 43 == '+' , 44 == ','
- /* 45 - 48 */ , 45 , 46 , 47 , 48 // 45 == '-' , 46 == '.' , 47 == '/' , 48 == '0'
- /* 49 - 52 */ , 49 , 50 , 51 , 52 // 49 == '1' , 50 == '2' , 51 == '3' , 52 == '4'
- /* 53 - 56 */ , 53 , 54 , 55 , 56 // 53 == '5' , 54 == '6' , 55 == '7' , 56 == '8'
- /* 57 - 60 */ , 57 , 58 , 59 , 60 // 57 == '9' , 58 == ':' , 59 == ';' , 60 == '<'
- /* 61 - 64 */ , 61 , 62 , 63 , 64 // 61 == '=' , 62 == '>' , 63 == '?' , 64 == '@'
- /* 65 - 68 */ , 97 /* 'a' */ , 98 /* 'b' */ , 99 /* 'c' */ , 100 /* 'd' */ // 65 == 'A' , 66 == 'B' , 67 == 'C' , 68 == 'D'
- /* 69 - 72 */ , 101 /* 'e' */ , 102 /* 'f' */ , 103 /* 'g' */ , 104 /* 'h' */ // 69 == 'E' , 70 == 'F' , 71 == 'G' , 72 == 'H'
- /* 73 - 76 */ , 105 /* 'i' */ , 106 /* 'j' */ , 107 /* 'k' */ , 108 /* 'l' */ // 73 == 'I' , 74 == 'J' , 74 == 'K' , 76 == 'L'
- /* 77 - 80 */ , 109 /* 'm' */ , 110 /* 'n' */ , 111 /* 'o' */ , 112 /* 'p' */ // 77 == 'M' , 78 == 'N' , 79 == 'O' , 80 == 'P'
- /* 81 - 84 */ , 113 /* 'q' */ , 114 /* 'r' */ , 115 /* 's' */ , 116 /* 't' */ // 81 == 'Q' , 82 == 'R' , 83 == 'S' , 84 == 'T'
- /* 85 - 88 */ , 117 /* 'u' */ , 118 /* 'v' */ , 119 /* 'w' */ , 120 /* 'x' */ // 85 == 'U' , 86 == 'V' , 87 == 'W' , 88 == 'X'
- /* 89 - 92 */ , 121 /* 'y' */ , 122 /* 'z' */ , 91 , 92 // 89 == 'Y' , 90 == 'Z' , 91 == '[' , 92 == '\\'
- /* 93 - 96 */ , 93 , 94 , 95 , 96 // 93 == ']' , 94 == '^' , 95 == '_' , 96 == '`'
- /* 97 - 100 */ , 97 /* 'a' */ , 98 /* 'b' */ , 99 /* 'c' */ , 100 /* 'd' */ // 97 == 'a' , 98 == 'b' , 99 == 'c' , 100 == 'd'
- /* 101 - 104 */ , 101 /* 'e' */ , 102 /* 'f' */ , 103 /* 'g' */ , 104 /* 'h' */ // 101 == 'e' , 102 == 'f' , 103 == 'g' , 104 == 'h'
- /* 105 - 108 */ , 105 /* 'i' */ , 106 /* 'j' */ , 107 /* 'k' */ , 108 /* 'l' */ // 105 == 'i' , 106 == 'j' , 107 == 'k' , 108 == 'l'
- /* 109 - 112 */ , 109 /* 'm' */ , 110 /* 'n' */ , 111 /* 'o' */ , 112 /* 'p' */ // 109 == 'm' , 110 == 'n' , 111 == 'o' , 112 == 'p'
- /* 113 - 116 */ , 113 /* 'q' */ , 114 /* 'r' */ , 115 /* 's' */ , 116 /* 't' */ // 113 == 'q' , 114 == 'r' , 115 == 's' , 116 == 't'
- /* 117 - 120 */ , 117 /* 'u' */ , 118 /* 'v' */ , 119 /* 'w' */ , 120 /* 'x' */ // 117 == 'u' , 118 == 'v' , 119 == 'w' , 120 == 'x'
- /* 121 - 124 */ , 121 /* 'y' */ , 122 /* 'z' */ , 123 , 124 // 121 == 'y' , 122 == 'z' , 123 == '{' , 124 == '|'
- /* 125 - 128 */ , 125 , 126 , 127 , 128 // 125 == '}' , 126 == '~' , 127 == DEL , 128 == '�'
- /* 129 - 132 */ , 129 , 130 , 131 , 132 // 129 , 130 == '�' , 131 == '�' , 132 == '�'
- /* 133 - 136 */ , 133 , 134 , 135 , 136 // 133 == '�' , 134 == '�' , 135 == '�' , 136 == '�'
- /* 137 - 140 */ , 137 , 154 /* '�' */ , 139 , 156 /* '�' */ // 137 == '�' , 138 == '�' , 139 == '�' , 140 == '�'
- /* 141 - 144 */ , 141 , 158 /* '�' */ , 143 , 144 // 141 , 142 == '�' , 143 , 144
- /* 145 - 148 */ , 145 , 146 , 147 , 148 // 145 == '�' , 146 == '�' , 147 == '�' , 148 == '�'
- /* 149 - 152 */ , 149 , 150 , 151 , 152 // 149 == '�' , 150 == '�' , 151 == '�' , 152 == '�"
- /* 153 - 156 */ , 153 , 154 /* '�' */ , 155 , 156 /* '�' */ // 153 == '�' , 154 == '�' , 155 == '�' , 156 == '�'
- /* 157 - 160 */ , 157 , 158 /* '�' */ , 255 /* '�' */ , 160 // 157 , 158 == '�' , 159 == '�' , 160 == '�'
- /* 161 - 164 */ , 161 , 162 , 163 , 164 // 161 == '�' , 162 == '�' , 163 == '�' , 164 == '�'
- /* 165 - 168 */ , 165 , 166 , 167 , 168 // 165 == '�' , 166 == '�' , 167 == '�' , 168 == '�'
- /* 169 - 172 */ , 169 , 170 , 171 , 172 // 169 == '�' , 170 == '�' , 171 == '�' , 172 == '�'
- /* 173 - 176 */ , 173 , 174 , 175 , 176 // 173 , 174 == '�' , 175 == '�' , 176 == '�'
- /* 177 - 180 */ , 177 , 178 , 179 , 180 // 177 == '�' , 178 == '�' , 179 == '�' , 180 == '�'
- /* 181 - 184 */ , 181 , 182 , 183 , 184 // 181 == '�' , 182 == '�' , 183 == '�' , 184 == '�'
- /* 185 - 188 */ , 185 , 186 , 187 , 188 // 185 == '�' , 186 == '�' , 187 == '�' , 188 == '�'
- /* 189 - 192 */ , 189 , 190 , 191 , 224 /* '�' */ // 189 == '�' , 190 == '�' , 191 == '�' , 192 == '�'
- /* 193 - 196 */ , 225 /* '�' */ , 226 /* '�' */ , 227 /* '�' */ , 228 /* '�' */ // 193 == '�' , 194 == '�' , 195 == '�' , 196 == '�'
- /* 197 - 200 */ , 229 /* '�' */ , 230 /* '�' */ , 231 /* '�' */ , 232 /* '�' */ // 197 == '�' , 198 == '�' , 199 == '�' , 200 == '�'
- /* 201 - 204 */ , 233 /* '�' */ , 234 /* '�' */ , 235 /* '�' */ , 236 /* '�' */ // 201 == '�' , 202 == '�' , 203 == '�' , 204 == '�'
- /* 205 - 208 */ , 237 /* '�' */ , 238 /* '�' */ , 239 /* '�' */ , 240 /* '�' */ // 205 == '�' , 206 == '�' , 207 == '�' , 208 == '�'
- /* 209 - 212 */ , 241 /* '�' */ , 242 /* '�' */ , 243 /* '�' */ , 244 /* '�' */ // 209 == '�' , 210 == '�' , 211 == '�' , 212 == '�'
- /* 213 - 216 */ , 245 /* '�' */ , 246 /* '�' */ , 215 , 248 /* '�' */ // 213 == '�' , 214 == '�' , 215 == '�' , 216 == '�'
- /* 217 - 220 */ , 249 /* '�' */ , 250 /* '�' */ , 251 /* '�' */ , 252 /* '�' */ // 217 == '�' , 218 == '�' , 219 == '�' , 220 == '�'
- /* 221 - 224 */ , 253 /* '�' */ , 254 /* '�' */ , 223 /* '�' */ , 224 /* '�' */ // 221 == '�' , 222 == '�' , 223 == '�' , 224 == '�'
- /* 225 - 228 */ , 225 /* '�' */ , 226 /* '�' */ , 227 /* '�' */ , 228 /* '�' */ // 225 == '�' , 226 == '�' , 227 == '�' , 228 == '�'
- /* 229 - 232 */ , 229 /* '�' */ , 230 /* '�' */ , 231 /* '�' */ , 232 /* '�' */ // 229 == '�' , 230 == '�' , 231 == '�' , 232 == '�'
- /* 233 - 236 */ , 233 /* '�' */ , 234 /* '�' */ , 235 /* '�' */ , 236 /* '�' */ // 233 == '�' , 234 == '�' , 235 == '�' , 236 == '�'
- /* 237 - 240 */ , 237 /* '�' */ , 238 /* '�' */ , 239 /* '�' */ , 240 /* '�' */ // 237 == '�' , 238 == '�' , 239 == '�' , 240 == '�'
- /* 241 - 244 */ , 241 /* '�' */ , 242 /* '�' */ , 243 /* '�' */ , 244 /* '�' */ // 241 == '�' , 242 == '�' , 243 == '�' , 244 == '�'
- /* 245 - 248 */ , 245 /* '�' */ , 246 /* '�' */ , 247 , 248 /* '�' */ // 245 == '�' , 246 == '�' , 247 == '�' , 248 == '�'
- /* 249 - 252 */ , 249 /* '�' */ , 250 /* '�' */ , 251 /* '�' */ , 252 /* '�' */ // 249 == '�' , 250 == '�' , 251 == '�' , 252 == '�'
- /* 253 - 255 */ , 253 /* '�' */ , 254 /* '�' */ , 255 /* '�' */ // 253 == '�' , 254 == '�' , 255 == '�'
-};
+ // ISO 8859-1
+ constexpr unsigned char ASCII_ISO8859_1_Table_lower[] =
+ {
+ /* 0 - 0 */ 0 // '\0', end of string
+ /* 1 - 4 */ , 1 , 2 , 3 , 4 // 1 == SOH , 2 == STX , 3 == ETX , 4 == EOT
+ /* 5 - 8 */ , 5 , 6 , 7 , 8 // 5 == ENQ , 6 == ACK , 7 == BEL , 8 == '\b'
+ /* 9 - 12 */ , 9 , 10 , 11 , 12 // 9 == '\t' , 10 == '\n' , 11 == '\v' , 12 == '\f'
+ /* 13 - 16 */ , 13 , 14 , 15 , 16 // 13 == '\r' , 14 == SO , 15 == SI , 16 == DLE
+ /* 17 - 20 */ , 17 , 18 , 19 , 20 // 17 == DC1 , 18 == DC2 , 19 == DC3 , 20 == DC4
+ /* 21 - 24 */ , 21 , 22 , 23 , 24 // 21 == NAK , 22 == SYN , 23 == ETB , 24 == CAN
+ /* 25 - 28 */ , 25 , 26 , 27 , 28 // 25 == EM , 26 == SUB , 27 == ESC , 28 == FS
+ /* 29 - 32 */ , 29 , 30 , 31 , 32 // 29 == GS , 30 == RS , 31 == US , 32 == ' '
+ /* 33 - 36 */ , 33 , 34 , 35 , 36 // 33 == '!' , 34 == '\"' , 35 == '#' , 36 == '$'
+ /* 37 - 40 */ , 37 , 38 , 39 , 40 // 37 == '%' , 38 == '&' , 39 == '\'' , 40 == '('
+ /* 41 - 44 */ , 41 , 42 , 43 , 44 // 41 == ')' , 42 == '*' , 43 == '+' , 44 == ','
+ /* 45 - 48 */ , 45 , 46 , 47 , 48 // 45 == '-' , 46 == '.' , 47 == '/' , 48 == '0'
+ /* 49 - 52 */ , 49 , 50 , 51 , 52 // 49 == '1' , 50 == '2' , 51 == '3' , 52 == '4'
+ /* 53 - 56 */ , 53 , 54 , 55 , 56 // 53 == '5' , 54 == '6' , 55 == '7' , 56 == '8'
+ /* 57 - 60 */ , 57 , 58 , 59 , 60 // 57 == '9' , 58 == ':' , 59 == ';' , 60 == '<'
+ /* 61 - 64 */ , 61 , 62 , 63 , 64 // 61 == '=' , 62 == '>' , 63 == '?' , 64 == '@'
+ /* 65 - 68 */ , 97 /* 'a' */ , 98 /* 'b' */ , 99 /* 'c' */ , 100 /* 'd' */ // 65 == 'A' , 66 == 'B' , 67 == 'C' , 68 == 'D'
+ /* 69 - 72 */ , 101 /* 'e' */ , 102 /* 'f' */ , 103 /* 'g' */ , 104 /* 'h' */ // 69 == 'E' , 70 == 'F' , 71 == 'G' , 72 == 'H'
+ /* 73 - 76 */ , 105 /* 'i' */ , 106 /* 'j' */ , 107 /* 'k' */ , 108 /* 'l' */ // 73 == 'I' , 74 == 'J' , 74 == 'K' , 76 == 'L'
+ /* 77 - 80 */ , 109 /* 'm' */ , 110 /* 'n' */ , 111 /* 'o' */ , 112 /* 'p' */ // 77 == 'M' , 78 == 'N' , 79 == 'O' , 80 == 'P'
+ /* 81 - 84 */ , 113 /* 'q' */ , 114 /* 'r' */ , 115 /* 's' */ , 116 /* 't' */ // 81 == 'Q' , 82 == 'R' , 83 == 'S' , 84 == 'T'
+ /* 85 - 88 */ , 117 /* 'u' */ , 118 /* 'v' */ , 119 /* 'w' */ , 120 /* 'x' */ // 85 == 'U' , 86 == 'V' , 87 == 'W' , 88 == 'X'
+ /* 89 - 92 */ , 121 /* 'y' */ , 122 /* 'z' */ , 91 , 92 // 89 == 'Y' , 90 == 'Z' , 91 == '[' , 92 == '\\'
+ /* 93 - 96 */ , 93 , 94 , 95 , 96 // 93 == ']' , 94 == '^' , 95 == '_' , 96 == '`'
+ /* 97 - 100 */ , 97 /* 'a' */ , 98 /* 'b' */ , 99 /* 'c' */ , 100 /* 'd' */ // 97 == 'a' , 98 == 'b' , 99 == 'c' , 100 == 'd'
+ /* 101 - 104 */ , 101 /* 'e' */ , 102 /* 'f' */ , 103 /* 'g' */ , 104 /* 'h' */ // 101 == 'e' , 102 == 'f' , 103 == 'g' , 104 == 'h'
+ /* 105 - 108 */ , 105 /* 'i' */ , 106 /* 'j' */ , 107 /* 'k' */ , 108 /* 'l' */ // 105 == 'i' , 106 == 'j' , 107 == 'k' , 108 == 'l'
+ /* 109 - 112 */ , 109 /* 'm' */ , 110 /* 'n' */ , 111 /* 'o' */ , 112 /* 'p' */ // 109 == 'm' , 110 == 'n' , 111 == 'o' , 112 == 'p'
+ /* 113 - 116 */ , 113 /* 'q' */ , 114 /* 'r' */ , 115 /* 's' */ , 116 /* 't' */ // 113 == 'q' , 114 == 'r' , 115 == 's' , 116 == 't'
+ /* 117 - 120 */ , 117 /* 'u' */ , 118 /* 'v' */ , 119 /* 'w' */ , 120 /* 'x' */ // 117 == 'u' , 118 == 'v' , 119 == 'w' , 120 == 'x'
+ /* 121 - 124 */ , 121 /* 'y' */ , 122 /* 'z' */ , 123 , 124 // 121 == 'y' , 122 == 'z' , 123 == '{' , 124 == '|'
+ /* 125 - 128 */ , 125 , 126 , 127 , 128 // 125 == '}' , 126 == '~' , 127 == DEL , 128 == '�'
+ /* 129 - 132 */ , 129 , 130 , 131 , 132 // 129 , 130 == '�' , 131 == '�' , 132 == '�'
+ /* 133 - 136 */ , 133 , 134 , 135 , 136 // 133 == '�' , 134 == '�' , 135 == '�' , 136 == '�'
+ /* 137 - 140 */ , 137 , 154 /* '�' */ , 139 , 156 /* '�' */ // 137 == '�' , 138 == '�' , 139 == '�' , 140 == '�'
+ /* 141 - 144 */ , 141 , 158 /* '�' */ , 143 , 144 // 141 , 142 == '�' , 143 , 144
+ /* 145 - 148 */ , 145 , 146 , 147 , 148 // 145 == '�' , 146 == '�' , 147 == '�' , 148 == '�'
+ /* 149 - 152 */ , 149 , 150 , 151 , 152 // 149 == '�' , 150 == '�' , 151 == '�' , 152 == '�"
+ /* 153 - 156 */ , 153 , 154 /* '�' */ , 155 , 156 /* '�' */ // 153 == '�' , 154 == '�' , 155 == '�' , 156 == '�'
+ /* 157 - 160 */ , 157 , 158 /* '�' */ , 255 /* '�' */ , 160 // 157 , 158 == '�' , 159 == '�' , 160 == '�'
+ /* 161 - 164 */ , 161 , 162 , 163 , 164 // 161 == '�' , 162 == '�' , 163 == '�' , 164 == '�'
+ /* 165 - 168 */ , 165 , 166 , 167 , 168 // 165 == '�' , 166 == '�' , 167 == '�' , 168 == '�'
+ /* 169 - 172 */ , 169 , 170 , 171 , 172 // 169 == '�' , 170 == '�' , 171 == '�' , 172 == '�'
+ /* 173 - 176 */ , 173 , 174 , 175 , 176 // 173 , 174 == '�' , 175 == '�' , 176 == '�'
+ /* 177 - 180 */ , 177 , 178 , 179 , 180 // 177 == '�' , 178 == '�' , 179 == '�' , 180 == '�'
+ /* 181 - 184 */ , 181 , 182 , 183 , 184 // 181 == '�' , 182 == '�' , 183 == '�' , 184 == '�'
+ /* 185 - 188 */ , 185 , 186 , 187 , 188 // 185 == '�' , 186 == '�' , 187 == '�' , 188 == '�'
+ /* 189 - 192 */ , 189 , 190 , 191 , 224 /* '�' */ // 189 == '�' , 190 == '�' , 191 == '�' , 192 == '�'
+ /* 193 - 196 */ , 225 /* '�' */ , 226 /* '�' */ , 227 /* '�' */ , 228 /* '�' */ // 193 == '�' , 194 == '�' , 195 == '�' , 196 == '�'
+ /* 197 - 200 */ , 229 /* '�' */ , 230 /* '�' */ , 231 /* '�' */ , 232 /* '�' */ // 197 == '�' , 198 == '�' , 199 == '�' , 200 == '�'
+ /* 201 - 204 */ , 233 /* '�' */ , 234 /* '�' */ , 235 /* '�' */ , 236 /* '�' */ // 201 == '�' , 202 == '�' , 203 == '�' , 204 == '�'
+ /* 205 - 208 */ , 237 /* '�' */ , 238 /* '�' */ , 239 /* '�' */ , 240 /* '�' */ // 205 == '�' , 206 == '�' , 207 == '�' , 208 == '�'
+ /* 209 - 212 */ , 241 /* '�' */ , 242 /* '�' */ , 243 /* '�' */ , 244 /* '�' */ // 209 == '�' , 210 == '�' , 211 == '�' , 212 == '�'
+ /* 213 - 216 */ , 245 /* '�' */ , 246 /* '�' */ , 215 , 248 /* '�' */ // 213 == '�' , 214 == '�' , 215 == '�' , 216 == '�'
+ /* 217 - 220 */ , 249 /* '�' */ , 250 /* '�' */ , 251 /* '�' */ , 252 /* '�' */ // 217 == '�' , 218 == '�' , 219 == '�' , 220 == '�'
+ /* 221 - 224 */ , 253 /* '�' */ , 254 /* '�' */ , 223 /* '�' */ , 224 /* '�' */ // 221 == '�' , 222 == '�' , 223 == '�' , 224 == '�'
+ /* 225 - 228 */ , 225 /* '�' */ , 226 /* '�' */ , 227 /* '�' */ , 228 /* '�' */ // 225 == '�' , 226 == '�' , 227 == '�' , 228 == '�'
+ /* 229 - 232 */ , 229 /* '�' */ , 230 /* '�' */ , 231 /* '�' */ , 232 /* '�' */ // 229 == '�' , 230 == '�' , 231 == '�' , 232 == '�'
+ /* 233 - 236 */ , 233 /* '�' */ , 234 /* '�' */ , 235 /* '�' */ , 236 /* '�' */ // 233 == '�' , 234 == '�' , 235 == '�' , 236 == '�'
+ /* 237 - 240 */ , 237 /* '�' */ , 238 /* '�' */ , 239 /* '�' */ , 240 /* '�' */ // 237 == '�' , 238 == '�' , 239 == '�' , 240 == '�'
+ /* 241 - 244 */ , 241 /* '�' */ , 242 /* '�' */ , 243 /* '�' */ , 244 /* '�' */ // 241 == '�' , 242 == '�' , 243 == '�' , 244 == '�'
+ /* 245 - 248 */ , 245 /* '�' */ , 246 /* '�' */ , 247 , 248 /* '�' */ // 245 == '�' , 246 == '�' , 247 == '�' , 248 == '�'
+ /* 249 - 252 */ , 249 /* '�' */ , 250 /* '�' */ , 251 /* '�' */ , 252 /* '�' */ // 249 == '�' , 250 == '�' , 251 == '�' , 252 == '�'
+ /* 253 - 255 */ , 253 /* '�' */ , 254 /* '�' */ , 255 /* '�' */ // 253 == '�' , 254 == '�' , 255 == '�'
+ };
-// ISO 8859-1
-static constexpr unsigned char ASCII_ISO8859_1_Table_upper[] =
-{
- /* 0 - 0 */ 0 // '\0', end of string
- /* 1 - 4 */ , 1 , 2 , 3 , 4 // 1 == SOH , 2 == STX , 3 == ETX , 4 == EOT
- /* 5 - 8 */ , 5 , 6 , 7 , 8 // 5 == ENQ , 6 == ACK , 7 == BEL , 8 == '\b'
- /* 9 - 12 */ , 9 , 10 , 11 , 12 // 9 == '\t' , 10 == '\n' , 11 == '\v' , 12 == '\f'
- /* 13 - 16 */ , 13 , 14 , 15 , 16 // 13 == '\r' , 14 == SO , 15 == SI , 16 == DLE
- /* 17 - 20 */ , 17 , 18 , 19 , 20 // 17 == DC1 , 18 == DC2 , 19 == DC3 , 20 == DC4
- /* 21 - 24 */ , 21 , 22 , 23 , 24 // 21 == NAK , 22 == SYN , 23 == ETB , 24 == CAN
- /* 25 - 28 */ , 25 , 26 , 27 , 28 // 25 == EM , 26 == SUB , 27 == ESC , 28 == FS
- /* 29 - 32 */ , 29 , 30 , 31 , 32 // 29 == GS , 30 == RS , 31 == US , 32 == ' '
- /* 33 - 36 */ , 33 , 34 , 35 , 36 // 33 == '!' , 34 == '\"' , 35 == '#' , 36 == '$'
- /* 37 - 40 */ , 37 , 38 , 39 , 40 // 37 == '%' , 38 == '&' , 39 == '\'' , 40 == '('
- /* 41 - 44 */ , 41 , 42 , 43 , 44 // 41 == ')' , 42 == '*' , 43 == '+' , 44 == ','
- /* 45 - 48 */ , 45 , 46 , 47 , 48 // 45 == '-' , 46 == '.' , 47 == '/' , 48 == '0'
- /* 49 - 52 */ , 49 , 50 , 51 , 52 // 49 == '1' , 50 == '2' , 51 == '3' , 52 == '4'
- /* 53 - 56 */ , 53 , 54 , 55 , 56 // 53 == '5' , 54 == '6' , 55 == '7' , 56 == '8'
- /* 57 - 60 */ , 57 , 58 , 59 , 60 // 57 == '9' , 58 == ':' , 59 == ';' , 60 == '<'
- /* 61 - 64 */ , 61 , 62 , 63 , 64 // 61 == '=' , 62 == '>' , 63 == '?' , 64 == '@'
- /* 65 - 68 */ , 65 /* 'A' */ , 66 /* 'B' */ , 67 /* 'C' */ , 68 /* 'D' */ // 65 == 'A' , 66 == 'B' , 67 == 'C' , 68 == 'D'
- /* 69 - 72 */ , 69 /* 'E' */ , 70 /* 'F' */ , 71 /* 'G' */ , 72 /* 'H' */ // 69 == 'E' , 70 == 'F' , 71 == 'G' , 72 == 'H'
- /* 73 - 76 */ , 73 /* 'I' */ , 74 /* 'J' */ , 75 /* 'K' */ , 76 /* 'L' */ // 73 == 'I' , 74 == 'J' , 74 == 'K' , 76 == 'L'
- /* 77 - 80 */ , 77 /* 'M' */ , 78 /* 'N' */ , 79 /* 'O' */ , 80 /* 'P' */ // 77 == 'M' , 78 == 'N' , 79 == 'O' , 80 == 'P'
- /* 81 - 84 */ , 81 /* 'Q' */ , 82 /* 'R' */ , 83 /* 'S' */ , 84 /* 'T' */ // 81 == 'Q' , 82 == 'R' , 83 == 'S' , 84 == 'T'
- /* 85 - 88 */ , 85 /* 'U' */ , 86 /* 'V' */ , 87 /* 'W' */ , 88 /* 'X' */ // 85 == 'U' , 86 == 'V' , 87 == 'W' , 88 == 'X'
- /* 89 - 92 */ , 89 /* 'Y' */ , 90 /* 'Z' */ , 91 , 92 // 89 == 'Y' , 90 == 'Z' , 91 == '[' , 92 == '\\'
- /* 93 - 96 */ , 93 , 94 , 95 , 96 // 93 == ']' , 94 == '^' , 95 == '_' , 96 == '`'
- /* 97 - 100 */ , 65 /* 'A' */ , 66 /* 'B' */ , 67 /* 'C' */ , 68 /* 'D' */ // 97 == 'a' , 98 == 'b' , 99 == 'c' , 100 == 'd'
- /* 101 - 104 */ , 69 /* 'E' */ , 70 /* 'F' */ , 71 /* 'G' */ , 72 /* 'H' */ // 101 == 'e' , 102 == 'f' , 103 == 'g' , 104 == 'h'
- /* 105 - 108 */ , 73 /* 'I' */ , 74 /* 'J' */ , 75 /* 'K' */ , 76 /* 'L' */ // 105 == 'i' , 106 == 'j' , 107 == 'k' , 108 == 'l'
- /* 109 - 112 */ , 77 /* 'M' */ , 78 /* 'N' */ , 79 /* 'O' */ , 80 /* 'P' */ // 109 == 'm' , 110 == 'n' , 111 == 'o' , 112 == 'p'
- /* 113 - 116 */ , 81 /* 'Q' */ , 82 /* 'R' */ , 83 /* 'S' */ , 84 /* 'T' */ // 113 == 'q' , 114 == 'r' , 115 == 's' , 116 == 't'
- /* 117 - 120 */ , 85 /* 'U' */ , 86 /* 'V' */ , 87 /* 'W' */ , 88 /* 'X' */ // 117 == 'u' , 118 == 'v' , 119 == 'w' , 120 == 'x'
- /* 121 - 124 */ , 89 /* 'Y' */ , 90 /* 'Z' */ , 123 , 124 // 121 == 'y' , 122 == 'z' , 123 == '{' , 124 == '|'
- /* 125 - 128 */ , 125 , 126 , 127 , 128 // 125 == '}' , 126 == '~' , 127 == DEL , 128 == '�'
- /* 129 - 132 */ , 129 , 130 , 131 , 132 // 129 , 130 == '�' , 131 == '�' , 132 == '�'
- /* 133 - 136 */ , 133 , 134 , 135 , 136 // 133 == '�' , 134 == '�' , 135 == '�' , 136 == '�'
- /* 137 - 140 */ , 137 , 138 /* '�' */ , 139 , 140 /* '�' */ // 137 == '�' , 138 == '�' , 139 == '�' , 140 == '�'
- /* 141 - 144 */ , 141 , 142 /* '�' */ , 143 , 144 // 141 , 142 == '�' , 143 , 144
- /* 145 - 148 */ , 145 , 146 , 147 , 148 // 145 == '�' , 146 == '�' , 147 == '�' , 148 == '�'
- /* 149 - 152 */ , 149 , 150 , 151 , 152 // 149 == '�' , 150 == '�' , 151 == '�' , 152 == '�"
- /* 153 - 156 */ , 153 , 138 /* '�' */ , 155 , 140 /* '�' */ // 153 == '�' , 154 == '�' , 155 == '�' , 156 == '�'
- /* 157 - 160 */ , 157 , 142 /* '�' */ , 159 /* '�' */ , 160 // 157 , 158 == '�' , 159 == '�' , 160 == '�'
- /* 161 - 164 */ , 161 , 162 , 163 , 164 // 161 == '�' , 162 == '�' , 163 == '�' , 164 == '�'
- /* 165 - 168 */ , 165 , 166 , 167 , 168 // 165 == '�' , 166 == '�' , 167 == '�' , 168 == '�'
- /* 169 - 172 */ , 169 , 170 , 171 , 172 // 169 == '�' , 170 == '�' , 171 == '�' , 172 == '�'
- /* 173 - 176 */ , 173 , 174 , 175 , 176 // 173 , 174 == '�' , 175 == '�' , 176 == '�'
- /* 177 - 180 */ , 177 , 178 , 179 , 180 // 177 == '�' , 178 == '�' , 179 == '�' , 180 == '�'
- /* 181 - 184 */ , 181 , 182 , 183 , 184 // 181 == '�' , 182 == '�' , 183 == '�' , 184 == '�'
- /* 185 - 188 */ , 185 , 186 , 187 , 188 // 185 == '�' , 186 == '�' , 187 == '�' , 188 == '�'
- /* 189 - 192 */ , 189 , 190 , 191 , 192 /* '�' */ // 189 == '�' , 190 == '�' , 191 == '�' , 192 == '�'
- /* 193 - 196 */ , 193 /* '�' */ , 194 /* '�' */ , 195 /* '�' */ , 196 /* '�' */ // 193 == '�' , 194 == '�' , 195 == '�' , 196 == '�'
- /* 197 - 200 */ , 197 /* '�' */ , 198 /* '�' */ , 199 /* '�' */ , 200 /* '�' */ // 197 == '�' , 198 == '�' , 199 == '�' , 200 == '�'
- /* 201 - 204 */ , 201 /* '�' */ , 202 /* '�' */ , 203 /* '�' */ , 204 /* '�' */ // 201 == '�' , 202 == '�' , 203 == '�' , 204 == '�'
- /* 205 - 208 */ , 205 /* '�' */ , 206 /* '�' */ , 207 /* '�' */ , 208 /* '�' */ // 205 == '�' , 206 == '�' , 207 == '�' , 208 == '�'
- /* 209 - 212 */ , 209 /* '�' */ , 210 /* '�' */ , 211 /* '�' */ , 212 /* '�' */ // 209 == '�' , 210 == '�' , 211 == '�' , 212 == '�'
- /* 213 - 216 */ , 213 /* '�' */ , 214 /* '�' */ , 215 , 216 /* '�' */ // 213 == '�' , 214 == '�' , 215 == '�' , 216 == '�'
- /* 217 - 220 */ , 217 /* '�' */ , 218 /* '�' */ , 219 /* '�' */ , 220 /* '�' */ // 217 == '�' , 218 == '�' , 219 == '�' , 220 == '�'
- /* 221 - 224 */ , 221 /* '�' */ , 222 /* '�' */ , 223 /* '�' */ , 192 /* '�' */ // 221 == '�' , 222 == '�' , 223 == '�' , 224 == '�'
- /* 225 - 228 */ , 193 /* '�' */ , 194 /* '�' */ , 195 /* '�' */ , 196 /* '�' */ // 225 == '�' , 226 == '�' , 227 == '�' , 228 == '�'
- /* 229 - 232 */ , 197 /* '�' */ , 198 /* '�' */ , 199 /* '�' */ , 200 /* '�' */ // 229 == '�' , 230 == '�' , 231 == '�' , 232 == '�'
- /* 233 - 236 */ , 201 /* '�' */ , 202 /* '�' */ , 203 /* '�' */ , 204 /* '�' */ // 233 == '�' , 234 == '�' , 235 == '�' , 236 == '�'
- /* 237 - 240 */ , 205 /* '�' */ , 206 /* '�' */ , 207 /* '�' */ , 208 /* '�' */ // 237 == '�' , 238 == '�' , 239 == '�' , 240 == '�'
- /* 241 - 244 */ , 209 /* '�' */ , 210 /* '�' */ , 211 /* '�' */ , 212 /* '�' */ // 241 == '�' , 242 == '�' , 243 == '�' , 244 == '�'
- /* 245 - 248 */ , 213 /* '�' */ , 214 /* '�' */ , 247 , 216 /* '�' */ // 245 == '�' , 246 == '�' , 247 == '�' , 248 == '�'
- /* 249 - 252 */ , 217 /* '�' */ , 218 /* '�' */ , 219 /* '�' */ , 220 /* '�' */ // 249 == '�' , 250 == '�' , 251 == '�' , 252 == '�'
- /* 253 - 255 */ , 221 /* '�' */ , 222 /* '�' */ , 159 /* '�' */ // 253 == '�' , 254 == '�' , 255 == '�'
-};
+ // ISO 8859-1
+ constexpr unsigned char ASCII_ISO8859_1_Table_upper[] =
+ {
+ /* 0 - 0 */ 0 // '\0', end of string
+ /* 1 - 4 */ , 1 , 2 , 3 , 4 // 1 == SOH , 2 == STX , 3 == ETX , 4 == EOT
+ /* 5 - 8 */ , 5 , 6 , 7 , 8 // 5 == ENQ , 6 == ACK , 7 == BEL , 8 == '\b'
+ /* 9 - 12 */ , 9 , 10 , 11 , 12 // 9 == '\t' , 10 == '\n' , 11 == '\v' , 12 == '\f'
+ /* 13 - 16 */ , 13 , 14 , 15 , 16 // 13 == '\r' , 14 == SO , 15 == SI , 16 == DLE
+ /* 17 - 20 */ , 17 , 18 , 19 , 20 // 17 == DC1 , 18 == DC2 , 19 == DC3 , 20 == DC4
+ /* 21 - 24 */ , 21 , 22 , 23 , 24 // 21 == NAK , 22 == SYN , 23 == ETB , 24 == CAN
+ /* 25 - 28 */ , 25 , 26 , 27 , 28 // 25 == EM , 26 == SUB , 27 == ESC , 28 == FS
+ /* 29 - 32 */ , 29 , 30 , 31 , 32 // 29 == GS , 30 == RS , 31 == US , 32 == ' '
+ /* 33 - 36 */ , 33 , 34 , 35 , 36 // 33 == '!' , 34 == '\"' , 35 == '#' , 36 == '$'
+ /* 37 - 40 */ , 37 , 38 , 39 , 40 // 37 == '%' , 38 == '&' , 39 == '\'' , 40 == '('
+ /* 41 - 44 */ , 41 , 42 , 43 , 44 // 41 == ')' , 42 == '*' , 43 == '+' , 44 == ','
+ /* 45 - 48 */ , 45 , 46 , 47 , 48 // 45 == '-' , 46 == '.' , 47 == '/' , 48 == '0'
+ /* 49 - 52 */ , 49 , 50 , 51 , 52 // 49 == '1' , 50 == '2' , 51 == '3' , 52 == '4'
+ /* 53 - 56 */ , 53 , 54 , 55 , 56 // 53 == '5' , 54 == '6' , 55 == '7' , 56 == '8'
+ /* 57 - 60 */ , 57 , 58 , 59 , 60 // 57 == '9' , 58 == ':' , 59 == ';' , 60 == '<'
+ /* 61 - 64 */ , 61 , 62 , 63 , 64 // 61 == '=' , 62 == '>' , 63 == '?' , 64 == '@'
+ /* 65 - 68 */ , 65 /* 'A' */ , 66 /* 'B' */ , 67 /* 'C' */ , 68 /* 'D' */ // 65 == 'A' , 66 == 'B' , 67 == 'C' , 68 == 'D'
+ /* 69 - 72 */ , 69 /* 'E' */ , 70 /* 'F' */ , 71 /* 'G' */ , 72 /* 'H' */ // 69 == 'E' , 70 == 'F' , 71 == 'G' , 72 == 'H'
+ /* 73 - 76 */ , 73 /* 'I' */ , 74 /* 'J' */ , 75 /* 'K' */ , 76 /* 'L' */ // 73 == 'I' , 74 == 'J' , 74 == 'K' , 76 == 'L'
+ /* 77 - 80 */ , 77 /* 'M' */ , 78 /* 'N' */ , 79 /* 'O' */ , 80 /* 'P' */ // 77 == 'M' , 78 == 'N' , 79 == 'O' , 80 == 'P'
+ /* 81 - 84 */ , 81 /* 'Q' */ , 82 /* 'R' */ , 83 /* 'S' */ , 84 /* 'T' */ // 81 == 'Q' , 82 == 'R' , 83 == 'S' , 84 == 'T'
+ /* 85 - 88 */ , 85 /* 'U' */ , 86 /* 'V' */ , 87 /* 'W' */ , 88 /* 'X' */ // 85 == 'U' , 86 == 'V' , 87 == 'W' , 88 == 'X'
+ /* 89 - 92 */ , 89 /* 'Y' */ , 90 /* 'Z' */ , 91 , 92 // 89 == 'Y' , 90 == 'Z' , 91 == '[' , 92 == '\\'
+ /* 93 - 96 */ , 93 , 94 , 95 , 96 // 93 == ']' , 94 == '^' , 95 == '_' , 96 == '`'
+ /* 97 - 100 */ , 65 /* 'A' */ , 66 /* 'B' */ , 67 /* 'C' */ , 68 /* 'D' */ // 97 == 'a' , 98 == 'b' , 99 == 'c' , 100 == 'd'
+ /* 101 - 104 */ , 69 /* 'E' */ , 70 /* 'F' */ , 71 /* 'G' */ , 72 /* 'H' */ // 101 == 'e' , 102 == 'f' , 103 == 'g' , 104 == 'h'
+ /* 105 - 108 */ , 73 /* 'I' */ , 74 /* 'J' */ , 75 /* 'K' */ , 76 /* 'L' */ // 105 == 'i' , 106 == 'j' , 107 == 'k' , 108 == 'l'
+ /* 109 - 112 */ , 77 /* 'M' */ , 78 /* 'N' */ , 79 /* 'O' */ , 80 /* 'P' */ // 109 == 'm' , 110 == 'n' , 111 == 'o' , 112 == 'p'
+ /* 113 - 116 */ , 81 /* 'Q' */ , 82 /* 'R' */ , 83 /* 'S' */ , 84 /* 'T' */ // 113 == 'q' , 114 == 'r' , 115 == 's' , 116 == 't'
+ /* 117 - 120 */ , 85 /* 'U' */ , 86 /* 'V' */ , 87 /* 'W' */ , 88 /* 'X' */ // 117 == 'u' , 118 == 'v' , 119 == 'w' , 120 == 'x'
+ /* 121 - 124 */ , 89 /* 'Y' */ , 90 /* 'Z' */ , 123 , 124 // 121 == 'y' , 122 == 'z' , 123 == '{' , 124 == '|'
+ /* 125 - 128 */ , 125 , 126 , 127 , 128 // 125 == '}' , 126 == '~' , 127 == DEL , 128 == '�'
+ /* 129 - 132 */ , 129 , 130 , 131 , 132 // 129 , 130 == '�' , 131 == '�' , 132 == '�'
+ /* 133 - 136 */ , 133 , 134 , 135 , 136 // 133 == '�' , 134 == '�' , 135 == '�' , 136 == '�'
+ /* 137 - 140 */ , 137 , 138 /* '�' */ , 139 , 140 /* '�' */ // 137 == '�' , 138 == '�' , 139 == '�' , 140 == '�'
+ /* 141 - 144 */ , 141 , 142 /* '�' */ , 143 , 144 // 141 , 142 == '�' , 143 , 144
+ /* 145 - 148 */ , 145 , 146 , 147 , 148 // 145 == '�' , 146 == '�' , 147 == '�' , 148 == '�'
+ /* 149 - 152 */ , 149 , 150 , 151 , 152 // 149 == '�' , 150 == '�' , 151 == '�' , 152 == '�"
+ /* 153 - 156 */ , 153 , 138 /* '�' */ , 155 , 140 /* '�' */ // 153 == '�' , 154 == '�' , 155 == '�' , 156 == '�'
+ /* 157 - 160 */ , 157 , 142 /* '�' */ , 159 /* '�' */ , 160 // 157 , 158 == '�' , 159 == '�' , 160 == '�'
+ /* 161 - 164 */ , 161 , 162 , 163 , 164 // 161 == '�' , 162 == '�' , 163 == '�' , 164 == '�'
+ /* 165 - 168 */ , 165 , 166 , 167 , 168 // 165 == '�' , 166 == '�' , 167 == '�' , 168 == '�'
+ /* 169 - 172 */ , 169 , 170 , 171 , 172 // 169 == '�' , 170 == '�' , 171 == '�' , 172 == '�'
+ /* 173 - 176 */ , 173 , 174 , 175 , 176 // 173 , 174 == '�' , 175 == '�' , 176 == '�'
+ /* 177 - 180 */ , 177 , 178 , 179 , 180 // 177 == '�' , 178 == '�' , 179 == '�' , 180 == '�'
+ /* 181 - 184 */ , 181 , 182 , 183 , 184 // 181 == '�' , 182 == '�' , 183 == '�' , 184 == '�'
+ /* 185 - 188 */ , 185 , 186 , 187 , 188 // 185 == '�' , 186 == '�' , 187 == '�' , 188 == '�'
+ /* 189 - 192 */ , 189 , 190 , 191 , 192 /* '�' */ // 189 == '�' , 190 == '�' , 191 == '�' , 192 == '�'
+ /* 193 - 196 */ , 193 /* '�' */ , 194 /* '�' */ , 195 /* '�' */ , 196 /* '�' */ // 193 == '�' , 194 == '�' , 195 == '�' , 196 == '�'
+ /* 197 - 200 */ , 197 /* '�' */ , 198 /* '�' */ , 199 /* '�' */ , 200 /* '�' */ // 197 == '�' , 198 == '�' , 199 == '�' , 200 == '�'
+ /* 201 - 204 */ , 201 /* '�' */ , 202 /* '�' */ , 203 /* '�' */ , 204 /* '�' */ // 201 == '�' , 202 == '�' , 203 == '�' , 204 == '�'
+ /* 205 - 208 */ , 205 /* '�' */ , 206 /* '�' */ , 207 /* '�' */ , 208 /* '�' */ // 205 == '�' , 206 == '�' , 207 == '�' , 208 == '�'
+ /* 209 - 212 */ , 209 /* '�' */ , 210 /* '�' */ , 211 /* '�' */ , 212 /* '�' */ // 209 == '�' , 210 == '�' , 211 == '�' , 212 == '�'
+ /* 213 - 216 */ , 213 /* '�' */ , 214 /* '�' */ , 215 , 216 /* '�' */ // 213 == '�' , 214 == '�' , 215 == '�' , 216 == '�'
+ /* 217 - 220 */ , 217 /* '�' */ , 218 /* '�' */ , 219 /* '�' */ , 220 /* '�' */ // 217 == '�' , 218 == '�' , 219 == '�' , 220 == '�'
+ /* 221 - 224 */ , 221 /* '�' */ , 222 /* '�' */ , 223 /* '�' */ , 192 /* '�' */ // 221 == '�' , 222 == '�' , 223 == '�' , 224 == '�'
+ /* 225 - 228 */ , 193 /* '�' */ , 194 /* '�' */ , 195 /* '�' */ , 196 /* '�' */ // 225 == '�' , 226 == '�' , 227 == '�' , 228 == '�'
+ /* 229 - 232 */ , 197 /* '�' */ , 198 /* '�' */ , 199 /* '�' */ , 200 /* '�' */ // 229 == '�' , 230 == '�' , 231 == '�' , 232 == '�'
+ /* 233 - 236 */ , 201 /* '�' */ , 202 /* '�' */ , 203 /* '�' */ , 204 /* '�' */ // 233 == '�' , 234 == '�' , 235 == '�' , 236 == '�'
+ /* 237 - 240 */ , 205 /* '�' */ , 206 /* '�' */ , 207 /* '�' */ , 208 /* '�' */ // 237 == '�' , 238 == '�' , 239 == '�' , 240 == '�'
+ /* 241 - 244 */ , 209 /* '�' */ , 210 /* '�' */ , 211 /* '�' */ , 212 /* '�' */ // 241 == '�' , 242 == '�' , 243 == '�' , 244 == '�'
+ /* 245 - 248 */ , 213 /* '�' */ , 214 /* '�' */ , 247 , 216 /* '�' */ // 245 == '�' , 246 == '�' , 247 == '�' , 248 == '�'
+ /* 249 - 252 */ , 217 /* '�' */ , 218 /* '�' */ , 219 /* '�' */ , 220 /* '�' */ // 249 == '�' , 250 == '�' , 251 == '�' , 252 == '�'
+ /* 253 - 255 */ , 221 /* '�' */ , 222 /* '�' */ , 159 /* '�' */ // 253 == '�' , 254 == '�' , 255 == '�'
+ };
+}
/************************************************************************/
// NEString namespace global method implementation
diff --git a/framework/areg/base/private/SharedBuffer.cpp b/framework/areg/base/private/SharedBuffer.cpp
index fe7042991..7d0951fa1 100644
--- a/framework/areg/base/private/SharedBuffer.cpp
+++ b/framework/areg/base/private/SharedBuffer.cpp
@@ -54,6 +54,17 @@ SharedBuffer::SharedBuffer( const unsigned char* buffer, unsigned int size, unsi
writeData(buffer, size);
}
+SharedBuffer::SharedBuffer(unsigned int reserveSize, const unsigned char* buffer, unsigned int size, unsigned int blockSize)
+ : BufferStreamBase(static_cast(self()), static_cast(self()))
+ , BufferPosition(static_cast(self()))
+
+ , mBlockSize(MACRO_ALIGN_SIZE(blockSize, NEMemory::BLOCK_SIZE))
+{
+ reserveSize = MACRO_MAX(reserveSize, size);
+ reserve(reserveSize, false);
+ writeData(buffer, size);
+}
+
SharedBuffer::SharedBuffer(const char * textString, unsigned int blockSize /*= NEMemory::BLOCK_SIZE*/)
: BufferStreamBase( static_cast(self()), static_cast(self()) )
, BufferPosition ( static_cast(self()) )
diff --git a/framework/areg/base/private/Thread.cpp b/framework/areg/base/private/Thread.cpp
index 1a02b55d6..7b82e8246 100644
--- a/framework/areg/base/private/Thread.cpp
+++ b/framework/areg/base/private/Thread.cpp
@@ -52,9 +52,23 @@ IMPLEMENT_RUNTIME(Thread, RuntimeObject)
/************************************************************************/
// Define internal static mapping objects
/************************************************************************/
-Thread::MapThreadHandleResource Thread::_mapThreadhHandle;
-Thread::MapThreadNameResource Thread::_mapThreadName;
-Thread::MapThreadIDResource Thread::_mapThreadId;
+Thread::MapThreadHandleResource& Thread::_getMapThreadhHandle()
+{
+ static Thread::MapThreadHandleResource _mapThreadhHandle;
+ return _mapThreadhHandle;
+}
+
+Thread::MapThreadNameResource& Thread::_getMapThreadName()
+{
+ static Thread::MapThreadNameResource _mapThreadName;
+ return _mapThreadName;
+}
+
+Thread::MapThreadIDResource& Thread::_getMapThreadId()
+{
+ static Thread::MapThreadIDResource _mapThreadId;
+ return _mapThreadId;
+}
/************************************************************************/
// Default thread procedure
@@ -248,9 +262,8 @@ void Thread::onPostExitThread( void )
const String & Thread::getThreadName( id_type threadId )
{
- static String emptyString;
Thread* threadObj = Thread::findThreadById( threadId);
- return (threadObj != nullptr ? threadObj->getName() : emptyString);
+ return (threadObj != nullptr ? threadObj->getName() : String::getEmptyString());
}
const ThreadAddress & Thread::getThreadAddress( id_type threadId )
@@ -303,9 +316,9 @@ void Thread::_cleanResources( void )
bool Thread::_registerThread( void )
{
- Thread::_mapThreadhHandle.registerResourceObject(mThreadHandle, this);
- Thread::_mapThreadName.registerResourceObject(mThreadAddress.getThreadName(), this);
- Thread::_mapThreadId.registerResourceObject(mThreadId, this);
+ Thread::_getMapThreadhHandle().registerResourceObject(mThreadHandle, this);
+ Thread::_getMapThreadName().registerResourceObject(mThreadAddress.getThreadName(), this);
+ Thread::_getMapThreadId().registerResourceObject(mThreadId, this);
_osSetThreadName(mThreadId, mThreadAddress.getThreadName());
return mThreadConsumer.onThreadRegistered(this);
@@ -317,18 +330,24 @@ void Thread::_unregisterThread( void )
{
mThreadConsumer.onThreadUnregistering();
- Thread::_mapThreadhHandle.unregisterResourceObject(mThreadHandle);
- Thread::_mapThreadName.unregisterResourceObject(mThreadAddress.getThreadName());
- Thread::_mapThreadId.unregisterResourceObject(mThreadId);
+ Thread::_getMapThreadhHandle().unregisterResourceObject(mThreadHandle);
+ Thread::_getMapThreadName().unregisterResourceObject(mThreadAddress.getThreadName());
+ Thread::_getMapThreadId().unregisterResourceObject(mThreadId);
- if (Thread::_mapThreadhHandle.isEmpty())
- Thread::_mapThreadhHandle.removeAllResources();
+ if (Thread::_getMapThreadhHandle().isEmpty())
+ {
+ Thread::_getMapThreadhHandle().removeAllResources();
+ }
- if (Thread::_mapThreadName.isEmpty())
- Thread::_mapThreadName.removeAllResources();
+ if (Thread::_getMapThreadName().isEmpty())
+ {
+ Thread::_getMapThreadName().removeAllResources();
+ }
- if (Thread::_mapThreadId.isEmpty())
- Thread::_mapThreadId.removeAllResources();
+ if (Thread::_getMapThreadId().isEmpty())
+ {
+ Thread::_getMapThreadId().removeAllResources();
+ }
}
else
{
@@ -347,12 +366,12 @@ IEThreadConsumer& Thread::getCurrentThreadConsumer( void )
Thread * Thread::getFirstThread( id_type & OUT threadId )
{
- return _mapThreadId.resourceFirstKey( threadId );
+ return _getMapThreadId().resourceFirstKey( threadId );
}
Thread * Thread::getNextThread( id_type & IN OUT threadId )
{
- return _mapThreadId.resourceNextKey( threadId );
+ return _getMapThreadId().resourceNextKey( threadId );
}
#ifdef _DEBUG
@@ -364,22 +383,23 @@ void Thread::dumpThreads( void )
OUTPUT_DBG(">>> Starting dump Thread objects");
OUTPUT_DBG(">>> ............................");
- Thread::_mapThreadName.lock();
+ Thread::MapThreadNameResource& mapNames{ Thread::_getMapThreadName() };
+ mapNames.lock();
- if (Thread::_mapThreadName.isEmpty() == false)
+ if (mapNames.isEmpty() == false)
{
String threadName("");
Thread* threadObj{ nullptr };
- Thread::_mapThreadName.resourceFirstKey(threadName);
+ mapNames.resourceFirstKey(threadName);
do
{
OUTPUT_WARN("The thread with name [ %s ] is still registered in resource!", static_cast(threadName.getString()));
- threadObj = Thread::_mapThreadName.resourceNextKey(threadName);
+ threadObj = mapNames.resourceNextKey(threadName);
} while (threadObj != nullptr );
}
- Thread::_mapThreadName.unlock();
+ mapNames.unlock();
OUTPUT_DBG("<<< .......................");
OUTPUT_DBG("<<< End dump Thread objects");
diff --git a/framework/areg/base/private/posix/IESynchObjectBaseIX.hpp b/framework/areg/base/private/posix/IESynchObjectBaseIX.hpp
index 2001ec6ab..37db9624a 100644
--- a/framework/areg/base/private/posix/IESynchObjectBaseIX.hpp
+++ b/framework/areg/base/private/posix/IESynchObjectBaseIX.hpp
@@ -52,7 +52,7 @@ class IESynchObjectBaseIX
/**
* \brief The length of synchronization object name, including null-termination symbol.
**/
- static const int _MAX_NAME_LENGTH = 32;
+ static constexpr int _MAX_NAME_LENGTH { 32 };
//////////////////////////////////////////////////////////////////////////
// Protected constructor.
diff --git a/framework/areg/base/private/posix/NESocketPosix.cpp b/framework/areg/base/private/posix/NESocketPosix.cpp
index 4887783f7..10fcfbaa8 100644
--- a/framework/areg/base/private/posix/NESocketPosix.cpp
+++ b/framework/areg/base/private/posix/NESocketPosix.cpp
@@ -32,10 +32,6 @@
#include // IEEE Std 1003.1-2001
#include
-//////////////////////////////////////////////////////////////////////////
-// Local static members
-//////////////////////////////////////////////////////////////////////////
-
//////////////////////////////////////////////////////////////////////////
// NESocket namespace functions implementation
//////////////////////////////////////////////////////////////////////////
diff --git a/framework/areg/base/private/posix/SynchLockAndWaitIX.cpp b/framework/areg/base/private/posix/SynchLockAndWaitIX.cpp
index 42e5b18c4..bc48bf760 100644
--- a/framework/areg/base/private/posix/SynchLockAndWaitIX.cpp
+++ b/framework/areg/base/private/posix/SynchLockAndWaitIX.cpp
@@ -23,18 +23,21 @@
#include "areg/base/Thread.hpp"
#include
-//////////////////////////////////////////////////////////////////////////
-// SynchWaitableMapIX class implementation
-//////////////////////////////////////////////////////////////////////////
-
-SynchLockAndWaitIX::SynchResourceMapIX SynchLockAndWaitIX::_theSynchResourceMapIX;
-
//////////////////////////////////////////////////////////////////////////
// SynchLockAndWaitIX class implementation
//////////////////////////////////////////////////////////////////////////
-SynchLockAndWaitIX::MapWaitIDResource SynchLockAndWaitIX::_mapWaitIdResource;
+SynchLockAndWaitIX::MapWaitIDResource & SynchLockAndWaitIX::_mapWaitResourceIds( void )
+{
+ static SynchLockAndWaitIX::MapWaitIDResource _mapWaitIdResource;
+ return _mapWaitIdResource;
+}
+SynchLockAndWaitIX::SynchResourceMapIX & SynchLockAndWaitIX::_mapSynchResources( void )
+{
+ static SynchLockAndWaitIX::SynchResourceMapIX _theSynchResourceMapIX;
+ return _theSynchResourceMapIX;
+}
int SynchLockAndWaitIX::waitForSingleObject( IEWaitableBaseIX & synchWait, unsigned int msTimeout /* = NECommon::WAIT_INFINITE */ )
{
@@ -55,23 +58,24 @@ int SynchLockAndWaitIX::waitForMultipleObjects( IEWaitableBaseIX ** listWaitable
if ( (lockAndWait._isEmpty() == false) && lockAndWait._lock( ) )
{
- _mapWaitIdResource.registerResourceObject(reinterpret_cast(lockAndWait.mContext), &lockAndWait);
+ SynchLockAndWaitIX::MapWaitIDResource & mapReousrces { SynchLockAndWaitIX::_mapWaitResourceIds() };
+ mapReousrces.registerResourceObject(reinterpret_cast(lockAndWait.mContext), &lockAndWait);
int waitResult = ENOLCK;
bool makeLoop = true;
while ( makeLoop && lockAndWait._noEventFired( ) )
{
waitResult = lockAndWait._waitCondition( );
- _mapWaitIdResource.lock();
+ mapReousrces.lock();
if ( (RETURNED_OK != waitResult) && (lockAndWait.mFiredEntry == NESynchTypesIX::SynchObjectInvalid) )
{
lockAndWait.mFiredEntry = (waitResult == ETIMEDOUT) || (waitResult == EBUSY) ? NESynchTypesIX::SynchObjectTimeout : NESynchTypesIX::SynchWaitInterrupted;
makeLoop = false;
}
- _mapWaitIdResource.unlock();
+ mapReousrces.unlock();
}
- _mapWaitIdResource.unregisterResourceObject(reinterpret_cast(lockAndWait.mContext));
+ mapReousrces.unregisterResourceObject(reinterpret_cast(lockAndWait.mContext));
lockAndWait._unlock( );
}
@@ -86,7 +90,7 @@ int SynchLockAndWaitIX::eventSignaled( IEWaitableBaseIX & synchWaitable )
{
int result = 0;
- SynchResourceMapIX & mapResource = SynchLockAndWaitIX::_theSynchResourceMapIX;
+ SynchResourceMapIX & mapResource { SynchLockAndWaitIX::_mapSynchResources() };
mapResource.lock( );
ListLockAndWait * waitList = mapResource.getResource( &synchWaitable );
@@ -149,7 +153,7 @@ int SynchLockAndWaitIX::eventSignaled( IEWaitableBaseIX & synchWaitable )
void SynchLockAndWaitIX::eventRemove( IEWaitableBaseIX & synchWaitable )
{
- SynchResourceMapIX & mapResource = SynchLockAndWaitIX::_theSynchResourceMapIX;
+ SynchResourceMapIX & mapResource { SynchLockAndWaitIX::_mapSynchResources() };
mapResource.lock( );
ListLockAndWait * waitList = mapResource.getResource( &synchWaitable );
@@ -182,7 +186,7 @@ void SynchLockAndWaitIX::eventRemove( IEWaitableBaseIX & synchWaitable )
void SynchLockAndWaitIX::eventFailed( IEWaitableBaseIX & synchWaitable )
{
- SynchResourceMapIX & mapResource = SynchLockAndWaitIX::_theSynchResourceMapIX;
+ SynchResourceMapIX & mapResource { SynchLockAndWaitIX::_mapSynchResources() };
mapResource.lock( );
ListLockAndWait * waitList = mapResource.getResource( &synchWaitable );
@@ -213,7 +217,7 @@ bool SynchLockAndWaitIX::isWaitableRegistered( IEWaitableBaseIX & synchWaitable
{
bool result = false;
- SynchResourceMapIX & mapResources = SynchLockAndWaitIX::_theSynchResourceMapIX;
+ SynchResourceMapIX & mapResources { SynchLockAndWaitIX::_mapSynchResources() };
mapResources.lock();
result = mapResources.existResource(&synchWaitable);
@@ -227,19 +231,20 @@ bool SynchLockAndWaitIX::notifyAsynchSignal( id_type threadId )
{
bool result = false;
- SynchResourceMapIX & mapResource = SynchLockAndWaitIX::_theSynchResourceMapIX;
+ SynchResourceMapIX & mapResource { SynchLockAndWaitIX::_mapSynchResources() };
mapResource.lock( );
do
{
- SynchLockAndWaitIX::_mapWaitIdResource.lock();
- SynchLockAndWaitIX * lockAndWait = SynchLockAndWaitIX::_mapWaitIdResource.findResourceObject(threadId);
+ SynchLockAndWaitIX::MapWaitIDResource & mapReousrces { SynchLockAndWaitIX::_mapWaitResourceIds() };
+ mapReousrces.lock();
+ SynchLockAndWaitIX * lockAndWait = mapReousrces.findResourceObject(threadId);
if (lockAndWait != nullptr)
{
lockAndWait->mFiredEntry = NESynchTypesIX::SynchAsynchSignal;
result = lockAndWait->_notifyEvent();
}
- SynchLockAndWaitIX::_mapWaitIdResource.unlock();
+ mapReousrces.unlock();
} while (false);
@@ -271,7 +276,7 @@ SynchLockAndWaitIX::SynchLockAndWaitIX( IEWaitableBaseIX ** listWaitables
if ( _initPosixSynchObjects() )
{
- SynchResourceMapIX & mapResources = SynchLockAndWaitIX::_theSynchResourceMapIX;
+ SynchResourceMapIX & mapResources { SynchLockAndWaitIX::_mapSynchResources() };
mapResources.lock();
count = MACRO_MIN(NECommon::MAXIMUM_WAITING_OBJECTS, count);
@@ -358,7 +363,7 @@ SynchLockAndWaitIX::SynchLockAndWaitIX( IEWaitableBaseIX ** listWaitables
SynchLockAndWaitIX::~SynchLockAndWaitIX( void )
{
- SynchLockAndWaitIX::_theSynchResourceMapIX.removeResourceObject(this, true);
+ SynchLockAndWaitIX::_mapSynchResources().removeResourceObject(this, true);
}
inline bool SynchLockAndWaitIX::_noEventFired( void ) const
diff --git a/framework/areg/base/private/posix/SynchLockAndWaitIX.hpp b/framework/areg/base/private/posix/SynchLockAndWaitIX.hpp
index d1141621a..bf61304fb 100644
--- a/framework/areg/base/private/posix/SynchLockAndWaitIX.hpp
+++ b/framework/areg/base/private/posix/SynchLockAndWaitIX.hpp
@@ -63,7 +63,7 @@ class SynchLockAndWaitIX
using MapLockAndWait = TEMap;
//////////////////////////////////////////////////////////////////////////
-// SynchWaitableMapIX class declaration
+// ImplResourceListMap class declaration
//////////////////////////////////////////////////////////////////////////
/**
* \brief The helper class of resource list map that contains helper functions implementation.
@@ -274,6 +274,16 @@ class SynchLockAndWaitIX
// Hidden operations and attributes
//////////////////////////////////////////////////////////////////////////
+ /**
+ * \brief Returns static list of waitables, where keys are id_type and values are waitables.
+ **/
+ static SynchLockAndWaitIX::MapWaitIDResource& _mapWaitResourceIds(void);
+
+ /**
+ * \brief Returns the static instance of synchronization resource map.
+ */
+ static SynchResourceMapIX& _mapSynchResources(void);
+
/**
* \brief Returns true if no event in the list is fired.
**/
@@ -405,15 +415,6 @@ class SynchLockAndWaitIX
**/
WaitingList mWaitingList;
- /**
- * \brief Static list of waitables, where keys are id_type and values are waitables.
- **/
- static MapWaitIDResource _mapWaitIdResource;
- /**
- * \brief The singleton instance of synchronization resource map.
- */
- static SynchResourceMapIX _theSynchResourceMapIX;
-
//////////////////////////////////////////////////////////////////////////
// Forbidden calls.
//////////////////////////////////////////////////////////////////////////
diff --git a/framework/areg/base/private/posix/SynchObjectsPosix.cpp b/framework/areg/base/private/posix/SynchObjectsPosix.cpp
index 757e7301b..445b7adfe 100644
--- a/framework/areg/base/private/posix/SynchObjectsPosix.cpp
+++ b/framework/areg/base/private/posix/SynchObjectsPosix.cpp
@@ -32,11 +32,6 @@
#include
#include
-//////////////////////////////////////////////////////////////////////////
-// Internal static methods
-//////////////////////////////////////////////////////////////////////////
-
-
//////////////////////////////////////////////////////////////////////////
// IESynchObject class implementation
//////////////////////////////////////////////////////////////////////////
@@ -70,7 +65,7 @@ bool Mutex::_osLockMutex( unsigned int timeout )
{
bool result{ false };
WaitableMutexIX * synchMutex{ reinterpret_cast(mSynchObject) };
-
+
if ( NESynchTypesIX::SynchObject0 == SynchLockAndWaitIX::waitForSingleObject(*synchMutex, timeout) )
{
mOwnerThreadId.store(reinterpret_cast(synchMutex->getOwningThreadId()));
diff --git a/framework/areg/base/private/posix/WaitableMutexIX.cpp b/framework/areg/base/private/posix/WaitableMutexIX.cpp
index df8d7eb6a..830d75085 100644
--- a/framework/areg/base/private/posix/WaitableMutexIX.cpp
+++ b/framework/areg/base/private/posix/WaitableMutexIX.cpp
@@ -122,15 +122,19 @@ bool WaitableMutexIX::checkCanSignalMultipleThreads(void) const
return false;
}
-#ifdef DEBUG
+#ifdef DEBUG
+
void WaitableMutexIX::notifyReleasedThreads(int numThreads)
{
ASSERT((numThreads == 1) || (numThreads == 0));
}
-#else
+
+#else // DEBUG
+
void WaitableMutexIX::notifyReleasedThreads(int /*numThreads*/)
{
}
-#endif
+
+#endif // DEBUG
#endif // defined(_POSIX) || defined(POSIX)
diff --git a/framework/areg/base/private/win32/ThreadWin32.cpp b/framework/areg/base/private/win32/ThreadWin32.cpp
index a9e5e70e3..f56923e64 100644
--- a/framework/areg/base/private/win32/ThreadWin32.cpp
+++ b/framework/areg/base/private/win32/ThreadWin32.cpp
@@ -45,7 +45,7 @@ void Thread::_osSetThreadName( id_type threadId, const char* threadName)
/**
* \brief MS Exception value, used to set thread name.
**/
- static constexpr unsigned int SET_NAME_MS_VC_EXCEPTION = 0x406D1388u;
+ static constexpr unsigned int SET_NAME_MS_VC_EXCEPTION{ 0x406D1388u };
#pragma pack(push, 8)
typedef struct tagTHREADNAME_INFO
diff --git a/framework/areg/component/private/posix/TimerManagerPosix.cpp b/framework/areg/component/private/posix/TimerManagerPosix.cpp
index 4b2958b81..d5c5468fa 100644
--- a/framework/areg/component/private/posix/TimerManagerPosix.cpp
+++ b/framework/areg/component/private/posix/TimerManagerPosix.cpp
@@ -23,22 +23,16 @@
#include "areg/base/private/posix/SynchLockAndWaitIX.hpp"
#include "areg/component/Timer.hpp"
#include "areg/base/NEUtilities.hpp"
-#include "areg/trace/GETrace.h"
#include
#include
#include
-DEF_TRACE_SCOPE(areg_component_private_posix_TimerManager__osSystemTimerStart );
-DEF_TRACE_SCOPE(areg_component_private_posix_TimerManager__posixTimerExpiredRoutine );
-
//////////////////////////////////////////////////////////////////////////
// POSIX specific methods
//////////////////////////////////////////////////////////////////////////
void TimerManager::_posixTimerExpiredRoutine( union sigval argSig )
{
- TRACE_SCOPE( areg_component_private_posix_TimerManager__posixTimerExpiredRoutine );
-
TimerManager & timerManager = TimerManager::getInstance( );
TimerPosix * posixTimer = reinterpret_cast(argSig.sival_ptr);
ASSERT( posixTimer != nullptr );
@@ -46,20 +40,11 @@ void TimerManager::_posixTimerExpiredRoutine( union sigval argSig )
if ( (timer != nullptr) && (posixTimer->isValid( )) )
{
- TRACE_DBG( "Timer [ %s ] expired at [ %u ] sec and [ %u ] ns"
- , timer->getName( ).getString( )
- , posixTimer->getDueTime( ).tv_sec
- , posixTimer->getDueTime( ).tv_nsec );
-
unsigned int highValue = static_cast(posixTimer->mDueTime.tv_sec);
unsigned int lowValue = static_cast(posixTimer->mDueTime.tv_nsec);
posixTimer->timerExpired( );
timerManager._processExpiredTimer( timer, reinterpret_cast(posixTimer), highValue, lowValue );
}
- else
- {
- TRACE_WARN( "Ignore handling timer [ %p ], it is [ %s ]", posixTimer, timer == nullptr ? "NOT REGISTERED ANYMORE" : "ALREADY INVALID" );
- }
}
void TimerManager::_osSsystemTimerStop( TIMERHANDLE timerHandle )
@@ -73,8 +58,6 @@ void TimerManager::_osSsystemTimerStop( TIMERHANDLE timerHandle )
bool TimerManager::_osSystemTimerStart( Timer & timer )
{
- TRACE_SCOPE(areg_component_private_posix_TimerManager__osSystemTimerStart );
-
bool result{ false };
TimerPosix * posixTimer = reinterpret_cast(timer.getHandle());
ASSERT(posixTimer != nullptr);
@@ -86,17 +69,6 @@ bool TimerManager::_osSystemTimerStart( Timer & timer )
if (posixTimer->startTimer(timer, 0, &TimerManager::_posixTimerExpiredRoutine))
{
result = true;
- TRACE_DBG("Started timer [ %s ], expire time at [ %u ]sec : [ %u ] ns"
- , timer.getName().getString()
- , posixTimer->getDueTime().tv_sec
- , posixTimer->getDueTime().tv_nsec);
- }
- else
- {
- TRACE_ERR( "System Failed to start timer in period [ %d ] ms, timer name [ %s ]. System Error [ %p ]"
- , timer.getTimeout( )
- , timer.getName( ).getString()
- , static_cast(errno) );
}
return result;
diff --git a/framework/areg/component/private/posix/WatchdogManagerPosix.cpp b/framework/areg/component/private/posix/WatchdogManagerPosix.cpp
index 6e87a67a8..a05b46bbe 100644
--- a/framework/areg/component/private/posix/WatchdogManagerPosix.cpp
+++ b/framework/areg/component/private/posix/WatchdogManagerPosix.cpp
@@ -23,14 +23,10 @@
#include "areg/base/private/posix/SynchLockAndWaitIX.hpp"
#include "areg/component/Timer.hpp"
#include "areg/base/NEUtilities.hpp"
-#include "areg/trace/GETrace.h"
#include
#include
#include
-DEF_TRACE_SCOPE(areg_component_private_posix_WatchdogManager__osSystemTimerStart );
-DEF_TRACE_SCOPE(areg_component_private_posix_WatchdogManager__posixWatchdogExpiredRoutine );
-
//////////////////////////////////////////////////////////////////////////
// Linux specific methods
//////////////////////////////////////////////////////////////////////////
@@ -46,8 +42,6 @@ void WatchdogManager::_osSystemTimerStop(TIMERHANDLE handle)
bool WatchdogManager::_osSystemTimerStart(Watchdog& watchdog)
{
- TRACE_SCOPE(areg_component_private_posix_WatchdogManager__osSystemTimerStart );
-
bool result = false;
TimerPosix* posixTimer = reinterpret_cast(watchdog.getHandle());
if (posixTimer != nullptr)
@@ -55,20 +49,8 @@ bool WatchdogManager::_osSystemTimerStart(Watchdog& watchdog)
Watchdog::WATCHDOG_ID watchdogId = watchdog.watchdogId();
if (posixTimer->startTimer(watchdog, watchdogId, &WatchdogManager::_posixWatchdogExpiredRoutine))
{
- TRACE_DBG("Started watchdog timer [ %s ] with timeout [ %u ] ms", watchdog.getName().getString(), watchdog.getTimeout());
result = true;
}
- else
- {
- TRACE_ERR("System failed to start watchdog timer in period [ %d ] ms, timer name [ %s ]. System Error [ %p ]"
- , watchdog.getTimeout()
- , watchdog.getName().getString()
- , static_cast(errno));
- }
- }
- else
- {
- TRACE_ERR("The POSIX timer is null");
}
return result;
@@ -76,8 +58,6 @@ bool WatchdogManager::_osSystemTimerStart(Watchdog& watchdog)
void WatchdogManager::_posixWatchdogExpiredRoutine(union sigval argSig)
{
- TRACE_SCOPE(areg_component_private_posix_WatchdogManager__posixWatchdogExpiredRoutine );
-
WatchdogManager& watchdogManager = WatchdogManager::getInstance();
TimerPosix * posixTimer = reinterpret_cast(argSig.sival_ptr);
ASSERT(posixTimer != nullptr);
@@ -92,10 +72,6 @@ void WatchdogManager::_posixWatchdogExpiredRoutine(union sigval argSig)
posixTimer->stopTimer();
watchdogManager._processExpiredTimer(watchdog, watchdogId, highValue, lowValue);
}
- else
- {
- TRACE_WARN("Ignore handling null timer, watchdog is [ %s ]", watchdog == nullptr ? "NOT REGISTERED ANYMORE" : "ALREADY INVALID");
- }
}
#endif // defined(_POSIX) || defined(POSIX)
diff --git a/framework/areg/ipc/ServerConnectionBase.hpp b/framework/areg/ipc/ServerConnectionBase.hpp
index 5eb6597e8..4150225a8 100644
--- a/framework/areg/ipc/ServerConnectionBase.hpp
+++ b/framework/areg/ipc/ServerConnectionBase.hpp
@@ -72,7 +72,7 @@ class AREG_API ServerConnectionBase
/**
* \brief The size of master list to listen sockets for incoming messages.
**/
- static constexpr int MASTER_LIST_SIZE = 64;
+ static constexpr int MASTER_LIST_SIZE { 64 };
//////////////////////////////////////////////////////////////////////////
// Constructors / Destructor
diff --git a/framework/areg/ipc/ServiceClientConnectionBase.hpp b/framework/areg/ipc/ServiceClientConnectionBase.hpp
index 706d6438e..66c265a98 100644
--- a/framework/areg/ipc/ServiceClientConnectionBase.hpp
+++ b/framework/areg/ipc/ServiceClientConnectionBase.hpp
@@ -134,6 +134,16 @@ class ServiceClientConnectionBase : public IEServiceConnectionProvider
**/
inline bool isDisconnectState( void ) const;
+ /**
+ * \brief Registers the client socket connection thread to receive service commands.
+ **/
+ inline void registerForServiceClientCommands(void);
+
+ /**
+ * \brief Unregisters the client socket connection thread to receive service commands.
+ **/
+ inline void unregisterForServiceClientCommands(void);
+
//////////////////////////////////////////////////////////////////////////
// Overrides
//////////////////////////////////////////////////////////////////////////
@@ -456,6 +466,16 @@ inline bool ServiceClientConnectionBase::isDisconnectState( void ) const
return (static_cast(mConnectionState) & static_cast(ServiceClientConnectionBase::eConnectionState::DisconnectState));
}
+inline void ServiceClientConnectionBase::registerForServiceClientCommands(void)
+{
+ ServiceClientEvent::addListener(static_cast(mEventConsumer), mMessageDispatcher);
+}
+
+inline void ServiceClientConnectionBase::unregisterForServiceClientCommands(void)
+{
+ ServiceClientEvent::removeListener(static_cast(mEventConsumer), mMessageDispatcher);
+}
+
inline const char * ServiceClientConnectionBase::getString(ServiceClientConnectionBase::eConnectionState val)
{
switch (val)
@@ -514,5 +534,4 @@ inline void ServiceClientConnectionBase::disconnectService( Event::eEventPriorit
, eventPrio );
}
-
#endif // AREG_IPC_SERVICECLIENTCONNECTIONBASE_HPP
diff --git a/framework/areg/ipc/private/NERemoteService.cpp b/framework/areg/ipc/private/NERemoteService.cpp
index 628fb7fc2..12a9c8c16 100644
--- a/framework/areg/ipc/private/NERemoteService.cpp
+++ b/framework/areg/ipc/private/NERemoteService.cpp
@@ -27,7 +27,10 @@ namespace
return ((client != NEService::COOKIE_UNKNOWN) && client != (NEService::COOKIE_LOCAL));
}
- inline static void _createRegisterRequest(RemoteMessage & out_msgRegister, NEService::eServiceRequestType reqType, NEService::eDisconnectReason reason, const StubAddress & addrService)
+ inline static void _createRegisterRequest( RemoteMessage & out_msgRegister
+ , NEService::eServiceRequestType reqType
+ , NEService::eDisconnectReason reason
+ , const StubAddress & addrService)
{
if (out_msgRegister.initMessage(NERemoteService::getMessageRegisterService().rbHeader) != nullptr)
{
@@ -38,7 +41,10 @@ namespace
}
}
- inline static void _createRegisterRequest(RemoteMessage & out_msgRegister, NEService::eServiceRequestType reqType, NEService::eDisconnectReason reason, const ProxyAddress & addrService)
+ inline static void _createRegisterRequest( RemoteMessage & out_msgRegister
+ , NEService::eServiceRequestType reqType
+ , NEService::eDisconnectReason reason
+ , const ProxyAddress & addrService)
{
if (out_msgRegister.initMessage(NERemoteService::getMessageRegisterService().rbHeader) != nullptr)
{
@@ -49,7 +55,10 @@ namespace
}
}
- inline static void _createRegisterNotify(RemoteMessage & out_msgNotify, NEService::eServiceRequestType reqType, NEService::eDisconnectReason reason, const StubAddress & addrService)
+ inline static void _createRegisterNotify( RemoteMessage & out_msgNotify
+ , NEService::eServiceRequestType reqType
+ , NEService::eDisconnectReason reason
+ , const StubAddress & addrService)
{
if (out_msgNotify.initMessage(NERemoteService::getMessageRegisterNotify().rbHeader) != nullptr)
{
@@ -60,7 +69,10 @@ namespace
}
}
- inline static void _createRegisterNotify(RemoteMessage & out_msgNotify, NEService::eServiceRequestType reqType, NEService::eDisconnectReason reason, const ProxyAddress & addrService)
+ inline static void _createRegisterNotify( RemoteMessage & out_msgNotify
+ , NEService::eServiceRequestType reqType
+ , NEService::eDisconnectReason reason
+ , const ProxyAddress & addrService)
{
if (out_msgNotify.initMessage(NERemoteService::getMessageRegisterNotify().rbHeader) != nullptr)
{
diff --git a/framework/areg/ipc/private/RouterClient.cpp b/framework/areg/ipc/private/RouterClient.cpp
index 612fa5293..485f25a5c 100644
--- a/framework/areg/ipc/private/RouterClient.cpp
+++ b/framework/areg/ipc/private/RouterClient.cpp
@@ -275,8 +275,8 @@ void RouterClient::processReceivedMessage( const RemoteMessage & msgReceived, So
TRACE_SCOPE(areg_ipc_private_RouterClient_processReceivedMessage);
if ( msgReceived.isValid() && whichSource.isValid() )
{
- NEService::eFuncIdRange msgId = static_cast( msgReceived.getMessageId());
- NEMemory::eMessageResult result = static_cast(msgReceived.getResult());
+ NEService::eFuncIdRange msgId{ static_cast(msgReceived.getMessageId()) };
+ NEMemory::eMessageResult result{ static_cast(msgReceived.getResult()) };
TRACE_DBG("Processing received valid message [ %u ], result [ %s ]", msgId, NEMemory::getString(result));
switch ( msgId )
@@ -544,7 +544,7 @@ void RouterClient::readyForEvents(bool isReady)
{
if (isReady)
{
- ServiceClientEvent::addListener(static_cast(mEventConsumer), static_cast(self()));
+ registerForServiceClientCommands();
DispatcherThread::readyForEvents(true);
setConnectionState(ServiceClientConnectionBase::eConnectionState::DisconnectState);
}
@@ -552,7 +552,7 @@ void RouterClient::readyForEvents(bool isReady)
{
DispatcherThread::readyForEvents(false);
setConnectionState(ServiceClientConnectionBase::eConnectionState::ConnectionStopped);
- ServiceClientEvent::removeListener(static_cast(mEventConsumer), static_cast(self()));
+ unregisterForServiceClientCommands();
}
}
diff --git a/framework/areg/ipc/private/ServiceClientConnectionBase.cpp b/framework/areg/ipc/private/ServiceClientConnectionBase.cpp
index 264967c39..f07384853 100644
--- a/framework/areg/ipc/private/ServiceClientConnectionBase.cpp
+++ b/framework/areg/ipc/private/ServiceClientConnectionBase.cpp
@@ -225,10 +225,10 @@ void ServiceClientConnectionBase::onServiceConnectionStarted(void)
{
TRACE_DBG("Succeeded to start router service client, cookie [ %llu ]", mClientConnection.getCookie());
- setConnectionState(ServiceClientConnectionBase::eConnectionState::ConnectionStarted);
mChannel.setCookie( mClientConnection.getCookie() );
mChannel.setSource( mMessageDispatcher.getId());
mChannel.setTarget( mTarget );
+ setConnectionState(ServiceClientConnectionBase::eConnectionState::ConnectionStarted);
mConnectionConsumer.connectedRemoteServiceChannel(mChannel);
}
}
diff --git a/framework/areg/ipc/private/SocketConnectionBase.cpp b/framework/areg/ipc/private/SocketConnectionBase.cpp
index 3d6075df4..7a520bf5d 100644
--- a/framework/areg/ipc/private/SocketConnectionBase.cpp
+++ b/framework/areg/ipc/private/SocketConnectionBase.cpp
@@ -20,27 +20,13 @@
#include "areg/trace/GETrace.h"
-DEF_TRACE_SCOPE(areg_ipc_SocketConnectionBase_sendMessage);
-DEF_TRACE_SCOPE(areg_ipc_SocketConnectionBase_receiveMessage);
-
int SocketConnectionBase::sendMessage(const RemoteMessage & in_message, const Socket & clientSocket) const
{
- TRACE_SCOPE(areg_ipc_SocketConnectionBase_sendMessage);
-
- int result = -1;
+ int result{ -1 };
if ( in_message.isValid() && clientSocket.isValid() )
{
in_message.bufferCompletionFix();
const NEMemory::sRemoteMessageHeader & buffer = reinterpret_cast( *in_message.getByteBuffer() );
-
- TRACE_DBG("Sending message with ID [ %u ] from source [ %llu ] to target [ %llu ] via socket [ %llu ], data length [ %u ], checksum [ %u ]"
- , in_message.getMessageId()
- , in_message.getSource()
- , in_message.getTarget()
- , clientSocket.getHandle()
- , buffer.rbhBufHeader.biUsed
- , buffer.rbhChecksum);
-
result = clientSocket.sendData( reinterpret_cast(&buffer), sizeof(NEMemory::sRemoteMessageHeader) );
if ((result == sizeof(NEMemory::sRemoteMessageHeader)) && (buffer.rbhBufHeader.biUsed != 0))
{
@@ -49,37 +35,21 @@ int SocketConnectionBase::sendMessage(const RemoteMessage & in_message, const So
result += clientSocket.sendData(in_message.getBuffer(), static_cast(buffer.rbhBufHeader.biLength));
}
}
- else
- {
- TRACE_ERR("Either socket is [ %s ] or the remote buffer is [ %s ] to send"
- , clientSocket.isValid() ? "VALID" : "INVALID"
- , in_message.isValid() ? "VALID" : "INVALID");
- }
return result;
}
int SocketConnectionBase::receiveMessage(RemoteMessage & out_message, const Socket & clientSocket) const
{
- TRACE_SCOPE(areg_ipc_SocketConnectionBase_receiveMessage);
-
- int result = -1;
+ int result{ -1 };
if ( clientSocket.isValid() && clientSocket.isAlive() )
{
NEMemory::sRemoteMessageHeader msgHeader{};
out_message.invalidate();
- TRACE_DBG("Wait to receive message header");
result = clientSocket.receiveData(reinterpret_cast(&msgHeader), sizeof(NEMemory::sRemoteMessageHeader));
if ( result == sizeof(NEMemory::sRemoteMessageHeader) )
{
- TRACE_DBG("Receiving message with ID [ %u ] from target [ %llu ] for source [ %llu ], data length [ %u ], checksum [ %u ]"
- , msgHeader.rbhMessageId
- , msgHeader.rbhTarget
- , msgHeader.rbhSource
- , msgHeader.rbhBufHeader.biLength
- , msgHeader.rbhChecksum);
-
result = sizeof(NEMemory::sRemoteMessageHeader);
unsigned char * buffer = out_message.initMessage( msgHeader );
if ( (buffer != nullptr) && (msgHeader.rbhBufHeader.biUsed > 0))
@@ -93,23 +63,15 @@ int SocketConnectionBase::receiveMessage(RemoteMessage & out_message, const Sock
out_message.moveToBegin();
if ( out_message.isChecksumValid() == false )
{
- TRACE_WARN("Received [ %u ] bytes of message data, but checksum is invalid, ignoring message", result);
result = 0;
out_message.invalidate();
}
}
else
{
- TRACE_WARN("Failed to receive message data. Probably the connection is closed, received [ %d ] bytes.", result);
result = (result > 0) && (result != sizeof(NEMemory::sRemoteMessageHeader)) ? 0 : result;
}
}
- else
- {
- TRACE_WARN("Ignore processing message, the client socket is [ %s : %s ]"
- , clientSocket.isValid() ? "VALID" : "INVALID"
- , clientSocket.isAlive() ? "ALIVE" : "DEAD");
- }
return result;
}
diff --git a/framework/areg/persist/ConfigManager.hpp b/framework/areg/persist/ConfigManager.hpp
index 557972f20..2445856a2 100644
--- a/framework/areg/persist/ConfigManager.hpp
+++ b/framework/areg/persist/ConfigManager.hpp
@@ -22,7 +22,6 @@
#include "areg/base/String.hpp"
#include "areg/base/SynchObjects.hpp"
-#include "areg/base/TEMap.hpp"
#include "areg/base/Version.hpp"
#include "areg/persist/NEPersistence.hpp"
#include "areg/persist/Property.hpp"
@@ -35,6 +34,7 @@
* Dependencies.
************************************************************************/
class FileBase;
+class IEConfigurationListener;
//////////////////////////////////////////////////////////////////////////
// ConfigManager class declaration
@@ -50,13 +50,6 @@ class FileBase;
**/
class AREG_API ConfigManager
{
-//////////////////////////////////////////////////////////////////////////
-// Object specific types and constants
-//////////////////////////////////////////////////////////////////////////
-public:
- //!< The type to initialize list of properties.
- using ListProperties = TEArrayList;
-
//////////////////////////////////////////////////////////////////////////
// Constructors / destructor
//////////////////////////////////////////////////////////////////////////
@@ -86,12 +79,42 @@ class AREG_API ConfigManager
/**
* \brief Returns the list of read-only configuration properties.
**/
- inline const ConfigManager::ListProperties & getReadonlyProperties( void ) const;
+ inline const NEPersistence::ListProperties & getReadonlyProperties( void ) const;
/**
* \brief Returns the list of writable configuration properties.
**/
- inline const ConfigManager::ListProperties & getModuleProperties( void ) const;
+ inline const NEPersistence::ListProperties & getModuleProperties( void ) const;
+
+ /**
+ * \brief Locks the access resources of configuration manager. The current thread
+ * gets access ownership until unlock method is called. If a thread already
+ * owns the resource access of the configuration, the current thread is suspended.
+ * \return Returns true if current thread successfully got configuration resource ownership.
+ **/
+ inline bool lock(void) const;
+
+ /**
+ * \brief Unlocks / releases the configuration resource access ownership, so that other thread
+ * may access the resources. The calling thread should have resource ownership to unlock it.
+ * Otherwise, no lock state is changed.
+ * \return Returns true if succeeded.
+ **/
+ inline bool unlock(void) const;
+
+ /**
+ * \brief Attempts to get configuration resource access ownership without blocking current thread.
+ * If the call succeeded, the calling thread takes the resource access ownership. Otherwise,
+ * the access is already locked by another thread.
+ * \return Return true if the configuration resource access ownership succeeded. Otherwise,
+ * returns false.
+ **/
+ inline bool tryLock(void) const;
+
+ /**
+ * \brief Return true if configuration resources access is already locked by a thread.
+ **/
+ inline bool isLocked(void) const;
/**
* \brief Returns true if the specified property exists.
@@ -111,7 +134,7 @@ class AREG_API ConfigManager
/**
* \brief Returns merged list of read-only and writable properties of the specified section.
**/
- ConfigManager::ListProperties getSectionProperties(const String& section) const;
+ NEPersistence::ListProperties getSectionProperties(const String& section) const;
/**
* \brief Returns the pointer of the property searched by specified parameters.
@@ -257,12 +280,12 @@ class AREG_API ConfigManager
* \param propList The list of new properties to add.
* \return Returns number of properties added to the writable list of the module.
**/
- inline int addModuleProperties(const ConfigManager::ListProperties& propList);
+ inline int addModuleProperties(const NEPersistence::ListProperties& propList);
/**
* \brief Overwrites the existing list of writable properties. All existing properties will be lost.
**/
- inline void replaceModuleProperty(const ConfigManager::ListProperties& listProperties);
+ inline void replaceModuleProperty(const NEPersistence::ListProperties& listProperties);
/**
* \brief Removes the existing configuration entry from the writable list.
@@ -306,9 +329,12 @@ class AREG_API ConfigManager
* NEApplication::DEFAULT_CONFIG_FILE file path.
* \param filePath The relative of full path to the configuration file.
* If empty, uses NEApplication::DEFAULT_CONFIG_FILE file path.
+ * \param listener The pointer to the configuration listener to notify
+ * before and after reading configuration from the file.
+ * If nullptr, no notification is triggered.
* \return Returns true if succeeded to read and initialize configuration.
**/
- bool readConfig(const String& filePath = String::EmptyString);
+ bool readConfig(const String& filePath = String::EmptyString, IEConfigurationListener * listener = nullptr);
/**
* \brief Reads the configuration from the specified configuration file.
@@ -316,9 +342,12 @@ class AREG_API ConfigManager
* If the specified file path is empty, it uses default
* NEApplication::DEFAULT_CONFIG_FILE file path.
* \param file The instance of file object opened for reading.
+ * \param listener The pointer to the configuration listener to notify
+ * before and after reading configuration from the file.
+ * If nullptr, no notification is triggered.
* \return Returns true if succeeded to read and initialize configuration.
**/
- bool readConfig(const FileBase& file);
+ bool readConfig(const FileBase& file, IEConfigurationListener * listener = nullptr);
/**
* \brief Saves the current configuration in the specified file.
@@ -328,9 +357,12 @@ class AREG_API ConfigManager
* If file is empty, uses the same name of previously opened file.
* If the current configuration file path is empty (defaults are initialized),
* it uses NEApplication::DEFAULT_CONFIG_FILE file to save.
+ * \param listener The pointer to the configuration listener to notify
+ * before and after saving configuration to the file.
+ * If nullptr, no notification is triggered.
* \return Returns true if succeeded to save configuration.
**/
- bool saveConfig(const String& filePath = String::EmptyString);
+ bool saveConfig(const String& filePath = String::EmptyString, IEConfigurationListener * listener = nullptr);
/**
* \brief Saves the current configuration in the specified file object opened with write access.
@@ -340,9 +372,21 @@ class AREG_API ConfigManager
* If file is empty, uses the same name of previously opened file.
* If the current configuration file path is empty (defaults are initialized),
* it uses NEApplication::DEFAULT_CONFIG_FILE file to save.
+ * \param listener The pointer to the configuration listener to notify
+ * before and after saving configuration to the file.
+ * If nullptr, no notification is triggered.
* \return Returns true if succeeded to save configuration.
**/
- bool saveConfig(const FileBase& srcFile, FileBase& dstFile);
+ bool saveConfig(const FileBase& srcFile, FileBase& dstFile, bool saveAll, IEConfigurationListener * listener = nullptr);
+
+ /**
+ * \brief Sets the read-only and writable configuration entries.
+ * \param listReadonly The list of read-only configuration properties.
+ * \param listWritable The list of writable configuration properties.
+ * \param listener The pointer to the configuration listener to notify configuration data set/
+ * If nullptr, no notification is triggered.
+ **/
+ void setConfiguration(const NEPersistence::ListProperties& listReadonly, const NEPersistence::ListProperties& listWritable, IEConfigurationListener * listener = nullptr);
/**
* \brief Releases all module specific entries.
@@ -356,13 +400,6 @@ class AREG_API ConfigManager
**/
inline void releaseProperties(void);
- /**
- * \brief Sets the read-only and writable configuration entries.
- * \param listReadonly The list of read-only configuration properties.
- * \param listWritable The list of writable configuration properties.
- **/
- inline void setConfiguration(const ConfigManager::ListProperties& listReadonly, const ConfigManager::ListProperties& listWritable);
-
/************************************************************************
* Configuration properties.
************************************************************************/
@@ -724,12 +761,12 @@ class AREG_API ConfigManager
/**
* \brief The list of writable properties of the configuration, which can be modified for current process.
**/
- ListProperties mWritableProperties;
+ NEPersistence::ListProperties mWritableProperties;
/**
* \brief The list of read-only properties of the configuration, which cannot be modified.
**/
- ListProperties mReadonlyProperties;
+ NEPersistence::ListProperties mReadonlyProperties;
#if defined(_MSC_VER) && (_MSC_VER > 1200)
#pragma warning(default: 4251)
@@ -772,18 +809,38 @@ inline const String& ConfigManager::getConfigFile(void) const
return mFilePath;
}
-inline const ConfigManager::ListProperties& ConfigManager::getReadonlyProperties(void) const
+inline const NEPersistence::ListProperties& ConfigManager::getReadonlyProperties(void) const
{
Lock lock(mLock);
return mReadonlyProperties;
}
-inline const ConfigManager::ListProperties& ConfigManager::getModuleProperties(void) const
+inline const NEPersistence::ListProperties& ConfigManager::getModuleProperties(void) const
{
Lock lock(mLock);
return mWritableProperties;
}
+inline bool ConfigManager::lock(void) const
+{
+ return mLock.lock();
+}
+
+inline bool ConfigManager::unlock(void) const
+{
+ return mLock.unlock();
+}
+
+inline bool ConfigManager::tryLock(void) const
+{
+ return mLock.tryLock();
+}
+
+inline bool ConfigManager::isLocked(void) const
+{
+ return mLock.isLocked();
+}
+
inline bool ConfigManager::existProperty(const String& section, const String& property, const String& position) const
{
return existProperty(PropertyKey(section, mModule, property, position));
@@ -805,9 +862,9 @@ inline void ConfigManager::setModuleProperty(const PropertyKey& key, const Strin
}
inline const PropertyValue * ConfigManager::getPropertyValue( const String& section
- , const String& property
- , const String& position /*= String::EmptyString*/
- , NEPersistence::eConfigKeys keyType /*= NEPersistence::eConfigKeys::EntryAnyKey*/) const
+ , const String& property
+ , const String& position /*= String::EmptyString*/
+ , NEPersistence::eConfigKeys keyType /*= NEPersistence::eConfigKeys::EntryAnyKey*/) const
{
Lock lock(mLock);
@@ -825,10 +882,10 @@ inline const PropertyValue* ConfigManager::getModulePropertyValue(const Property
return getModulePropertyValue(key.getSection(), key.getProperty(), key.getPosition(), key.getKeyType());
}
-inline const PropertyValue* ConfigManager::getModulePropertyValue( const String& section
- , const String& property
- , const String& position /*= String::EmptyString*/
- , NEPersistence::eConfigKeys keyType /*= NEPersistence::eConfigKeys::EntryAnyKey*/) const
+inline const PropertyValue * ConfigManager::getModulePropertyValue( const String& section
+ , const String& property
+ , const String& position /*= String::EmptyString*/
+ , NEPersistence::eConfigKeys keyType /*= NEPersistence::eConfigKeys::EntryAnyKey*/) const
{
Lock lock(mLock);
@@ -852,7 +909,7 @@ inline PropertyValue * ConfigManager::getModulePropertyValue( const String& sect
return (result != nullptr ? &const_cast(result)->getValue() : nullptr);
}
-inline int ConfigManager::addModuleProperties(const ConfigManager::ListProperties& propList)
+inline int ConfigManager::addModuleProperties(const NEPersistence::ListProperties& propList)
{
int result{ 0 };
Lock lock(mLock);
@@ -869,7 +926,7 @@ inline int ConfigManager::addModuleProperties(const ConfigManager::ListPropertie
return result;
}
-inline void ConfigManager::replaceModuleProperty(const ConfigManager::ListProperties& listProperties)
+inline void ConfigManager::replaceModuleProperty(const NEPersistence::ListProperties& listProperties)
{
Lock lock(mLock);
mWritableProperties = listProperties;
@@ -894,14 +951,6 @@ inline void ConfigManager::releaseProperties(void)
mReadonlyProperties.clear();
}
-inline void ConfigManager::setConfiguration(const ConfigManager::ListProperties& listReadonly, const ConfigManager::ListProperties& listWritable)
-{
- Lock lock(mLock);
- mIsConfigured = true;
- mWritableProperties = listWritable;
- mReadonlyProperties = listReadonly;
-}
-
inline void ConfigManager::setLoggingStatus(bool newValue, bool isTemporary /*= false*/)
{
Lock lock(mLock);
@@ -923,7 +972,7 @@ inline void ConfigManager::setLogEnabled(const String& logType, bool newValue, b
constexpr NEPersistence::eConfigKeys confKey = NEPersistence::eConfigKeys::EntryLogEnable;
const NEPersistence::sPropertyKey& key = NEPersistence::getLogEnable();
- setModuleProperty(key.section, key.property, key.position, String::toString(newValue), confKey, isTemporary);
+ setModuleProperty(key.section, key.property, logType, String::toString(newValue), confKey, isTemporary);
}
inline void ConfigManager::setLogEnabled(const Identifier& logType, bool newValue, bool isTemporary /*= false*/)
diff --git a/framework/areg/persist/IEConfigurationListener.hpp b/framework/areg/persist/IEConfigurationListener.hpp
new file mode 100644
index 000000000..2415accd9
--- /dev/null
+++ b/framework/areg/persist/IEConfigurationListener.hpp
@@ -0,0 +1,96 @@
+#ifndef AREG_PERSIST_IECONFIGURATIONLISTENER_HPP
+#define AREG_PERSIST_IECONFIGURATIONLISTENER_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 areg/persist/IEConfigurationListener.hpp
+ * \ingroup AREG SDK, Asynchronous Event Generator Software Development Kit
+ * \author Artak Avetyan
+ * \brief AREG Platform, the configuration object to read configuration file.
+ ************************************************************************/
+
+ /************************************************************************
+ * Include files.
+ ************************************************************************/
+#include "areg/base/GEGlobal.h"
+
+#include "areg/persist/ConfigManager.hpp"
+
+/************************************************************************
+ * Dependencies.
+ ************************************************************************/
+class ConfigManager;
+
+/**
+ * \brief Configuration listener is an object, which methods are triggered
+ * when the application loads, saves or sets default configuration data.
+ * It is normally used by Application object when initializing the application
+ * and loads the configuration. In this case the developers may change
+ * the configuration during run-time and manually update the configuration.
+ * For example, the developers may set temporary property, which will
+ * have the influence on the application, but not saved in the config file.
+ **/
+class IEConfigurationListener
+{
+//////////////////////////////////////////////////////////////////////////
+// Protected constructors / destructor
+//////////////////////////////////////////////////////////////////////////
+protected:
+ IEConfigurationListener(void) = default;
+ virtual ~IEConfigurationListener(void) = default;
+
+//////////////////////////////////////////////////////////////////////////
+// Overrides
+//////////////////////////////////////////////////////////////////////////
+public:
+/************************************************************************/
+// IEConfigurationListener interface overrides
+/************************************************************************/
+
+ /**
+ * \brief Called by configuration manager before the configuration is saved in the file.
+ * \param config The instance of configuration manager.
+ **/
+ virtual void prepareSaveConfiguration(ConfigManager& config) = 0;
+
+ /**
+ * \brief Called by configuration manager after the configuration is saved in the file.
+ * \param config The instance of configuration manager.
+ **/
+ virtual void postSaveConfiguration(ConfigManager& config) = 0;
+
+ /**
+ * \brief Called by configuration manager before the configuration is loaded from the file.
+ * \param config The instance of configuration manager.
+ **/
+ virtual void prepareReadConfiguration(ConfigManager& config) = 0;
+
+ /**
+ * \brief Called by configuration manager when configuration is completed to load data from the file.
+ * \param config The instance of configuration manager.
+ **/
+ virtual void postReadConfiguration(ConfigManager& config) = 0;
+
+ /**
+ * \brief Called by configuration manager after setting read-only and writable properties.
+ * For example, when the default configuration is set.
+ * \param listReadonly The list of read-only properties to set in the configuration.
+ * \param listWritable The list of module / process specific properties to set in the configuration;
+ * \param config The instance of configuration manager.
+ **/
+ virtual void onSetupConfiguration(const NEPersistence::ListProperties& listReadonly, const NEPersistence::ListProperties& listWritable, ConfigManager& config) = 0;
+
+//////////////////////////////////////////////////////////////////////////
+// Forbidden calls
+//////////////////////////////////////////////////////////////////////////
+private:
+ DECLARE_NOCOPY_NOMOVE(IEConfigurationListener);
+};
+
+#endif // AREG_PERSIST_IECONFIGURATIONLISTENER_HPP
diff --git a/framework/areg/persist/NEPersistence.hpp b/framework/areg/persist/NEPersistence.hpp
index 16b2b9223..91b4c8a37 100644
--- a/framework/areg/persist/NEPersistence.hpp
+++ b/framework/areg/persist/NEPersistence.hpp
@@ -142,31 +142,31 @@ namespace NEPersistence
**/
enum eConfigKeys : int
{
- EntryInvalid = -1 //!< Invalid key of the configuration
- , EntryConfigVersion = 0 //!< The configuration version.
-
- , EntryLogVersion = 1 //!< The logging version.
- , EntryLogTarget = 2 //!< The logging types (targets).
- , EntryLogStatus = 3 //!< The logging enabled / disabled status.
- , EntryLogEnable = 4 //!< The logging type (in target) enabled / disabled flag.
- , EntryLogFileLocation = 5 //!< The log file location and file name mask.
- , EntryLogFileAppend = 6 //!< The flag to append logs into the file.
- , EntryLogRemoteQueue = 7 //!< The queue size of remote logging.
- , EntryLogRemoteService = 8 //!< The service name of the remote logging.
- , EntryLogLayoutEnter = 9 //!< The layout of enter scope message.
- , EntryLogLayoutMessage = 10 //!< The layout of log message.
- , EntryLogLayoutExit = 11 //!< The layout of exit scope message.
- , EntryLogScope = 12 //!< The log scope enable / disable flag.
-
- , EntryServiceList = 13 //!< The list of supported remote services.
-
- , EntryServiceName = 14 //!< The process name of the remote service.
- , EntryServiceConnection= 15 //!< The list of connection type of the remote service.
- , EntryServiceEnable = 16 //!< The connection enable / disable flag of the remote service.
- , EntryServiceAddress = 17 //!< The connection address of the remote service.
- , EntryServicePort = 18 //!< The connection port number of the remote service.
-
- , EntryAnyKey = 19 //!< Indicates any key type.
+ EntryInvalid = -1 //!< Invalid key of the configuration
+ , EntryConfigVersion = 0 //!< The configuration version.
+
+ , EntryLogVersion = 1 //!< The logging version.
+ , EntryLogTarget = 2 //!< The logging types (targets).
+ , EntryLogStatus = 3 //!< The logging enabled / disabled status.
+ , EntryLogEnable = 4 //!< The logging type (in target) enabled / disabled flag.
+ , EntryLogFileLocation = 5 //!< The log file location and file name mask.
+ , EntryLogFileAppend = 6 //!< The flag to append logs into the file.
+ , EntryLogRemoteQueueSize = 7 //!< The queue size of remote logging.
+ , EntryLogRemoteService = 8 //!< The service name of the remote logging.
+ , EntryLogLayoutEnter = 9 //!< The layout of enter scope message.
+ , EntryLogLayoutMessage = 10 //!< The layout of log message.
+ , EntryLogLayoutExit = 11 //!< The layout of exit scope message.
+ , EntryLogScope = 12 //!< The log scope enable / disable flag.
+
+ , EntryServiceList = 13 //!< The list of supported remote services.
+
+ , EntryServiceName = 14 //!< The process name of the remote service.
+ , EntryServiceConnection = 15 //!< The list of connection type of the remote service.
+ , EntryServiceEnable = 16 //!< The connection enable / disable flag of the remote service.
+ , EntryServiceAddress = 17 //!< The connection address of the remote service.
+ , EntryServicePort = 18 //!< The connection port number of the remote service.
+
+ , EntryAnyKey = 19 //!< Indicates any key type.
};
/**
@@ -182,7 +182,7 @@ namespace NEPersistence
, {"log" , "*" , "enable" , "*" } //! 4 , The logging type (in target) enabled / disabled flag property structure.
, {"log" , "*" , "file" , "location"} //! 5 , The log file location and file name mask property structure.
, {"log" , "*" , "file" , "append" } //! 6 , The flag to append logs into the file property structure.
- , {"log" , "*" , "remote" , "size" } //! 7 , The queue size of remote logging property structure.
+ , {"log" , "*" , "remote" , "queue" } //! 7 , The queue size of remote logging property structure.
, {"log" , "*" , "remote" , "service" } //! 8 , The service name of the remote logging.
, {"log" , "*" , "layout" , "enter" } //! 9 , The layout of enter scope message property structure.
, {"log" , "*" , "layout" , "message" } //! 10 , The layout of log message property structure.
@@ -336,7 +336,7 @@ inline const NEPersistence::sPropertyKey& NEPersistence::getLogFileAppend(void)
inline const NEPersistence::sPropertyKey& NEPersistence::getLogRemoteQueueSize(void)
{
- return NEPersistence::DefaultPropertyKeys[static_cast(NEPersistence::eConfigKeys::EntryLogRemoteQueue)];
+ return NEPersistence::DefaultPropertyKeys[static_cast(NEPersistence::eConfigKeys::EntryLogRemoteQueueSize)];
}
inline const NEPersistence::sPropertyKey& NEPersistence::getLogLayoutEnter(void)
diff --git a/framework/areg/persist/Property.hpp b/framework/areg/persist/Property.hpp
index 5e38d1781..65b6afe0c 100644
--- a/framework/areg/persist/Property.hpp
+++ b/framework/areg/persist/Property.hpp
@@ -352,4 +352,13 @@ namespace std
};
}
+#include "areg/base/Containers.hpp"
+
+// Declaration of ListProperties within NEPersistence namespace
+namespace NEPersistence
+{
+ //!< The type to initialize list of properties.
+ using ListProperties = TEArrayList;
+}
+
#endif // AREG_PERSIST_PROPERTY_HPP
diff --git a/framework/areg/persist/private/CMakeLists.txt b/framework/areg/persist/private/CMakeLists.txt
index e6918b0c8..88e0e6457 100644
--- a/framework/areg/persist/private/CMakeLists.txt
+++ b/framework/areg/persist/private/CMakeLists.txt
@@ -1,5 +1,6 @@
list(APPEND areg_SRC
${areg_BASE}/persist/private/ConfigManager.cpp
+ ${areg_BASE}/persist/private/IEConfigurationListener.cpp
${areg_BASE}/persist/private/NEPersistence.cpp
${areg_BASE}/persist/private/PersistenceManager.cpp
${areg_BASE}/persist/private/Property.cpp
diff --git a/framework/areg/persist/private/ConfigManager.cpp b/framework/areg/persist/private/ConfigManager.cpp
index 0b36617e1..148fb3811 100644
--- a/framework/areg/persist/private/ConfigManager.cpp
+++ b/framework/areg/persist/private/ConfigManager.cpp
@@ -21,6 +21,7 @@
#include "areg/appbase/NEApplication.hpp"
#include "areg/base/File.hpp"
#include "areg/base/Process.hpp"
+#include "areg/persist/IEConfigurationListener.hpp"
namespace
{
@@ -34,22 +35,21 @@ namespace
, NEPersistence::eConfigKeys configKey)
{
uint32_t result { NECommon::INVALID_POSITION };
- uint32_t count { 0 };
const auto& list{ propList.getData() };
- for (const auto & prop : list)
+ uint32_t count{ static_cast(list.size()) };
+
+ for (uint32_t pos = startAt; pos < count; ++ pos)
{
- const PropertyKey& key = prop.getKey();
+ const PropertyKey& key = propList[pos].getKey();
if ((configKey == NEPersistence::eConfigKeys::EntryAnyKey) || (configKey == key.getKeyType()))
{
if ((exact && key.isExactProperty(section, module, property, position)) ||
(!exact && key.isModuleProperty(section, module, property, position)))
{
- result = count;
+ result = pos;
break;
}
}
-
- ++count;
}
return result;
@@ -69,6 +69,11 @@ namespace
uint32_t readPos = _findPosition(readList , 0, section, NEPersistence::SYNTAX_ALL_MODULES, property, position, false, confKey);
uint32_t writePos = _findPosition(writeList, 0, section, module, property, position, true , confKey);
+ while ((writePos != NECommon::INVALID_POSITION) && (writeList[writePos].isTemporary() != isTemporary))
+ {
+ writePos = _findPosition(writeList, writePos + 1, section, module, property, position, true, confKey);
+ }
+
if (readPos == NECommon::INVALID_POSITION)
{
if (writePos != NECommon::INVALID_POSITION)
@@ -85,7 +90,7 @@ namespace
const PropertyValue& readValue = readList[readPos].getValue();
if (newValue != static_cast(readValue))
{
- if (writePos != NECommon::INVALID_POSITION)
+ if ((writePos != NECommon::INVALID_POSITION) && (writeList[writePos].isTemporary() == isTemporary))
{
writeList[writePos].getValue() = newValue;
}
@@ -101,7 +106,7 @@ namespace
}
}
- inline const Property* _getProperty( const ConfigManager::ListProperties& list
+ inline const Property* _getProperty( const NEPersistence::ListProperties& list
, const String& section
, const String& module
, const String& property
@@ -115,7 +120,7 @@ namespace
return (elemPos != NECommon::INVALID_POSITION ? &list[elemPos] : nullptr);
}
- uint32_t _readConfig(const FileBase& file, ConfigManager::ListProperties& OUT listWritable, ConfigManager::ListProperties& OUT listReadonly, const String& module)
+ uint32_t _readConfig(const FileBase& file, NEPersistence::ListProperties& OUT listWritable, NEPersistence::ListProperties& OUT listReadonly, const String& module)
{
uint32_t result{ 0 };
@@ -257,10 +262,10 @@ bool ConfigManager::existProperty(const PropertyKey& key) const
return result;
}
-ConfigManager::ListProperties ConfigManager::getSectionProperties(const String& section) const
+NEPersistence::ListProperties ConfigManager::getSectionProperties(const String& section) const
{
Lock lock(mLock);
- ConfigManager::ListProperties result;
+ NEPersistence::ListProperties result;
if (section.isEmpty())
{
return result;
@@ -377,7 +382,7 @@ void ConfigManager::removeSectionProperties(const String& section)
}
}
-bool ConfigManager::readConfig(const String& filePath /*= String::EmptyString*/)
+bool ConfigManager::readConfig(const String& filePath /*= String::EmptyString*/, IEConfigurationListener * listener /*= nullptr*/)
{
Lock lock(mLock);
if (mIsConfigured == false)
@@ -395,7 +400,7 @@ bool ConfigManager::readConfig(const String& filePath /*= String::EmptyString*/)
path = File::getFileFullPath(File::normalizePath(path));
File fileConfig(path, FileBase::FO_MODE_EXIST | FileBase::FO_MODE_READ | FileBase::FO_MODE_TEXT | FileBase::FO_MODE_SHARE_READ);
- if (fileConfig.open() && readConfig(fileConfig))
+ if (fileConfig.open() && readConfig(fileConfig, listener))
{
mFilePath = fileConfig.getName();
}
@@ -404,20 +409,30 @@ bool ConfigManager::readConfig(const String& filePath /*= String::EmptyString*/)
return mIsConfigured;
}
-bool ConfigManager::readConfig(const FileBase& file)
+bool ConfigManager::readConfig(const FileBase& file, IEConfigurationListener * listener /*= nullptr*/)
{
Lock lock(mLock);
if (mIsConfigured == false)
{
mWritableProperties.clear();
mReadonlyProperties.clear();
+ if (listener != nullptr)
+ {
+ listener->prepareReadConfiguration(*this);
+ }
+
mIsConfigured = _readConfig(file, mWritableProperties, mReadonlyProperties, mModule) != 0;
+
+ if (listener != nullptr)
+ {
+ listener->postReadConfiguration(*this);
+ }
}
return mIsConfigured;
}
-bool ConfigManager::saveConfig(const String& filePath)
+bool ConfigManager::saveConfig(const String& filePath, IEConfigurationListener * listener /*= nullptr*/)
{
Lock lock(mLock);
bool result{ false };
@@ -459,7 +474,7 @@ bool ConfigManager::saveConfig(const String& filePath)
if (srcFile.open() && dstFile.open())
{
- if (_saveConfig(mWritableProperties.getData(), mReadonlyProperties.getData(), mModule, srcFile, dstFile, saveAll))
+ if (saveConfig(srcFile, dstFile, saveAll, listener))
{
srcFile.close();
dstFile.close();
@@ -471,12 +486,39 @@ bool ConfigManager::saveConfig(const String& filePath)
return result;
}
-bool ConfigManager::saveConfig(const FileBase& srcFile, FileBase& dstFile)
+bool ConfigManager::saveConfig(const FileBase& srcFile, FileBase& dstFile, bool saveAll, IEConfigurationListener * listener /*= nullptr*/)
+{
+ Lock lock(mLock);
+ if (listener != nullptr)
+ {
+ listener->prepareSaveConfiguration(*this);
+ }
+
+ bool result = _saveConfig(mWritableProperties.getData(), mReadonlyProperties.getData(), mModule, srcFile, dstFile, saveAll);
+
+ if (listener != nullptr)
+ {
+ listener->postSaveConfiguration(*this);
+ }
+
+ return result;
+}
+
+void ConfigManager::setConfiguration(const NEPersistence::ListProperties& listReadonly, const NEPersistence::ListProperties& listWritable, IEConfigurationListener* listener /*= nullptr*/)
{
Lock lock(mLock);
- return _saveConfig(mWritableProperties.getData(), mReadonlyProperties.getData(), mModule, srcFile, dstFile, false);
+
+ mIsConfigured = true;
+ mWritableProperties = listWritable;
+ mReadonlyProperties = listReadonly;
+
+ if (listener != nullptr)
+ {
+ listener->onSetupConfiguration(listReadonly, listWritable, *this);
+ }
}
+
Version ConfigManager::getConfigVersion(void) const
{
Lock lock(mLock);
@@ -640,7 +682,7 @@ uint32_t ConfigManager::getLogRemoteQueueSize(void) const
{
Lock lock(mLock);
- constexpr NEPersistence::eConfigKeys confKey = NEPersistence::eConfigKeys::EntryLogRemoteQueue;
+ constexpr NEPersistence::eConfigKeys confKey = NEPersistence::eConfigKeys::EntryLogRemoteQueueSize;
const NEPersistence::sPropertyKey& key = NEPersistence::getLogRemoteQueueSize();
const PropertyValue* value = getPropertyValue(key.section, key.property, key.position, confKey);
return (value != nullptr ? value->getInteger() : NEApplication::DEFAULT_LOG_QUEUE_SIZE);
@@ -650,7 +692,7 @@ void ConfigManager::setLogRemoteQueueSize(uint32_t newValue, bool isTemporary /*
{
Lock lock(mLock);
- constexpr NEPersistence::eConfigKeys confKey = NEPersistence::eConfigKeys::EntryLogRemoteQueue;
+ constexpr NEPersistence::eConfigKeys confKey = NEPersistence::eConfigKeys::EntryLogRemoteQueueSize;
const NEPersistence::sPropertyKey& key = NEPersistence::getLogRemoteQueueSize();
setModuleProperty(key.section, key.property, key.position, String::toString(newValue), confKey, isTemporary);
}
diff --git a/framework/areg/persist/private/IEConfigurationListener.cpp b/framework/areg/persist/private/IEConfigurationListener.cpp
new file mode 100644
index 000000000..09a0b5b0b
--- /dev/null
+++ b/framework/areg/persist/private/IEConfigurationListener.cpp
@@ -0,0 +1,19 @@
+/************************************************************************
+ * 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 areg/persist/private/IEConfigurationListener.cpp
+ * \ingroup AREG SDK, Asynchronous Event Generator Software Development Kit
+ * \author Artak Avetyan
+ * \brief AREG Platform, the configuration object to read configuration file.
+ ************************************************************************/
+
+ /************************************************************************
+ * Include files.
+ ************************************************************************/
+#include "areg/persist/IEConfigurationListener.hpp"
diff --git a/framework/areg/persist/private/Makefile b/framework/areg/persist/private/Makefile
index 5a0f7f229..785f68f69 100644
--- a/framework/areg/persist/private/Makefile
+++ b/framework/areg/persist/private/Makefile
@@ -1,7 +1,8 @@
areg_SRC += \
- $(areg_BASE)/persist/private/ConfigManager.cpp \
- $(areg_BASE)/persist/private/NEPersistence.cpp \
- $(areg_BASE)/persist/private/PersistenceManager.cpp \
- $(areg_BASE)/persist/private/Property.cpp \
- $(areg_BASE)/persist/private/PropertyKey.cpp \
- $(areg_BASE)/persist/private/PropertyValue.cpp \
+ $(areg_BASE)/persist/private/ConfigManager.cpp \
+ $(areg_BASE)/persist/private/IEConfigurationListener.cpp\
+ $(areg_BASE)/persist/private/NEPersistence.cpp \
+ $(areg_BASE)/persist/private/PersistenceManager.cpp \
+ $(areg_BASE)/persist/private/Property.cpp \
+ $(areg_BASE)/persist/private/PropertyKey.cpp \
+ $(areg_BASE)/persist/private/PropertyValue.cpp \
diff --git a/framework/areg/resources/areg.init b/framework/areg/resources/areg.init
index 6deab6080..20fa4209d 100644
--- a/framework/areg/resources/areg.init
+++ b/framework/areg/resources/areg.init
@@ -63,6 +63,8 @@
# Meaning of Layout format:
# The Layout Format is relevant only when logs the messages in the plain text file.
# The Layout Format specification fields are following:
+ %a -- outputs the ID of a logging object set by the logger.
+ %b -- outputs the module name of the logging object.
# %c -- output tick-count value since process start
# %d -- output day and time data
# %e -- output module (process) ID
@@ -108,13 +110,13 @@ config::*::version = 2.0.0
log::*::version = 2.0.0 # Logging version
log::*::target = remote | file | debug | db # Log targets: remote, file, debug output, database
log::*::enable = true # Global logging enable / disable flag
-log::*::enable::remote = false # Remote logging enable / disable flag
+log::*::enable::remote = true # Remote logging enable / disable flag
log::*::enable::file = true # File logging enable / disable flag
log::*::enable::debug = false # Debug output console logging enable / disable flag
log::*::enable::db = false # Database logging enable / disable flag
log::*::file::location = ./logs/%appname%_%time%.log # Log file location and masks
log::*::file::append = false # Append logs at the end of file
-log::*::remote::stack = 100 # Queue stack size in remote logging, 0 means no queuing
+log::*::remote::queue = 100 # Queue stack size in remote logging, 0 means no queuing
log::*::remote::service = logger # The service name of the remote logging
# ---------------------------------------------------------------------------
@@ -132,9 +134,16 @@ log::*::db::name = # Database name
# ---------------------------------------------------------------------------
# Log message layout in the file
# ---------------------------------------------------------------------------
-log::*::layout::enter = %d: [ %t %x.%z: Enter -->]%n # Enter scope layout
-log::*::layout::message = %d: [ %t %p >>> ] %m%n # Log message layout
-log::*::layout::exit = %d: [ %t %x.%z: Exit <-- ]%n # Exit scope layout
+log::*::layout::enter = %d: [ %t %x.%z: Enter -->]%n # Enter scope layout
+log::*::layout::message = %d: [ %t %p >>> ] %m%n # Log message layout
+log::*::layout::exit = %d: [ %t %x.%z: Exit <-- ]%n # Exit scope layout
+
+# ---------------------------------------------------------------------------
+# Message layout for logger
+# ---------------------------------------------------------------------------
+log::logger::layout::enter = %d: [ %a.%b.%t.%z: Enter -->]%n # Enter scope layout
+log::logger::layout::message= %d: [ %a.%b.%t.%p >>> ] %m%n # Log message layout
+log::logger::layout::exit = %d: [ %a.%b.%t.%z: Exit <-- ]%n # Exit scope layout
# ###########################################################################
# Remote services
diff --git a/framework/areg/trace/NETrace.hpp b/framework/areg/trace/NETrace.hpp
index bb5daaed1..e80f2fa5d 100644
--- a/framework/areg/trace/NETrace.hpp
+++ b/framework/areg/trace/NETrace.hpp
@@ -45,6 +45,16 @@ class FileBase;
**/
namespace NETrace
{
+ //!< The list of the scopes. It is a pair, where the key is the ID of the scope
+ //!< and the value is the pointer to the scope.
+ using ScopeList = TEHashMap;
+
+ //!< Alias of the map position.
+ using SCOPEPOS = ScopeList::MAPPOS;
+
+ /**
+ * \brief The supported logging version
+ **/
constexpr std::string_view LOG_VERSION { "2.0.0" };
/**
@@ -200,26 +210,36 @@ namespace NETrace
AREG_API unsigned int makePriorities(const String& prioString);
/**
- * \brief NETrace::LOG_MESSAGE_BUFFER_SIZE
+ * \brief NETrace::LOG_MESSAGE_IZE
* The maximum size of text in log message
**/
- constexpr uint32_t LOG_MESSAGE_BUFFER_SIZE { 512 };
+ constexpr uint32_t LOG_MESSAGE_IZE { 512 };
/**
* \brief NETrace::LOG_NAMES_SIZE
* The maximum length of the names in logging objects
**/
- constexpr uint32_t LOG_NAMES_SIZE { LOG_MESSAGE_BUFFER_SIZE / 2 };
+ constexpr uint32_t LOG_NAMES_SIZE { 128 };
/**
- * \brief NETrace::eMessageType
+ * \brief NETrace::eLogMessageType
* The logging message type.
**/
- enum eMessageType : unsigned int
+ enum class eLogMessageType : unsigned char
{
- MsgUndefined = 0 //!< Undefined message type
- , MsgScopeEnter //!< Message entered scope
- , MsgScopeExit //!< Message exit scope
- , MsgText //!< Message text
+ LogMessageUndefined = 0 //!< The log origin is undefined.
+ , LogMessageScopeEnter = 1 //!< Indicates the begin of the logging scope.
+ , LogMessageText = 2 //!< Indicates the message to log.
+ , LogMessageScopeExit = 4 //!< Indicates the end of the logging scope.
+ };
+
+ /**
+ * \brief NETrace::eLogDataType
+ * The data type in the message log
+ **/
+ enum class eLogDataType : unsigned short
+ {
+ LogDataLocal = 0 //!< The message data is generated locally.
+ , LogDataRemote = 1 //!< The message data is prepared for remote logging.
};
/**
@@ -232,7 +252,7 @@ namespace NETrace
* \brief Initializes logging message of specified type.
* \param msgType The logging message type.
**/
- sLogMessage( NETrace::eMessageType msgType = NETrace::eMessageType::MsgUndefined );
+ sLogMessage( NETrace::eLogMessageType msgType = NETrace::eLogMessageType::LogMessageUndefined );
/**
* \brief Initializes logging message and sets specified data.
* \param msgType The logging message type.
@@ -240,7 +260,7 @@ namespace NETrace
* \param mstPrio The priority of logging message.
* \param message The message text to output on target. Can be empty.
**/
- sLogMessage(NETrace::eMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * message, unsigned int msgLen);
+ sLogMessage(NETrace::eLogMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * message, unsigned int msgLen);
/**
* \brief Copies data from given source.
* \param src The source to copy data.
@@ -253,17 +273,22 @@ namespace NETrace
**/
sLogMessage & operator = (const sLogMessage & src);
- NETrace::eMessageType logMsgType; //!< The type of the logging message.
- ITEM_ID logSource; //!< The ID of the source that generated logging message.
- ITEM_ID logTarget; //!< The ID of the target to send logging message, valid only in case of TCP/IP logging.
- ITEM_ID logCookie; //!< The cookie set by the networking service, i.e. the log collector. Valid only in case of TCP/IP logging.
- ITEM_ID logModuleId; //!< The ID of the process in the local machine.
- ITEM_ID logThreadId; //!< The ID the thread in the local process.
- TIME64 logTimestamp; //!< The timestamp of generated log.
- unsigned int logScopeId; //!< The ID of trace scope that generated log message
- NETrace::eLogPriority logMessagePrio; //!< The log message priority
- unsigned int logMessageLen; //!< The actual length of the log message
- char logMessage[LOG_MESSAGE_BUFFER_SIZE]; //!< The message text to output, with maximum NETrace::LOG_MESSAGE_BUFFER_SIZE characters
+ NETrace::eLogMessageType logMsgType; //!< The type of the logging message.
+ NETrace::eLogDataType logDataType; //!< The type of log message data.
+ NETrace::eLogPriority logMessagePrio; //!< The log message priority
+ ITEM_ID logSource; //!< The ID of the source that generated logging message.
+ ITEM_ID logTarget; //!< The ID of the target to send logging message, valid only in case of TCP/IP logging.
+ ITEM_ID logCookie; //!< The cookie set by the networking service, i.e. the log collector. Valid only in case of TCP/IP logging.
+ ITEM_ID logModuleId; //!< The ID of the process in the local machine.
+ ITEM_ID logThreadId; //!< The ID the thread in the local process.
+ TIME64 logTimestamp; //!< The timestamp of generated log.
+ unsigned int logScopeId; //!< The ID of trace scope that generated log message
+ unsigned int logMessageLen; //!< The actual length of the log message
+ char logMessage[LOG_MESSAGE_IZE];//!< The message text to output, with maximum NETrace::LOG_MESSAGE_IZE characters.
+ unsigned int logThreadLen; //!< The length of the thread name;
+ char logThread[LOG_NAMES_SIZE]; //!< The name of the thread that generated the log. Valid only for remote logging
+ unsigned int logModuleLen; //!< The length of the module name.
+ char logModule[LOG_NAMES_SIZE]; //!< The name of the module that generated the log. Valid only for remote logging.
};
/**
@@ -399,22 +424,19 @@ namespace NETrace
} eScopeList;
/**
- * \brief NETrace::eLogMessageType
- * Indicates the origin of the log.
+ * \brief Creates a network communication message to make a log.
+ * \param logMessage The message log structure.
+ * \param dataType The type of created data to set in the structure.
+ * \param srcCookie The source of cookie to set in the structure.
+ * \return Returns message object for network communication.
**/
- typedef enum E_LogMessageType : unsigned char
- {
- LogMessageUndefined //!< The log origin is undefined.
- , LogMessageScopeEnter //!< Indicates the begin of the logging scope.
- , LogMessageText //!< Indicates the message to log.
- , LogMessageScopeExit //!< Indicates the end of the logging scope.
- } eLogMessageType;
+ AREG_API RemoteMessage createLogMessage(const NETrace::sLogMessage& logMessage, NETrace::eLogDataType dataType, const ITEM_ID & srcCookie);
/**
- * \brief Creates a communication message to make a log.
- * \param logMessage The message to log.
+ * \brief Triggers an event to log the message, contained in the remote buffer.
+ * \param message The shared buffer with the information to log.
**/
- AREG_API RemoteMessage messageLog(const NETrace::sLogMessage & logMessage);
+ AREG_API void logMessage(const RemoteMessage& message);
/**
* \brief Creates a message for logging service to start registering application logging scopes.
@@ -429,12 +451,6 @@ namespace NETrace
**/
AREG_API RemoteMessage messageRegisterScopesEnd(const ITEM_ID & target);
- //!< The list of the scopes. It is a pair, where the key is the ID of the scope
- //!< and the value is the pointer to the scope.
- using ScopeList = TEHashMap;
- //!< Alias of the map position.
- using SCOPEPOS = ScopeList::MAPPOS;
-
/**
* \brief The maximum scope entries in one message.
**/
@@ -460,7 +476,6 @@ namespace NETrace
// NETrace namespace streamable types
//////////////////////////////////////////////////////////////////////////////
IMPLEMENT_STREAMABLE(NETrace::eLogPriority)
-IMPLEMENT_STREAMABLE(NETrace::eMessageType)
IMPLEMENT_STREAMABLE(NETrace::eScopeList)
IMPLEMENT_STREAMABLE(NETrace::eLogMessageType)
diff --git a/framework/areg/trace/private/DebugOutputLogger.cpp b/framework/areg/trace/private/DebugOutputLogger.cpp
index 5abd4078f..9e1c00c37 100644
--- a/framework/areg/trace/private/DebugOutputLogger.cpp
+++ b/framework/areg/trace/private/DebugOutputLogger.cpp
@@ -47,9 +47,9 @@ bool DebugOutputLogger::openLogger(void)
if (mIsOpened)
{
Process& curProcess = Process::getInstance();
- NETrace::sLogMessage logMsgHello(NETrace::eMessageType::MsgText, 0, NETrace::eLogPriority::PrioIgnoreLayout, nullptr, 0);
+ NETrace::sLogMessage logMsgHello(NETrace::eLogMessageType::LogMessageText, 0, NETrace::eLogPriority::PrioIgnoreLayout, nullptr, 0);
String::formatString( logMsgHello.logMessage
- , NETrace::LOG_MESSAGE_BUFFER_SIZE
+ , NETrace::LOG_MESSAGE_IZE
, LoggerBase::FOMAT_MESSAGE_HELLO.data()
, Process::getString(curProcess.getEnvironment())
, curProcess.getFullPath().getString()
@@ -70,9 +70,9 @@ void DebugOutputLogger::closeLogger(void)
if ( mIsOpened )
{
Process & curProcess = Process::getInstance();
- NETrace::sLogMessage logMsgGoodbye(NETrace::eMessageType::MsgText, 0, NETrace::eLogPriority::PrioIgnoreLayout, nullptr, 0);
+ NETrace::sLogMessage logMsgGoodbye(NETrace::eLogMessageType::LogMessageText, 0, NETrace::eLogPriority::PrioIgnoreLayout, nullptr, 0);
String::formatString( logMsgGoodbye.logMessage
- , NETrace::LOG_MESSAGE_BUFFER_SIZE
+ , NETrace::LOG_MESSAGE_IZE
, LoggerBase::FORMAT_MESSAGE_BYE.data()
, Process::getString(curProcess.getEnvironment())
, curProcess.getFullPath().getString()
@@ -93,15 +93,15 @@ void DebugOutputLogger::logMessage(const NETrace::sLogMessage & logMessage)
{
switch (logMessage.logMsgType)
{
- case NETrace::eMessageType::MsgText:
+ case NETrace::eLogMessageType::LogMessageText:
getLayoutMessage().logMessage(logMessage, static_cast(*this));
break;
- case NETrace::eMessageType::MsgScopeEnter:
+ case NETrace::eLogMessageType::LogMessageScopeEnter:
getLayoutEnterScope().logMessage(logMessage, static_cast(*this));
break;
- case NETrace::eMessageType::MsgScopeExit:
+ case NETrace::eLogMessageType::LogMessageScopeExit:
getLayoutExitScope().logMessage( logMessage, static_cast(*this) );
break;
diff --git a/framework/areg/trace/private/FileLogger.cpp b/framework/areg/trace/private/FileLogger.cpp
index dc4388745..5b50c5088 100644
--- a/framework/areg/trace/private/FileLogger.cpp
+++ b/framework/areg/trace/private/FileLogger.cpp
@@ -51,9 +51,9 @@ bool FileLogger::openLogger( void )
{
Process & curProcess = Process::getInstance();
- NETrace::sLogMessage logMsgHello(NETrace::eMessageType::MsgText, 0, NETrace::eLogPriority::PrioIgnoreLayout, nullptr, 0);
+ NETrace::sLogMessage logMsgHello(NETrace::eLogMessageType::LogMessageText, 0, NETrace::eLogPriority::PrioIgnoreLayout, nullptr, 0);
String::formatString( logMsgHello.logMessage
- , NETrace::LOG_MESSAGE_BUFFER_SIZE
+ , NETrace::LOG_MESSAGE_IZE
, LoggerBase::FOMAT_MESSAGE_HELLO.data()
, Process::getString(curProcess.getEnvironment())
, curProcess.getFullPath().getString()
@@ -76,9 +76,9 @@ void FileLogger::closeLogger(void)
if ( mLogFile.isOpened() )
{
Process & curProcess = Process::getInstance();
- NETrace::sLogMessage logMsgGoodbye(NETrace::eMessageType::MsgText, 0, NETrace::eLogPriority::PrioIgnoreLayout, nullptr, 0);
+ NETrace::sLogMessage logMsgGoodbye(NETrace::eLogMessageType::LogMessageText, 0, NETrace::eLogPriority::PrioIgnoreLayout, nullptr, 0);
String::formatString(logMsgGoodbye.logMessage
- , NETrace::LOG_MESSAGE_BUFFER_SIZE
+ , NETrace::LOG_MESSAGE_IZE
, LoggerBase::FORMAT_MESSAGE_BYE.data()
, Process::getString(curProcess.getEnvironment())
, curProcess.getFullPath().getString()
@@ -97,15 +97,15 @@ void FileLogger::logMessage( const NETrace::sLogMessage & logMessage )
{
switch (logMessage.logMsgType)
{
- case NETrace::eMessageType::MsgText:
+ case NETrace::eLogMessageType::LogMessageText:
getLayoutMessage().logMessage(logMessage, static_cast(mLogFile));
break;
- case NETrace::eMessageType::MsgScopeEnter:
+ case NETrace::eLogMessageType::LogMessageScopeEnter:
getLayoutEnterScope().logMessage( logMessage, static_cast(mLogFile) );
break;
- case NETrace::eMessageType::MsgScopeExit:
+ case NETrace::eLogMessageType::LogMessageScopeExit:
getLayoutExitScope().logMessage( logMessage, static_cast(mLogFile) );
break;
diff --git a/framework/areg/trace/private/LayoutManager.cpp b/framework/areg/trace/private/LayoutManager.cpp
index 762938db2..d901120d0 100644
--- a/framework/areg/trace/private/LayoutManager.cpp
+++ b/framework/areg/trace/private/LayoutManager.cpp
@@ -151,6 +151,14 @@ inline void LayoutManager::_createLayouts(char* layoutFormat)
}
break;
+ case NELogging::eLayouts::LayoutCookieId:
+ newLayout = DEBUG_NEW CookieLayoutId();
+ break;
+
+ case NELogging::eLayouts::LayoutCookieName:
+ newLayout = DEBUG_NEW CookieLayoutName();
+ break;
+
case NELogging::eLayouts::LayoutUndefined: // fall through
case NELogging::eLayouts::LayoutAnyText: // fall through
default:
diff --git a/framework/areg/trace/private/Layouts.cpp b/framework/areg/trace/private/Layouts.cpp
index 8fc093a38..bb97a460b 100644
--- a/framework/areg/trace/private/Layouts.cpp
+++ b/framework/areg/trace/private/Layouts.cpp
@@ -18,6 +18,8 @@
#include "areg/base/Thread.hpp"
#include "areg/base/NEUtilities.hpp"
+#include "areg/trace/private/TraceManager.hpp"
+
#include
//////////////////////////////////////////////////////////////////////////
@@ -96,7 +98,7 @@ void DayTimeLaytout::logMessage( const NETrace::sLogMessage & msgLog, IEOutStrea
//////////////////////////////////////////////////////////////////////////
ModuleIdLayout::ModuleIdLayout(void)
- : IELayout ( NELogging::eLayouts::LayoutExecutableId )
+ : IELayout ( NELogging::eLayouts::LayoutExecutableId )
{
}
@@ -112,17 +114,30 @@ ModuleIdLayout::ModuleIdLayout( ModuleIdLayout && /*src*/ ) noexcept
void ModuleIdLayout::logMessage( const NETrace::sLogMessage & msgLog, IEOutStream & stream ) const
{
+ static const ITEM_ID _moduleId{ Process::getInstance().getId() };
+#ifdef _BIT64
+ static const String _moduleName{ String::toString(static_cast(_moduleId), NEString::eRadix::RadixHexadecimal) };
+#else // _BIT32
+ static const String _moduleName{ String::toString(static_cast(_moduleId), NEString::eRadix::RadixHexadecimal) };
+#endif // _BIT64
+
if (msgLog.logModuleId != 0)
{
+ if (msgLog.logModuleId == _moduleId)
+ {
+ stream.write(reinterpret_cast(_moduleName.getBuffer()), _moduleName.getLength());
+ }
+ else
+ {
#ifdef _BIT64
- constexpr char fmt[]{ "0x%llX" };
+ constexpr char fmt[]{ "0x%llX" };
#else // _BIT32
- constexpr char fmt[]{ "0x%X" };
+ constexpr char fmt[]{ "0x%X" };
#endif // _BIT64
-
- char buffer[128];
- int len = String::formatString(buffer, 128, fmt, static_cast(msgLog.logModuleId));
- stream.write( reinterpret_cast(buffer), len > 0 ? len : 0 );
+ char buffer[128];
+ int len = String::formatString(buffer, 128, fmt, static_cast(msgLog.logModuleId));
+ stream.write(reinterpret_cast(buffer), len > 0 ? len : 0);
+ }
}
}
@@ -253,9 +268,11 @@ void ThreadIdLayout::logMessage( const NETrace::sLogMessage & msgLog, IEOutStrea
if ( msgLog.logThreadId != 0 )
{
#ifdef _BIT64
- constexpr char fmt[]{ "0x%016llX" };
+ // constexpr char fmt[]{ "0x%016llX" };
+ constexpr char fmt[]{ "%06llu" };
#else // _BIT32
- constexpr char fmt[]{ "0x%08X" };
+ // constexpr char fmt[]{ "0x%08X" };
+ constexpr char fmt[]{ "%06u" };
#endif // _BIT64
char buffer[128];
@@ -310,12 +327,30 @@ ThreadNameLayout::ThreadNameLayout( ThreadNameLayout && /*src*/ ) noexcept
void ThreadNameLayout::logMessage( const NETrace::sLogMessage & msgLog, IEOutStream & stream ) const
{
- static const String _unknownThread("Unknown Thread");
+ const char* name{ nullptr };
+ uint32_t len{ 0 };
- id_type id = static_cast(msgLog.logThreadId);
- Thread * thread = Thread::findThreadById( id );
- const String& name{ thread != nullptr ? thread->getName() : _unknownThread };
- stream.write( reinterpret_cast(name.getString()), name.getLength() );
+ if (msgLog.logDataType == NETrace::eLogDataType::LogDataLocal)
+ {
+ const String& thread{ Thread::getThreadName(static_cast(msgLog.logThreadId)) };
+ name = thread.getString();
+ len = thread.getLength();
+ }
+ else
+ {
+ name = msgLog.logThread;
+ len = msgLog.logThreadLen;
+ }
+
+ if (len != 0)
+ {
+ stream.write(reinterpret_cast(name), len);
+ }
+ else
+ {
+ static constexpr std::string_view _unknownThread{ "Unknown Thread" };
+ stream.write(reinterpret_cast(_unknownThread.data()), static_cast(_unknownThread.length()));
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -380,3 +415,82 @@ void AnyTextLayout::logMessage( const NETrace::sLogMessage & /*msgLog*/, IEOutSt
{
stream.write( reinterpret_cast(mTextMessage.getString()), mTextMessage.getLength() );
}
+
+//////////////////////////////////////////////////////////////////////////
+// CookieLayoutId class declaration
+//////////////////////////////////////////////////////////////////////////
+
+CookieLayoutId::CookieLayoutId(void)
+ : IELayout(NELogging::eLayouts::LayoutCookieId)
+{
+}
+
+CookieLayoutId::CookieLayoutId(const CookieLayoutId& src)
+ : IELayout(NELogging::eLayouts::LayoutCookieId)
+{
+}
+
+CookieLayoutId::CookieLayoutId(CookieLayoutId&& src) noexcept
+ : IELayout(NELogging::eLayouts::LayoutCookieId)
+{
+}
+
+void CookieLayoutId::logMessage(const NETrace::sLogMessage& msgLog, IEOutStream& stream) const
+{
+#ifdef _BIT64
+ constexpr char fmt[]{ "%03llu" };
+#else // _BIT32
+ constexpr char fmt[]{ "%03u" };
+#endif // _BIT64
+
+ char buffer[128];
+ int len = String::formatString(buffer, 128, fmt, static_cast(msgLog.logCookie));
+ stream.write(reinterpret_cast(buffer), len > 0 ? len : 0);
+}
+
+//////////////////////////////////////////////////////////////////////////
+// CookieLayoutName class declaration
+//////////////////////////////////////////////////////////////////////////
+
+CookieLayoutName::CookieLayoutName(void)
+ : IELayout(NELogging::eLayouts::LayoutCookieName)
+{
+}
+
+CookieLayoutName::CookieLayoutName(const AnyTextLayout& src)
+ : IELayout(NELogging::eLayouts::LayoutCookieName)
+{
+}
+
+CookieLayoutName::CookieLayoutName(AnyTextLayout&& src) noexcept
+ : IELayout(NELogging::eLayouts::LayoutCookieName)
+{
+}
+
+void CookieLayoutName::logMessage(const NETrace::sLogMessage& msgLog, IEOutStream& stream) const
+{
+ static constexpr std::string_view _unknown{ "Unknown Instance" };
+
+ if (msgLog.logCookie == NEService::COOKIE_UNKNOWN)
+ {
+ stream.write(reinterpret_cast(_unknown.data()), static_cast(_unknown.size()));
+ }
+ else if (msgLog.logCookie == NEService::COOKIE_LOCAL)
+ {
+ static const String& _module{ Process::getInstance().getAppName() };
+ stream.write(reinterpret_cast(_module.getString()), _module.getLength());
+ }
+ else
+ {
+ const char* name = msgLog.logModule;
+ uint32_t len = msgLog.logModuleLen;
+ if (len != 0)
+ {
+ stream.write(reinterpret_cast(name), len);
+ }
+ else
+ {
+ stream.write(reinterpret_cast(_unknown.data()), static_cast(_unknown.length()));
+ }
+ }
+}
diff --git a/framework/areg/trace/private/Layouts.hpp b/framework/areg/trace/private/Layouts.hpp
index fba819a81..013f55963 100644
--- a/framework/areg/trace/private/Layouts.hpp
+++ b/framework/areg/trace/private/Layouts.hpp
@@ -50,12 +50,14 @@ class IELayout;
class ThreadNameLayout;
class ScopeNameLayout;
class AnyTextLayout;
+ class CookieLayoutId;
+ class CookieLayoutName;
//////////////////////////////////////////////////////////////////////////
// IELayout interface declaration
//////////////////////////////////////////////////////////////////////////
/**
- * \brief The layout base interface extended by all layout objects.
+ * \brief The layout base interface to extend by all layout objects.
**/
class IELayout
{
@@ -318,7 +320,7 @@ class ModuleIdLayout : public IELayout
// MessageLayout class declaration
//////////////////////////////////////////////////////////////////////////
/**
- * \brief This layout outputs message data to the stream.
+ * \brief This layout outputs log message to the stream.
**/
class MessageLayout : public IELayout
{
@@ -384,7 +386,7 @@ class MessageLayout : public IELayout
// EndOfLineLayout class declaration
//////////////////////////////////////////////////////////////////////////
/**
- * \brief This layout prints end-of-line data at the end of message.
+ * \brief This layout prints end-of-line data at current position of cursor.
**/
class EndOfLineLayout : public IELayout
{
@@ -516,7 +518,7 @@ class PriorityLayout : public IELayout
// ScopeIdLayout class declaration
//////////////////////////////////////////////////////////////////////////
/**
- * \brief This layout outputs the information of scope ID in the message.
+ * \brief This layout outputs the information of scope ID in the streamming object.
**/
class ScopeIdLayout : public IELayout
{
@@ -582,7 +584,7 @@ class ScopeIdLayout : public IELayout
// ThreadIdLayout class declaration
//////////////////////////////////////////////////////////////////////////
/**
- * \brief This layout outputs the information of thread ID, which generated logging message.
+ * \brief This layout outputs thread ID in the streaming object.
**/
class ThreadIdLayout : public IELayout
{
@@ -648,7 +650,7 @@ class ThreadIdLayout : public IELayout
// ModuleNameLayout class declaration
//////////////////////////////////////////////////////////////////////////
/**
- * \brief This layout outputs the name of running module (process) in the message.
+ * \brief This layout outputs the name of the thread, which logs message.
**/
class ModuleNameLayout : public IELayout
{
@@ -780,7 +782,7 @@ class ThreadNameLayout : public IELayout
// ScopeNameLayout class declaration
//////////////////////////////////////////////////////////////////////////
/**
- * \brief This layout output information of scope name in the logging message.
+ * \brief This layout outputs scope name in the streaming object.
**/
class ScopeNameLayout : public IELayout
{
@@ -846,7 +848,7 @@ class ScopeNameLayout : public IELayout
// AnyTextLayout class declaration
//////////////////////////////////////////////////////////////////////////
/**
- * \brief This layout outputs any text message as it is without formating.
+ * \brief This layout outputs any text message as it is without formating in the streaming object.
**/
class AnyTextLayout : public IELayout
{
@@ -929,6 +931,138 @@ class AnyTextLayout : public IELayout
String mTextMessage;
};
+//////////////////////////////////////////////////////////////////////////
+// CookieLayoutId class declaration
+//////////////////////////////////////////////////////////////////////////
+/**
+ * \brief This layout outputs the cookie ID of the source log message module.
+ **/
+class CookieLayoutId : public IELayout
+{
+//////////////////////////////////////////////////////////////////////////
+// Constructors / Destructor
+//////////////////////////////////////////////////////////////////////////
+public:
+ /**
+ * \brief Sets layout type value.
+ **/
+ CookieLayoutId( void );
+
+ /**
+ * \brief Copies data from given source.
+ * \param src The source of data to copy.
+ **/
+ CookieLayoutId( const CookieLayoutId& src );
+
+ /**
+ * \brief Moves data from given source.
+ * \param src The source of data to move.
+ **/
+ CookieLayoutId(CookieLayoutId&& src ) noexcept;
+
+ /**
+ * \brief Destructor
+ **/
+ virtual ~CookieLayoutId( void ) = default;
+
+//////////////////////////////////////////////////////////////////////////
+// Operators
+//////////////////////////////////////////////////////////////////////////
+public:
+ /**
+ * \brief Copies data from given source.
+ * \param src The source of data to copy.
+ **/
+ inline CookieLayoutId & operator = ( const CookieLayoutId& src );
+
+ /**
+ * \brief Moves data from given source.
+ * \param src The source of data to move.
+ **/
+ inline CookieLayoutId & operator = ( CookieLayoutId&& src ) noexcept;
+
+//////////////////////////////////////////////////////////////////////////
+// Operations
+//////////////////////////////////////////////////////////////////////////
+
+/************************************************************************/
+// IELayout interface overrides
+/************************************************************************/
+
+ /**
+ * \brief Makes layout specific formated text output of give message to the streaming object.
+ * \param msgLog The log message data structure that contains information to output message.
+ * \param stream The streaming object, where the text message should be written.
+ **/
+ virtual void logMessage( const NETrace::sLogMessage & msgLog, IEOutStream & stream ) const override;
+};
+
+//////////////////////////////////////////////////////////////////////////
+// CookieLayoutName class declaration
+//////////////////////////////////////////////////////////////////////////
+/**
+ * \brief This layout outputs the name of the source log message module.
+ **/
+class CookieLayoutName : public IELayout
+{
+//////////////////////////////////////////////////////////////////////////
+// Constructors / Destructor
+//////////////////////////////////////////////////////////////////////////
+public:
+ /**
+ * \brief Sets layout type value.
+ **/
+ CookieLayoutName( void );
+
+ /**
+ * \brief Copies data from given source.
+ * \param src The source of data to copy.
+ **/
+ CookieLayoutName( const AnyTextLayout & src );
+
+ /**
+ * \brief Moves data from given source.
+ * \param src The source of data to move.
+ **/
+ CookieLayoutName( AnyTextLayout && src ) noexcept;
+
+ /**
+ * \brief Destructor
+ **/
+ virtual ~CookieLayoutName( void ) = default;
+
+//////////////////////////////////////////////////////////////////////////
+// Operators
+//////////////////////////////////////////////////////////////////////////
+public:
+ /**
+ * \brief Copies data from given source.
+ * \param src The source of data to copy.
+ **/
+ inline CookieLayoutName& operator = ( const CookieLayoutName& src );
+
+ /**
+ * \brief Moves data from given source.
+ * \param src The source of data to move.
+ **/
+ inline CookieLayoutName& operator = (CookieLayoutName&& src ) noexcept;
+
+//////////////////////////////////////////////////////////////////////////
+// Operations
+//////////////////////////////////////////////////////////////////////////
+
+/************************************************************************/
+// IELayout interface overrides
+/************************************************************************/
+
+ /**
+ * \brief Makes layout specific formated text output of give message to the streaming object.
+ * \param msgLog The log message data structure that contains information to output message.
+ * \param stream The streaming object, where the text message should be written.
+ **/
+ virtual void logMessage( const NETrace::sLogMessage & msgLog, IEOutStream & stream ) const override;
+};
+
//////////////////////////////////////////////////////////////////////////
// Inline methods
//////////////////////////////////////////////////////////////////////////
@@ -1134,4 +1268,32 @@ inline AnyTextLayout & AnyTextLayout::operator = ( AnyTextLayout && src ) noexce
return (*this);
}
+//////////////////////////////////////////////////////////////////////////
+// CookieLayoutId class inline methods
+//////////////////////////////////////////////////////////////////////////
+
+inline CookieLayoutId& CookieLayoutId::operator=(const CookieLayoutId& src)
+{
+ return (*this);
+}
+
+inline CookieLayoutId& CookieLayoutId::operator=(CookieLayoutId&& src) noexcept
+{
+ return (*this);
+}
+
+//////////////////////////////////////////////////////////////////////////
+// CookieLayoutId class inline methods
+//////////////////////////////////////////////////////////////////////////
+
+inline CookieLayoutName& CookieLayoutName::operator=(const CookieLayoutName& src)
+{
+ return (*this);
+}
+
+inline CookieLayoutName& CookieLayoutName::operator=(CookieLayoutName&& src) noexcept
+{
+ return (*this);
+}
+
#endif // AREG_TRACE_PRIVATE_LAYOUTS_HPP
diff --git a/framework/areg/trace/private/LogMessage.cpp b/framework/areg/trace/private/LogMessage.cpp
index 744726b7d..4eca9b01d 100644
--- a/framework/areg/trace/private/LogMessage.cpp
+++ b/framework/areg/trace/private/LogMessage.cpp
@@ -24,17 +24,14 @@
#include
-LogMessage::LogMessage(NETrace::eMessageType msgType, const TraceScope & traceScope )
+LogMessage::LogMessage(NETrace::eLogMessageType msgType, const TraceScope & traceScope )
: NETrace::sLogMessage( msgType, traceScope.getScopeId(), NETrace::PrioScope, traceScope.getScopeName().getString(), traceScope.getScopeName( ).getLength() )
{
- ASSERT( (msgType == NETrace::eMessageType::MsgScopeEnter) || (msgType == NETrace::eMessageType::MsgScopeExit) );
+ ASSERT( (msgType == NETrace::eLogMessageType::LogMessageScopeEnter) || (msgType == NETrace::eLogMessageType::LogMessageScopeExit) );
}
void LogMessage::setMessage(const char * message, int msgLen )
{
- if ( (message != nullptr) && (msgLen > 0) )
- {
- int len = NEMemory::memCopy( this->logMessage, NETrace::LOG_MESSAGE_BUFFER_SIZE - 1, message, msgLen);
- this->logMessage[len] = String::EmptyChar;
- }
+ uint32_t len = NEMemory::memCopy(this->logMessage, NETrace::LOG_MESSAGE_IZE - 1, message, msgLen);
+ this->logMessage[len] = String::EmptyChar;
}
diff --git a/framework/areg/trace/private/LogMessage.hpp b/framework/areg/trace/private/LogMessage.hpp
index d445abe3b..6077c68bd 100644
--- a/framework/areg/trace/private/LogMessage.hpp
+++ b/framework/areg/trace/private/LogMessage.hpp
@@ -55,7 +55,7 @@ class LogMessage : public NETrace::sLogMessage
* \brief Initializes message log structure and sets the logging type value.
* \param msgType The type of message to initialize
**/
- inline explicit LogMessage( NETrace::eMessageType msgType );
+ inline explicit LogMessage( NETrace::eLogMessageType msgType );
/**
* \brief Initializes message log structure, sets the logging type value,
@@ -65,7 +65,7 @@ class LogMessage : public NETrace::sLogMessage
* \param msgPrio The priority of message to log
* \param message The text message to log
**/
- inline LogMessage(NETrace::eMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const String & message );
+ inline LogMessage(NETrace::eLogMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const String & message );
/**
* \brief Initializes message log structure, sets the logging type value,
@@ -76,7 +76,7 @@ class LogMessage : public NETrace::sLogMessage
* \param message The text message to log.
* \param msgLen The length of the message to log.
**/
- inline LogMessage( NETrace::eMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * message, unsigned int msgLen );
+ inline LogMessage( NETrace::eLogMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * message, unsigned int msgLen );
/**
* \brief Initializes message log structure for scope enter or exit event.
@@ -85,7 +85,7 @@ class LogMessage : public NETrace::sLogMessage
* It is either to enter or exit scope.
* \param traceScope The trace scope object, which contains ID and trace scope name is set as text.
**/
- LogMessage( NETrace::eMessageType msgType, const TraceScope & traceScope );
+ LogMessage( NETrace::eLogMessageType msgType, const TraceScope & traceScope );
/**
* \brief Copies logging message data from given source.
@@ -117,7 +117,7 @@ class LogMessage : public NETrace::sLogMessage
/**
* \brief Returns log type value
**/
- inline NETrace::eMessageType getMessageType( void ) const;
+ inline NETrace::eLogMessageType getMessageType( void ) const;
/**
* \brief Return the ID of thread where the message was initialized
@@ -195,17 +195,17 @@ class LogMessage : public NETrace::sLogMessage
//////////////////////////////////////////////////////////////////////////
// LogMessage class inline methods
//////////////////////////////////////////////////////////////////////////
-inline LogMessage::LogMessage( NETrace::eMessageType msgType )
+inline LogMessage::LogMessage( NETrace::eLogMessageType msgType )
: NETrace::sLogMessage(msgType)
{
}
-inline LogMessage::LogMessage( NETrace::eMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const String & message )
+inline LogMessage::LogMessage( NETrace::eLogMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const String & message )
: NETrace::sLogMessage( msgType, scopeId, msgPrio, message.getString(), message.getLength() )
{
}
-inline LogMessage::LogMessage( NETrace::eMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * message, unsigned int msgLen )
+inline LogMessage::LogMessage( NETrace::eLogMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * message, unsigned int msgLen )
: NETrace::sLogMessage( msgType, scopeId, msgPrio, message, msgLen )
{
}
@@ -221,7 +221,7 @@ inline const NETrace::sLogMessage & LogMessage::getLogData(void) const
return static_cast(*this);
}
-inline NETrace::eMessageType LogMessage::getMessageType(void) const
+inline NETrace::eLogMessageType LogMessage::getMessageType(void) const
{
return this->logMsgType;
}
diff --git a/framework/areg/trace/private/NELogging.hpp b/framework/areg/trace/private/NELogging.hpp
index 82db6d6dd..dad34073a 100644
--- a/framework/areg/trace/private/NELogging.hpp
+++ b/framework/areg/trace/private/NELogging.hpp
@@ -75,6 +75,8 @@ namespace NELogging
LayoutUndefined = 0 //!< Undefined specifier, no layout is created
, LayoutAnyText = 1 //!< Create any text layout to output message without formating
+ , LayoutCookieId = 'a' //!< Create layout to output the cookie id of the log message source module
+ , LayoutCookieName = 'b' //!< Create layout to output the name of the log message source module
, LayoutTickCount = 'c' //!< Create layout to output tick-count value since process start
, LayoutDayTime = 'd' //!< Create layout to output day and time data
, LayoutExecutableId = 'e' //!< Create layout to output module ID
diff --git a/framework/areg/trace/private/NETrace.cpp b/framework/areg/trace/private/NETrace.cpp
index 67f235036..05647bb66 100644
--- a/framework/areg/trace/private/NETrace.cpp
+++ b/framework/areg/trace/private/NETrace.cpp
@@ -30,7 +30,7 @@
namespace
{
- const NEMemory::sRemoteMessage & _getLogRegisterScopes(void)
+ const NEMemory::sRemoteMessage & _getLogRegisterScopes(void)
{
static constexpr NEMemory::sRemoteMessage _messageRegisterScopes
{
@@ -81,8 +81,10 @@ namespace
}
}
-NETrace::sLogMessage::sLogMessage(NETrace::eMessageType msgType)
- : logMsgType { msgType}
+NETrace::sLogMessage::sLogMessage(NETrace::eLogMessageType msgType)
+ : logMsgType { msgType }
+ , logDataType { NETrace::eLogDataType::LogDataLocal }
+ , logMessagePrio{ NETrace::eLogPriority::PrioNotset }
, logSource { NEService::COOKIE_LOCAL }
, logTarget { NEService::COOKIE_LOGGER }
, logCookie { NEService::COOKIE_LOCAL }
@@ -90,14 +92,19 @@ NETrace::sLogMessage::sLogMessage(NETrace::eMessageType msgType)
, logThreadId { Thread::INVALID_THREAD_ID }
, logTimestamp { DateTime::INVALID_TIME }
, logScopeId { NETrace::TRACE_SCOPE_ID_NONE }
- , logMessagePrio{ NETrace::eLogPriority::PrioNotset }
, logMessageLen { 0 }
- , logMessage {'\0'}
+ , logMessage { '\0' }
+ , logThreadLen { 0 }
+ , logThread { '\0' }
+ , logModuleLen { 0 }
+ , logModule { '\0' }
{
}
-NETrace::sLogMessage::sLogMessage(NETrace::eMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * message, unsigned int msgLen)
+NETrace::sLogMessage::sLogMessage(NETrace::eLogMessageType msgType, unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * message, unsigned int msgLen)
: logMsgType { msgType }
+ , logDataType { NETrace::eLogDataType::LogDataLocal }
+ , logMessagePrio{ msgPrio }
, logSource { NEService::COOKIE_LOCAL }
, logTarget { NEService::COOKIE_LOGGER }
, logCookie { TraceManager::getConnectionCookie() }
@@ -105,16 +112,21 @@ NETrace::sLogMessage::sLogMessage(NETrace::eMessageType msgType, unsigned int sc
, logThreadId { Thread::getCurrentThreadId() }
, logTimestamp { DateTime::getNow() }
, logScopeId { scopeId }
- , logMessagePrio{ msgPrio }
, logMessageLen { msgLen }
, logMessage { '\0' }
+ , logThreadLen { 0 }
+ , logThread { '\0' }
+ , logModuleLen { 0 }
+ , logModule { '\0' }
{
- int len = NEMemory::memCopy(logMessage, NETrace::LOG_MESSAGE_BUFFER_SIZE - 1, message, msgLen);
+ uint32_t len = NEMemory::memCopy(logMessage, NETrace::LOG_MESSAGE_IZE - 1, message, msgLen);
logMessage[len] = String::EmptyChar;
}
NETrace::sLogMessage::sLogMessage(const NETrace::sLogMessage & src)
: logMsgType { src.logMsgType }
+ , logDataType { src.logDataType }
+ , logMessagePrio{ src.logMessagePrio }
, logSource { src.logSource }
, logTarget { src.logTarget }
, logCookie { src.logCookie }
@@ -122,11 +134,14 @@ NETrace::sLogMessage::sLogMessage(const NETrace::sLogMessage & src)
, logThreadId { src.logThreadId }
, logTimestamp { src.logTimestamp }
, logScopeId { src.logScopeId }
- , logMessagePrio{ src.logMessagePrio }
, logMessageLen { src.logMessageLen }
, logMessage { '\0' }
+ , logThreadLen { 0 }
+ , logThread { '\0' }
+ , logModuleLen { 0 }
+ , logModule { '\0' }
{
- int len = NEMemory::memCopy(logMessage, NETrace::LOG_MESSAGE_BUFFER_SIZE - 1, src.logMessage, src.logMessageLen);
+ uint32_t len = NEMemory::memCopy(logMessage, NETrace::LOG_MESSAGE_IZE - 1, src.logMessage, src.logMessageLen);
logMessage[len] = String::EmptyChar;
}
@@ -134,17 +149,23 @@ NETrace::sLogMessage & NETrace::sLogMessage::operator = (const NETrace::sLogMess
{
if (this != &src)
{
- logMsgType = src.logMsgType;
- logSource = src.logSource;
- logTarget = src.logTarget;
- logCookie = src.logCookie;
- logModuleId = src.logModuleId;
- logThreadId = src.logThreadId;
- logTimestamp = src.logTimestamp;
- logScopeId = src.logScopeId;
- logMessagePrio= src.logMessagePrio;
- logMessageLen = src.logMessageLen;
- int len = NEMemory::memCopy(logMessage, NETrace::LOG_MESSAGE_BUFFER_SIZE - 1, src.logMessage, src.logMessageLen);
+ logMsgType = src.logMsgType;
+ logDataType = src.logDataType;
+ logMessagePrio = src.logMessagePrio;
+ logSource = src.logSource;
+ logTarget = src.logTarget;
+ logCookie = src.logCookie;
+ logModuleId = src.logModuleId;
+ logThreadId = src.logThreadId;
+ logTimestamp = src.logTimestamp;
+ logScopeId = src.logScopeId;
+ logMessageLen = src.logMessageLen;
+ logThreadLen = 0;
+ logThread[0] = String::EmptyChar;
+ logThreadLen = 0;
+ logModule[0] = String::EmptyChar;
+
+ uint32_t len = NEMemory::memCopy(logMessage, NETrace::LOG_MESSAGE_IZE - 1, src.logMessage, src.logMessageLen);
logMessage[len] = String::EmptyChar;
}
@@ -253,18 +274,39 @@ AREG_API_IMPL unsigned int NETrace::getScopePriority( const char * scopeName )
#endif // AREG_LOGS
}
-AREG_API_IMPL RemoteMessage NETrace::messageLog(const NETrace::sLogMessage & logMessage)
+AREG_API_IMPL RemoteMessage NETrace::createLogMessage(const NETrace::sLogMessage& logMessage, NETrace::eLogDataType dataType, const ITEM_ID& srcCookie)
{
RemoteMessage msgLog;
- if (msgLog.initMessage(_getLogMessage().rbHeader) != nullptr)
+ if (msgLog.initMessage(_getLogMessage().rbHeader, sizeof(NETrace::sLogMessage)) != nullptr)
{
- msgLog.setSource(NETrace::getCookie());
- msgLog << logMessage;
+ msgLog.write(reinterpret_cast(&logMessage), sizeof(NETrace::sLogMessage));
+ msgLog.setSource(srcCookie);
+ NETrace::sLogMessage* log = reinterpret_cast(msgLog.getBuffer());
+ log->logCookie = srcCookie;
+ log->logDataType = dataType;
+
+ if (NETrace::eLogDataType::LogDataLocal != dataType)
+ {
+ const String& threadName{ Thread::getThreadName(log->logThreadId) };
+ uint32_t len = NEMemory::memCopy(log->logThread, NETrace::LOG_NAMES_SIZE - 1, threadName.getString(), threadName.getLength());
+ log->logThreadLen = len;
+ log->logThread[len] = String::EmptyChar;
+
+ const String& module = Process::getInstance().getAppName();
+ len = NEMemory::memCopy(log->logModule, NETrace::LOG_NAMES_SIZE - 1, module.getString(), module.getLength());
+ log->logModuleLen = len;
+ log->logModule[len] = String::EmptyChar;
+ }
}
return msgLog;
}
+AREG_API_IMPL void NETrace::logMessage(const RemoteMessage& message)
+{
+ return TraceManager::logMessage(message);
+}
+
AREG_API_IMPL RemoteMessage NETrace::messageRegisterScopesStart(const ITEM_ID & target, unsigned int scopeCount)
{
RemoteMessage msgScope;
diff --git a/framework/areg/trace/private/NetTcpLogger.cpp b/framework/areg/trace/private/NetTcpLogger.cpp
index 9cf59429c..b4575fa7f 100644
--- a/framework/areg/trace/private/NetTcpLogger.cpp
+++ b/framework/areg/trace/private/NetTcpLogger.cpp
@@ -40,9 +40,9 @@ NetTcpLogger::NetTcpLogger(LogConfiguration & logConfig, ScopeController & scope
, IEServiceConnectionConsumer ( )
, IERemoteMessageHandler ( )
- , mScopeController (scopeController)
+ , mScopeController ( scopeController )
, mIsEnabled ( false )
- , mRingStack ( NEApplication::DEFAULT_LOG_QUEUE_SIZE, NECommon::eRingOverlap::ShiftOnOverlap)
+ , mRingStack ( logConfig.getStackSize(), NECommon::eRingOverlap::ShiftOnOverlap )
{
}
@@ -56,6 +56,8 @@ bool NetTcpLogger::openLogger(void)
mIsEnabled = false;
if (mLogConfiguration.isRemoteLoggingEnabled())
{
+ registerForServiceClientCommands();
+
String host{ mLogConfiguration.getRemoteTcpAddress()};
uint16_t port{ mLogConfiguration.getRemoteTcpPort() };
mIsEnabled = true;
@@ -81,21 +83,21 @@ void NetTcpLogger::closeLogger(void)
{
disconnectServiceHost();
mRingStack.clear();
+ unregisterForServiceClientCommands();
}
void NetTcpLogger::logMessage(const NETrace::sLogMessage& logMessage)
{
if (mIsEnabled)
{
- RemoteMessage log(NETrace::messageLog(logMessage));
-
if (isConnectedState())
{
- sendMessage(log, Event::eEventPriority::EventPriorityNormal);
+ ASSERT(mChannel.isValid());
+ sendMessage(NETrace::createLogMessage(logMessage, NETrace::eLogDataType::LogDataRemote, mChannel.getCookie()), Event::eEventPriority::EventPriorityNormal);
}
else
{
- mRingStack.pushLast(log);
+ mRingStack.pushLast(NETrace::createLogMessage(logMessage, NETrace::eLogDataType::LogDataRemote, mChannel.getCookie()));
}
}
}
@@ -109,31 +111,30 @@ bool NetTcpLogger::isLoggerOpened(void) const
void NetTcpLogger::connectedRemoteServiceChannel(const Channel & channel)
{
ASSERT(channel.isValid());
- ASSERT(channel.getSource() == NEService::COOKIE_LOGGER);
ASSERT(channel.getCookie() >= NEService::COOKIE_REMOTE_SERVICE);
+ ASSERT(mChannel.isValid());
mIsEnabled = true;
- mChannel = channel;
- mClientConnection.setCookie(channel.getCookie());
-
+ const ITEM_ID& cookie = channel.getCookie();
while (mRingStack.isEmpty() == false)
{
- RemoteMessage msg{ mRingStack.popFirst() };
- msg.setSource(channel.getCookie());
- sendMessage(msg, Event::eEventPriority::EventPriorityNormal);
+ RemoteMessage msgLog{ mRingStack.popFirst() };
+ msgLog.setSource(cookie);
+ reinterpret_cast(msgLog.getBuffer())->logCookie = cookie;
+ sendMessage(msgLog, Event::eEventPriority::EventPriorityNormal);
}
}
void NetTcpLogger::disconnectedRemoteServiceChannel(const Channel & channel)
{
+ ASSERT(mChannel.isValid() == false);
mIsEnabled = false;
- mChannel.invalidate();
mClientConnection.setCookie(NEService::COOKIE_UNKNOWN);
}
void NetTcpLogger::lostRemoteServiceChannel(const Channel & channel)
{
- mChannel.invalidate();
+ ASSERT(mChannel.isValid() == false);
mClientConnection.setCookie(NEService::COOKIE_UNKNOWN);
}
@@ -153,14 +154,53 @@ void NetTcpLogger::processReceivedMessage(const RemoteMessage & msgReceived, Soc
{
if (msgReceived.isValid() && whichSource.isValid())
{
- ASSERT(msgReceived.getTarget() == mChannel.getCookie());
-
- const NEService::eFuncIdRange msgId { static_cast(msgReceived.getMessageId()) };
- ITEM_ID target{ NEService::COOKIE_ANY };
- msgReceived >> target;
-
+ NEService::eFuncIdRange msgId = static_cast(msgReceived.getMessageId());
switch (msgId)
{
+ case NEService::eFuncIdRange::SystemServiceNotifyConnection:
+ {
+ NEService::eServiceConnection connection = NEService::eServiceConnection::ServiceConnectionUnknown;
+ ITEM_ID cookie = NEService::COOKIE_UNKNOWN;
+ msgReceived >> connection;
+ msgReceived >> cookie;
+
+ switch (connection)
+ {
+ case NEService::eServiceConnection::ServiceConnected:
+ case NEService::eServiceConnection::ServicePending:
+ {
+ if (msgReceived.getResult() == NEMemory::MESSAGE_SUCCESS)
+ {
+ Lock lock(mLock);
+ ASSERT(cookie == msgReceived.getTarget());
+ mClientConnection.setCookie(cookie);
+ sendCommand(ServiceEventData::eServiceEventCommands::CMD_ServiceStarted);
+ }
+ else
+ {
+ cancelConnection();
+ sendCommand(ServiceEventData::eServiceEventCommands::CMD_ServiceLost);
+ }
+ }
+ break;
+
+ case NEService::eServiceConnection::ServiceConnectionLost:
+ {
+ cancelConnection();
+ sendCommand(ServiceEventData::eServiceEventCommands::CMD_ServiceLost);
+ }
+ break;
+
+ default:
+ {
+ cancelConnection();
+ sendCommand(ServiceEventData::eServiceEventCommands::CMD_ServiceStopped);
+ }
+ break;
+ }
+ }
+ break;
+
case NEService::eFuncIdRange::ServiceLogUpdateScopes:
{
uint32_t scopeCount{ 0 };
diff --git a/framework/areg/trace/private/NetTcpLogger.hpp b/framework/areg/trace/private/NetTcpLogger.hpp
index bf50d58be..1d006c7cd 100644
--- a/framework/areg/trace/private/NetTcpLogger.hpp
+++ b/framework/areg/trace/private/NetTcpLogger.hpp
@@ -60,7 +60,7 @@ class NetTcpLogger : public LoggerBase
using RingStack = TENolockRingStack;
//!< A prefix to add in front of thread and timer names.
- static constexpr std::string_view PREFIX_THREAD{ "logger" };
+ static constexpr std::string_view PREFIX_THREAD{ "logger_" };
//////////////////////////////////////////////////////////////////////////
// Constructor / Destructor
diff --git a/framework/areg/trace/private/ScopeNodeBase.cpp b/framework/areg/trace/private/ScopeNodeBase.cpp
index af83caa3b..b98107237 100644
--- a/framework/areg/trace/private/ScopeNodeBase.cpp
+++ b/framework/areg/trace/private/ScopeNodeBase.cpp
@@ -194,8 +194,8 @@ String ScopeNodeBase::makeConfigString( const String & parent ) const
{
if (isValid())
{
- char scope[NETrace::LOG_MESSAGE_BUFFER_SIZE];
- int len = String::formatString(scope, NETrace::LOG_MESSAGE_BUFFER_SIZE, "%s%s", parent.getString(), mNodeName.getString());
+ char scope[NETrace::LOG_MESSAGE_IZE];
+ int len = String::formatString(scope, NETrace::LOG_MESSAGE_IZE, "%s%s", parent.getString(), mNodeName.getString());
return String(scope, len > 0 ? len : 0);
}
else
diff --git a/framework/areg/trace/private/ScopeNodes.cpp b/framework/areg/trace/private/ScopeNodes.cpp
index 4f37b681a..6c4557573 100644
--- a/framework/areg/trace/private/ScopeNodes.cpp
+++ b/framework/areg/trace/private/ScopeNodes.cpp
@@ -185,8 +185,8 @@ String ScopeNode::makeScopePath( const String & prefix ) const
{
ASSERT(mNodeName.isEmpty() == false);
ASSERT(isValid());
- char scope[NETrace::LOG_MESSAGE_BUFFER_SIZE];
- int len = String::formatString(scope, NETrace::LOG_MESSAGE_BUFFER_SIZE, "%s%s%c", prefix.getString(), mNodeName.getString(), NELogging::SYNTAX_SCOPE_SEPARATOR);
+ char scope[NETrace::LOG_MESSAGE_IZE];
+ int len = String::formatString(scope, NETrace::LOG_MESSAGE_IZE, "%s%s%c", prefix.getString(), mNodeName.getString(), NELogging::SYNTAX_SCOPE_SEPARATOR);
return String(scope, len > 0 ? len : 0);
}
@@ -295,8 +295,8 @@ unsigned int ScopeNode::groupRecursive( void )
String ScopeNode::makeConfigString( const String & parent ) const
{
- char scope[NETrace::LOG_MESSAGE_BUFFER_SIZE];
- int len = String::formatString( scope, NETrace::LOG_MESSAGE_BUFFER_SIZE
+ char scope[NETrace::LOG_MESSAGE_IZE];
+ int len = String::formatString( scope, NETrace::LOG_MESSAGE_IZE
, "%s%s%c%c"
, parent.getString()
, mNodeName.getString()
diff --git a/framework/areg/trace/private/TraceEvent.cpp b/framework/areg/trace/private/TraceEvent.cpp
index 8246da7b8..3b3693b07 100644
--- a/framework/areg/trace/private/TraceEvent.cpp
+++ b/framework/areg/trace/private/TraceEvent.cpp
@@ -21,6 +21,13 @@
#include
+namespace
+{
+ constexpr const uint32_t _logMessageSize{ static_cast(sizeof(NETrace::sLogMessage)) };
+ constexpr const uint32_t _logNamesSize{ static_cast(NETrace::LOG_NAMES_SIZE * 2) };
+ constexpr const uint32_t _logLocalMessage{ _logMessageSize - _logNamesSize };
+}
+
TraceEventData::TraceEventData( void )
: mAction ( TraceEventData::eTraceAction::TraceUndefined )
, mDataBuffer ( )
@@ -39,11 +46,10 @@ TraceEventData::TraceEventData( TraceEventData::eTraceAction action, const Share
{
}
-TraceEventData::TraceEventData( TraceEventData::eTraceAction action, const LogMessage & logData )
+TraceEventData::TraceEventData( TraceEventData::eTraceAction action, const NETrace::sLogMessage & logData )
: mAction ( action )
- , mDataBuffer ( )
+ , mDataBuffer (_logMessageSize, reinterpret_cast(&logData), _logLocalMessage)
{
- mDataBuffer << logData;
}
TraceEventData::TraceEventData( const TraceEventData & src )
diff --git a/framework/areg/trace/private/TraceEvent.hpp b/framework/areg/trace/private/TraceEvent.hpp
index 117f8d067..5996403c5 100644
--- a/framework/areg/trace/private/TraceEvent.hpp
+++ b/framework/areg/trace/private/TraceEvent.hpp
@@ -25,6 +25,10 @@
* Dependencies
************************************************************************/
class LogMessage;
+namespace NETrace
+{
+ struct sLogMessage;
+}
//////////////////////////////////////////////////////////////////////////
// TraceEventData class declaration
@@ -56,8 +60,8 @@ class AREG_API TraceEventData
, TraceSetDisableLogs //!< Action to notify to stop logging
, TraceSaveScopes //!< Action to notify to save scope list
, TraceLogMessage //!< Action to output logging message
- , TraceUpdateScopes
- , TraceQueryScopes
+ , TraceUpdateScopes //!< Action to update scope priorities
+ , TraceQueryScopes //!< Action to send the list of scopes.
} eTraceAction;
/**
@@ -92,7 +96,7 @@ class AREG_API TraceEventData
* \param action The action ID to set in event data
* \param logData The buffer of logging message data set.
**/
- TraceEventData( TraceEventData::eTraceAction action, const LogMessage & logData );
+ TraceEventData( TraceEventData::eTraceAction action, const NETrace::sLogMessage & logData );
/**
* \brief Copies logging event data from given source.
@@ -194,6 +198,8 @@ inline const char * TraceEventData::getString( TraceEventData::eTraceAction acti
CASE_MAKE_STRING(TraceEventData::eTraceAction::TraceSetDisableLogs);
CASE_MAKE_STRING(TraceEventData::eTraceAction::TraceSaveScopes);
CASE_MAKE_STRING(TraceEventData::eTraceAction::TraceLogMessage);
+ CASE_MAKE_STRING(TraceEventData::eTraceAction::TraceUpdateScopes);
+ CASE_MAKE_STRING(TraceEventData::eTraceAction::TraceQueryScopes);
CASE_DEFAULT("ERR: Undefined TraceEventData::eTraceAction value!");
}
}
diff --git a/framework/areg/trace/private/TraceManager.cpp b/framework/areg/trace/private/TraceManager.cpp
index 102ee1272..c3859c581 100644
--- a/framework/areg/trace/private/TraceManager.cpp
+++ b/framework/areg/trace/private/TraceManager.cpp
@@ -48,10 +48,19 @@ TraceManager & TraceManager::getInstance( void )
return _theTraceManager;
}
-void TraceManager::sendLogMessage( LogMessage & logData )
+void TraceManager::logMessage(const NETrace::sLogMessage& logData )
{
- TraceManager & tracer = TraceManager::getInstance();
- tracer.sendLogEvent( TraceEventData(TraceEventData::eTraceAction::TraceLogMessage, logData) );
+ TraceManager::getInstance().sendLogEvent( TraceEventData(TraceEventData::eTraceAction::TraceLogMessage, logData) );
+}
+
+void TraceManager::logMessage(const RemoteMessage& logData)
+{
+ TraceManager::getInstance().sendLogEvent( TraceEventData(TraceEventData::eTraceAction::TraceLogMessage, logData) );
+}
+
+void TraceManager::sendCommandMessage(TraceEventData::eTraceAction cmd, const SharedBuffer& data)
+{
+ TraceManager::getInstance().sendLogEvent(TraceEventData(cmd, data));
}
bool TraceManager::readLogConfig( const char* configFile /*= nullptr*/ )
@@ -334,17 +343,7 @@ void TraceManager::writeLogMessage( const NETrace::sLogMessage & logMessage )
bool TraceManager::postEvent(Event & eventElem)
{
- bool result = false;
- if (RUNTIME_CAST(&eventElem, TraceEvent) != nullptr)
- {
- result = EventDispatcher::postEvent(eventElem);
- }
- else
- {
- OUTPUT_ERR("Not a TraceEvent type event, cannot Post. Destroying event type [ %s ]", eventElem.getRuntimeClassName().getString());
- eventElem.destroy();
- }
- return result;
+ return EventDispatcher::postEvent(eventElem);
}
inline void TraceManager::sendLogEvent( const TraceEventData & data, Event::eEventPriority eventPrio /*= Event::eEventPriority::EventPriorityNormal*/ )
diff --git a/framework/areg/trace/private/TraceManager.hpp b/framework/areg/trace/private/TraceManager.hpp
index 9512ec8a6..92758155d 100644
--- a/framework/areg/trace/private/TraceManager.hpp
+++ b/framework/areg/trace/private/TraceManager.hpp
@@ -45,6 +45,10 @@
class TraceScope;
class LogMessage;
class IELogger;
+namespace NETrace
+{
+ struct sLogMessage;
+}
//////////////////////////////////////////////////////////////////////////
// TraceManager class declaration
@@ -61,6 +65,7 @@ class TraceManager : public DispatcherThread
, private IETraceEventConsumer
{
friend class TraceEventProcessor;
+ friend class CookieLayoutName;
//////////////////////////////////////////////////////////////////////////
// Internal types and constants
@@ -79,10 +84,24 @@ class TraceManager : public DispatcherThread
public:
/**
- * \brief Sends logging message for logging.
+ * \brief Triggers an event to log message created locally in the same process.
* \param logData The logging message object, which will be sent to all loggers.
**/
- static void sendLogMessage( LogMessage & logData );
+ static void logMessage( const NETrace::sLogMessage & logData );
+
+ /**
+ * \brief Triggers and event log remote message.
+ * \param logDaya The instance of remote message buffer, which contains the
+ * log message from another process.
+ **/
+ static void logMessage( const RemoteMessage& logData );
+
+ /**
+ * \brief Generates and queues a message to execute internal command.
+ * \param cmd The command to execute.
+ * \param data The binary data to pass in the command.
+ **/
+ static void sendCommandMessage(TraceEventData::eTraceAction cmd, const SharedBuffer& data);
/**
* \brief Call to configure logging. The passed configuration file name should be either
@@ -113,6 +132,9 @@ class TraceManager : public DispatcherThread
**/
static bool saveLogConfig( const char * configFile = nullptr );
+ /**
+ * \brief Updates the list of scopes and log priorities in the application configuration.
+ **/
static void updateScopeConfiguration( void );
/**
diff --git a/framework/areg/trace/private/TraceMessage.cpp b/framework/areg/trace/private/TraceMessage.cpp
index 12282c244..89cd7544c 100644
--- a/framework/areg/trace/private/TraceMessage.cpp
+++ b/framework/areg/trace/private/TraceMessage.cpp
@@ -29,8 +29,8 @@ TraceMessage::TraceMessage( const TraceScope & traceScope )
{
if ( isScopeEnabled() )
{
- LogMessage msg(NETrace::eMessageType::MsgScopeEnter, mScopeId, NETrace::PrioScope, mScopeName);
- TraceManager::sendLogMessage(msg);
+ LogMessage msg{ NETrace::eLogMessageType::LogMessageScopeEnter, mScopeId, NETrace::PrioScope, mScopeName };
+ TraceManager::logMessage(msg);
}
}
@@ -39,8 +39,8 @@ TraceMessage::~TraceMessage( void )
{
if ( isScopeEnabled() )
{
- LogMessage msg(NETrace::eMessageType::MsgScopeExit, mScopeId, NETrace::PrioScope, mScopeName);
- TraceManager::sendLogMessage(msg);
+ LogMessage msg{ NETrace::eLogMessageType::LogMessageScopeExit, mScopeId, NETrace::PrioScope, mScopeName };
+ TraceManager::logMessage(msg);
}
}
@@ -117,7 +117,7 @@ void TraceMessage::logTrace( NETrace::eLogPriority logPrio, const char * format,
inline void TraceMessage::_sendLog( unsigned int scopeId, NETrace::eLogPriority msgPrio, const char * format, va_list args )
{
- LogMessage logData(NETrace::MsgText, scopeId, msgPrio, nullptr, 0);
- logData.logMessageLen = String::formatStringList( logData.logMessage, NETrace::LOG_MESSAGE_BUFFER_SIZE - 1, format, args );
- TraceManager::sendLogMessage( logData );
+ LogMessage logData(NETrace::eLogMessageType::LogMessageText, scopeId, msgPrio, nullptr, 0);
+ logData.logMessageLen = String::formatStringList( logData.logMessage, NETrace::LOG_MESSAGE_IZE - 1, format, args );
+ TraceManager::logMessage( logData );
}
diff --git a/framework/extend/service/private/ServiceCommunicatonBase.cpp b/framework/extend/service/private/ServiceCommunicatonBase.cpp
index 102e36c94..ea5fd0997 100644
--- a/framework/extend/service/private/ServiceCommunicatonBase.cpp
+++ b/framework/extend/service/private/ServiceCommunicatonBase.cpp
@@ -278,7 +278,7 @@ void ServiceCommunicatonBase::onServiceExit( void )
bool ServiceCommunicatonBase::startConnection(void)
{
TRACE_SCOPE(areg_extend_service_ServiceCommunicatonBase_startConnection);
- TRACE_DBG("Going to start connection. Address [ %u ], port [ %d ]"
+ TRACE_DBG("Going to start connection. Address [ %s ], port [ %d ]"
, mServerConnection.getAddress().getHostAddress().getString()
, mServerConnection.getAddress().getHostPort());
@@ -322,7 +322,7 @@ bool ServiceCommunicatonBase::startConnection(void)
bool ServiceCommunicatonBase::restartConnection( void )
{
TRACE_SCOPE(areg_extend_service_ServiceCommunicatonBase_restartConnection);
- TRACE_DBG("Going to start connection. Address [ %u ], port [ %d ]"
+ TRACE_DBG("Going to start connection. Address [ %s ], port [ %d ]"
, mServerConnection.getAddress().getHostAddress().getString()
, mServerConnection.getAddress().getHostPort());
diff --git a/framework/logger/app/Logger.hpp b/framework/logger/app/Logger.hpp
index 3af720856..43624a61f 100644
--- a/framework/logger/app/Logger.hpp
+++ b/framework/logger/app/Logger.hpp
@@ -20,6 +20,7 @@
************************************************************************/
#include "areg/base/GEGlobal.h"
#include "extend/service/SystemServiceBase.hpp"
+#include "areg/persist/IEConfigurationListener.hpp"
#include "areg/base/SynchObjects.hpp"
#include "logger/app/NELoggerSettings.hpp"
@@ -38,7 +39,8 @@ class Console;
* and collects the log messages from the running applications.
* It may save logs in the file or forward to log viewer application..
**/
-class Logger : public SystemServiceBase
+class Logger : public SystemServiceBase
+ , private IEConfigurationListener
{
//////////////////////////////////////////////////////////////////////////
// Internal types
@@ -203,6 +205,43 @@ class Logger : public SystemServiceBase
**/
virtual void runConsoleInputSimple( void ) override;
+/************************************************************************/
+// IEConfigurationListener protected overrides
+/************************************************************************/
+
+ /**
+ * \brief Called by configuration manager before the configuration is saved in the file.
+ * \param config The instance of configuration manager.
+ **/
+ virtual void prepareSaveConfiguration(ConfigManager& config) override;
+
+ /**
+ * \brief Called by configuration manager after the configuration is saved in the file.
+ * \param config The instance of configuration manager.
+ **/
+ virtual void postSaveConfiguration(ConfigManager& config) override;
+
+ /**
+ * \brief Called by configuration manager before the configuration is loaded from the file.
+ * \param config The instance of configuration manager.
+ **/
+ virtual void prepareReadConfiguration(ConfigManager& config) override;
+
+ /**
+ * \brief Called by configuration manager when configuration is completed to load data from the file.
+ * \param config The instance of configuration manager.
+ **/
+ virtual void postReadConfiguration(ConfigManager& config) override;
+
+ /**
+ * \brief Called by configuration manager after setting read-only and writable properties.
+ * For example, when the default configuration is set.
+ * \param listReadonly The list of read-only properties to set in the configuration.
+ * \param listWritable The list of module / process specific properties to set in the configuration;
+ * \param config The instance of configuration manager.
+ **/
+ virtual void onSetupConfiguration(const NEPersistence::ListProperties& listReadonly, const NEPersistence::ListProperties& listWritable, ConfigManager& config) override;
+
//////////////////////////////////////////////////////////////////////////
// Hidden methods.
//////////////////////////////////////////////////////////////////////////
@@ -217,6 +256,8 @@ class Logger : public SystemServiceBase
**/
inline const ServiceCommunicatonBase::MapInstances & getConnetedInstances( void ) const;
+ inline void enableLocalLogs(ConfigManager& config, bool enable);
+
/**
* \brief Returns instance of the logger service.
**/
diff --git a/framework/logger/app/private/Logger.cpp b/framework/logger/app/private/Logger.cpp
index fcd01a493..129d094e5 100644
--- a/framework/logger/app/private/Logger.cpp
+++ b/framework/logger/app/private/Logger.cpp
@@ -23,6 +23,7 @@
#include "areg/base/Process.hpp"
#include "areg/base/String.hpp"
#include "areg/component/ComponentLoader.hpp"
+#include "areg/persist/ConfigManager.hpp"
#include "areg/trace/GETrace.h"
#include "extend/console/Console.hpp"
@@ -134,8 +135,9 @@ std::pair Logger::getOptionSetup( void
}
Logger::Logger( void )
- : SystemServiceBase ( mServiceServer )
- , mServiceServer ( )
+ : SystemServiceBase ( mServiceServer )
+ , IEConfigurationListener ( )
+ , mServiceServer ( )
{
}
@@ -201,10 +203,32 @@ void Logger::runConsoleInputSimple( void )
} while ( quit == false );
}
+void Logger::prepareSaveConfiguration(ConfigManager& config)
+{
+}
+
+void Logger::postSaveConfiguration(ConfigManager& config)
+{
+}
+
+void Logger::prepareReadConfiguration(ConfigManager& config)
+{
+}
+
+void Logger::postReadConfiguration(ConfigManager& config)
+{
+ enableLocalLogs(config, false);
+}
+
+void Logger::onSetupConfiguration(const NEPersistence::ListProperties& listReadonly, const NEPersistence::ListProperties& listWritable, ConfigManager& config)
+{
+ enableLocalLogs(config, false);
+}
+
void Logger::serviceMain( int argc, char ** argv )
{
// Start only tracing and timer manager.
- Application::initApplication(true, true, false, true, false, NEApplication::DEFAULT_CONFIG_FILE.data());
+ Application::initApplication(true, true, false, true, false, NEApplication::DEFAULT_CONFIG_FILE.data(), static_cast(&self()));
SystemServiceBase::serviceMain( argc, argv );
setState(NESystemService::eSystemServiceState::ServiceStopped);
mServiceServer.waitToComplete( );
@@ -639,3 +663,16 @@ void Logger::_cleanHelp(void)
#endif // AREG_EXTENDED
}
+
+inline void Logger::enableLocalLogs(ConfigManager& config, bool enable)
+{
+ constexpr NEPersistence::eConfigKeys prioConfKey{ NEPersistence::eConfigKeys::EntryLogScope };
+ const NEPersistence::sPropertyKey& keyPrio{ NEPersistence::getLogScope() };
+ unsigned int prios = enable
+ ? static_cast(NETrace::eLogPriority::PrioNotset) | static_cast(NETrace::eLogPriority::PrioNotset)
+ : static_cast(NETrace::eLogPriority::PrioNotset);
+ const String prio{ NETrace::makePrioString(prios) };
+
+ config.setModuleProperty(keyPrio.section, keyPrio.property, String(NEPersistence::SYNTAX_ANY_VALUE), prio, prioConfKey, true);
+ config.setLogEnabled(NETrace::eLogingTypes::LogTypeRemote, false, true);
+}
diff --git a/framework/logger/service/LoggerServerService.hpp b/framework/logger/service/LoggerServerService.hpp
index a1ceba59c..3995e9bfa 100644
--- a/framework/logger/service/LoggerServerService.hpp
+++ b/framework/logger/service/LoggerServerService.hpp
@@ -20,6 +20,7 @@
************************************************************************/
#include "areg/base/GEGlobal.h"
+#include "areg/trace/NETrace.hpp"
#include "extend/service/ServiceCommunicatonBase.hpp"
#include "logger/service/private/LoggerMessageProcessor.hpp"
diff --git a/framework/logger/service/private/LoggerMessageProcessor.cpp b/framework/logger/service/private/LoggerMessageProcessor.cpp
index 6d5f2c2ae..a23c067a1 100644
--- a/framework/logger/service/private/LoggerMessageProcessor.cpp
+++ b/framework/logger/service/private/LoggerMessageProcessor.cpp
@@ -240,6 +240,7 @@ void LoggerMessageProcessor::logMessage(const RemoteMessage & msgReceived) const
{
const ITEM_ID & key{ observers.keyAtPosition(pos) };
RemoteMessage msg{ msgReceived.clone(source, key) };
+ ASSERT(NETrace::eLogDataType::LogDataRemote == reinterpret_cast(msg.getBuffer())->logDataType);
mLoggerService.sendMessage(msg);
}
}
diff --git a/framework/logger/service/private/LoggerServerService.cpp b/framework/logger/service/private/LoggerServerService.cpp
index e503610bd..d7b7d029f 100644
--- a/framework/logger/service/private/LoggerServerService.cpp
+++ b/framework/logger/service/private/LoggerServerService.cpp
@@ -17,6 +17,7 @@
#include "areg/ipc/private/NEConnection.hpp"
#include "areg/ipc/ConnectionConfiguration.hpp"
#include "areg/trace/GETrace.h"
+#include "areg/trace/private/TraceManager.hpp"
DEF_TRACE_SCOPE(logger_service_LoggerServerService_onServiceMessageReceived);
DEF_TRACE_SCOPE(logger_service_LoggerServerService_onServiceMessageSend);
@@ -125,19 +126,22 @@ void LoggerServerService::onServiceMessageReceived(const RemoteMessage &msgRecei
case NEService::eFuncIdRange::ServiceLogMessage:
mLoggerProcessor.logMessage(msgReceived);
+ NETrace::logMessage(msgReceived);
break;
- case NEService::eFuncIdRange::RequestServiceProviderVersion:
- case NEService::eFuncIdRange::ResponseServiceProviderVersion:
- case NEService::eFuncIdRange::RequestServiceProviderConnection:
- case NEService::eFuncIdRange::ResponseServiceProviderConnection:
case NEService::eFuncIdRange::SystemServiceConnect:
case NEService::eFuncIdRange::SystemServiceDisconnect:
- case NEService::eFuncIdRange::SystemServiceNotifyConnection:
- case NEService::eFuncIdRange::SystemServiceNotifyInstances:
- case NEService::eFuncIdRange::RequestRegisterService:
- case NEService::eFuncIdRange::SystemServiceRequestRegister:
- case NEService::eFuncIdRange::SystemServiceNotifyRegister:
+ break;
+
+ case NEService::eFuncIdRange::RequestRegisterService: // fall through
+ case NEService::eFuncIdRange::RequestServiceProviderVersion: // fall through
+ case NEService::eFuncIdRange::ResponseServiceProviderVersion: // fall through
+ case NEService::eFuncIdRange::RequestServiceProviderConnection: // fall through
+ case NEService::eFuncIdRange::ResponseServiceProviderConnection:// fall through
+ case NEService::eFuncIdRange::SystemServiceNotifyConnection: // fall through
+ case NEService::eFuncIdRange::SystemServiceNotifyInstances: // fall through
+ case NEService::eFuncIdRange::SystemServiceRequestRegister: // fall through
+ case NEService::eFuncIdRange::SystemServiceNotifyRegister: // fall through
default:
TRACE_ERR("Unexpected logger service message!");
ASSERT(false);
diff --git a/framework/mcrouter/tcp/private/RouterServerService.cpp b/framework/mcrouter/tcp/private/RouterServerService.cpp
index 852e660fb..69264f16b 100644
--- a/framework/mcrouter/tcp/private/RouterServerService.cpp
+++ b/framework/mcrouter/tcp/private/RouterServerService.cpp
@@ -165,26 +165,26 @@ void RouterServerService::onServiceMessageReceived(const RemoteMessage &msgRecei
}
break;
- case NEService::eFuncIdRange::ServiceLastId:
- case NEService::eFuncIdRange::SystemServiceQueryInstances:
- case NEService::eFuncIdRange::SystemServiceConnect:
- case NEService::eFuncIdRange::RequestServiceProviderConnection:
- case NEService::eFuncIdRange::ResponseServiceProviderVersion:
- case NEService::eFuncIdRange::RequestServiceProviderVersion:
- case NEService::eFuncIdRange::RequestRegisterService:
- case NEService::eFuncIdRange::ComponentCleanup:
- case NEService::eFuncIdRange::SystemServiceNotifyRegister:
+ case NEService::eFuncIdRange::ServiceLastId: // fall through
+ case NEService::eFuncIdRange::SystemServiceQueryInstances: // fall through
+ case NEService::eFuncIdRange::SystemServiceConnect: // fall through
+ case NEService::eFuncIdRange::RequestServiceProviderConnection: // fall through
+ case NEService::eFuncIdRange::ResponseServiceProviderVersion: // fall through
+ case NEService::eFuncIdRange::RequestServiceProviderVersion: // fall through
+ case NEService::eFuncIdRange::RequestRegisterService: // fall through
+ case NEService::eFuncIdRange::ComponentCleanup: // fall through
+ case NEService::eFuncIdRange::SystemServiceNotifyRegister: // fall through
case NEService::eFuncIdRange::SystemServiceNotifyConnection:
break;
- case NEService::eFuncIdRange::ResponseServiceProviderConnection:
- case NEService::eFuncIdRange::AttributeLastId:
- case NEService::eFuncIdRange::AttributeFirstId:
- case NEService::eFuncIdRange::ResponseLastId:
- case NEService::eFuncIdRange::ResponseFirstId:
- case NEService::eFuncIdRange::RequestLastId:
- case NEService::eFuncIdRange::RequestFirstId:
- case NEService::eFuncIdRange::EmptyFunctionId:
+ case NEService::eFuncIdRange::ResponseServiceProviderConnection:// fall through
+ case NEService::eFuncIdRange::AttributeLastId: // fall through
+ case NEService::eFuncIdRange::AttributeFirstId: // fall through
+ case NEService::eFuncIdRange::ResponseLastId: // fall through
+ case NEService::eFuncIdRange::ResponseFirstId: // fall through
+ case NEService::eFuncIdRange::RequestLastId: // fall through
+ case NEService::eFuncIdRange::RequestFirstId: // fall through
+ case NEService::eFuncIdRange::EmptyFunctionId: // fall through
default:
if ( NEService::isExecutableId(static_cast(msgId)) || NEService::isConnectNotifyId( static_cast(msgId)) )
{