diff --git a/framework/areg/component/NEService.hpp b/framework/areg/component/NEService.hpp index 0a65295db..a47c506e1 100644 --- a/framework/areg/component/NEService.hpp +++ b/framework/areg/component/NEService.hpp @@ -358,7 +358,7 @@ namespace NEService * \brief NEService::TARGET_ALL * The undefined (all) target ID **/ - constexpr ITEM_ID TARGET_ALL { static_cast(NECommon::eCookies::CookieInvalid) }; + constexpr ITEM_ID TARGET_ALL { static_cast(NEService::COOKIE_ANY) }; /** * \brief NEService::SOURCE_UNKNOWN * The unknown source ID diff --git a/framework/areg/logging/NELogging.hpp b/framework/areg/logging/NELogging.hpp index d21bcf6bd..97000dd54 100644 --- a/framework/areg/logging/NELogging.hpp +++ b/framework/areg/logging/NELogging.hpp @@ -517,7 +517,7 @@ namespace NELogging /** * \brief Creates a message to query instances connected to the service. * \param source The source ID that created the query message. Should be the ID of the log observer or the ID of the log collector service. - * \param target The target ID to send the message. The target is either concrete target or NEService::COOKIE_ANY if message targets all clients. + * \param target The target ID to send the message. The target is either concrete target or NEService::TARGET_ALL if message targets all clients. * \return Returns generated message ready to forward to target client(s) via log collector service. **/ AREG_API RemoteMessage messageQueryInstances(const ITEM_ID& source, const ITEM_ID& target); @@ -532,7 +532,7 @@ namespace NELogging * \param source The ID of the source that generated the message. * The source should be either log observer or NEService::COOKIE_LOGGER. * \param target The ID of the target to send the message. - * If the ID is NEService::COOKIE_ANY, the message is sent to all connected clients. + * If the ID is NEService::TARGET_ALL, the message is sent to all connected clients. * \return Returns generated message ready to send from indicated source to the target. **/ AREG_API RemoteMessage messageQueryScopes(const ITEM_ID& source, const ITEM_ID& target); @@ -554,7 +554,7 @@ namespace NELogging * \param source The source ID that generated the message. It should be either ID of the log observer application * or the ID of the log collector service. * \param target The target ID to receive the message. This target can be either concrete connected client - * or can be NEService::COOKIE_ANY if should be forwarded to all connected clients. + * or can be NEService::TARGET_ALL if should be forwarded to all connected clients. * \return Returns generated message ready to send to client(s) via log collector service. **/ AREG_API RemoteMessage messageSaveConfiguration(const ITEM_ID & source, const ITEM_ID & target); diff --git a/framework/areglogger/client/LogObserverBase.hpp b/framework/areglogger/client/LogObserverBase.hpp index d1bc2b140..ac6fe213f 100644 --- a/framework/areglogger/client/LogObserverBase.hpp +++ b/framework/areglogger/client/LogObserverBase.hpp @@ -263,7 +263,7 @@ class LOGGER_API LogObserverBase * \brief Requests to update the priority of the logging message to receive. * The indicated scopes can be scope group. * \param target The valid cookie ID of the target to update the log message priority. - * This value cannot be NEService::TARGET_ALL (or 0). + * This value cannot be NEService::TARGET_ALL (or 0xFF). * \param scopes The list of scopes of scope group to update the priority. * The scope group should end with '*'. For example 'areg_base_*'. * In this case the ID of the scope can be 0. @@ -276,7 +276,7 @@ class LOGGER_API LogObserverBase * \brief Requests to save current configuration of the specified target. This is normally called when update the log priority of the instance, * so that on next start the application logs message of the scopes and priorities currently set. * \param target The cookie ID of the target instance to save the configuration. - * If the target is NEService::TARGET_ALL (or 0), the request is sent to all connected instances. + * If the target is NEService::TARGET_ALL (or 0xFF), the request is sent to all connected instances. * Otherwise, should be indicated the valid cookie ID of the connected log instance. * \return Returns true if processed with success. Otherwise, returns false. **/ diff --git a/framework/areglogger/client/private/LoggerClient.cpp b/framework/areglogger/client/private/LoggerClient.cpp index 7a94309a4..9df23ac7f 100644 --- a/framework/areglogger/client/private/LoggerClient.cpp +++ b/framework/areglogger/client/private/LoggerClient.cpp @@ -187,37 +187,37 @@ bool LoggerClient::requestConnectedInstances(void) return result; } -bool LoggerClient::requestScopes(const ITEM_ID& target /*= NEService::COOKIE_ANY*/) +bool LoggerClient::requestScopes(const ITEM_ID& target /*= NEService::TARGET_ALL*/) { bool result{ false }; Lock lock(mLock); - if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN)) + if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN)) { - result = sendMessage(NELogging::messageQueryScopes(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target)); + result = sendMessage(NELogging::messageQueryScopes(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target)); } return result; } -bool LoggerClient::requestChangeScopePrio(const NELogging::ScopeNames & scopes, const ITEM_ID& target /*= NEService::COOKIE_ANY*/) +bool LoggerClient::requestChangeScopePrio(const NELogging::ScopeNames & scopes, const ITEM_ID& target /*= NEService::TARGET_ALL*/) { bool result{ false }; Lock lock(mLock); - if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN)) + if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN)) { - result = sendMessage(NELogging::messageUpdateScopes(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target, scopes)); + result = sendMessage(NELogging::messageUpdateScopes(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target, scopes)); } return result; } -bool LoggerClient::requestSaveConfiguration(const ITEM_ID& target /*= NEService::COOKIE_ANY*/) +bool LoggerClient::requestSaveConfiguration(const ITEM_ID& target /*= NEService::TARGET_ALL*/) { bool result{ false }; Lock lock(mLock); - if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::COOKIE_UNKNOWN)) + if ((mChannel.getCookie() != NEService::COOKIE_UNKNOWN) && (target != NEService::TARGET_UNKNOWN)) { - result = sendMessage(NELogging::messageSaveConfiguration(mChannel.getCookie(), target == NEService::COOKIE_ANY ? LoggerClient::TargetID : target)); + result = sendMessage(NELogging::messageSaveConfiguration(mChannel.getCookie(), target == NEService::TARGET_ALL ? LoggerClient::TargetID : target)); } return result; diff --git a/framework/areglogger/client/private/LoggerClient.hpp b/framework/areglogger/client/private/LoggerClient.hpp index 738a968ad..dd67d8f25 100644 --- a/framework/areglogger/client/private/LoggerClient.hpp +++ b/framework/areglogger/client/private/LoggerClient.hpp @@ -180,37 +180,37 @@ class LoggerClient : public ServiceClientConnectionBase /** * \brief Generates and sends the message to query list of scopes. * The message is sent either to certain target or to all connected clients - * if the target is NEService::COOKIE_ANY. + * if the target is NEService::TARGET_ALL. * \param target The ID of the target to send the message. - * The message is sent to all clients if the target is NEService::COOKIE_ANY. + * The message is sent to all clients if the target is NEService::TARGET_ALL. * \return Returns true if processed the request with success. Otherwise, returns false. **/ - bool requestScopes(const ITEM_ID& target = NEService::COOKIE_ANY); + bool requestScopes(const ITEM_ID& target = NEService::TARGET_ALL); /** * \brief Generates and sends the message to update the scope priority. * The message is sent either to certain target or to all connected clients - * if the target is NEService::COOKIE_ANY. + * if the target is NEService::TARGET_ALL. * \param scopes The list of scopes or scope group to update the log message priority. * Each entry contains scope name, scope ID and the scope message priority. * The ID can be 0 if the name refers to a scope group. * \param target The ID of the target to send the message. - * The message is sent to all clients if the target is NEService::COOKIE_ANY. + * The message is sent to all clients if the target is NEService::TARGET_ALL. * \return Returns true if processed the request with success. Otherwise, returns false. **/ - bool requestChangeScopePrio(const NELogging::ScopeNames& scopes, const ITEM_ID& target = NEService::COOKIE_ANY); + bool requestChangeScopePrio(const NELogging::ScopeNames& scopes, const ITEM_ID& target = NEService::TARGET_ALL); /** * \brief Generates and sends the message to request to save configuration current state, * so that on the next start the application starts with the configuration state. * Normally, this is used when change scope message priority. * The message is sent either to certain target or to all connected clients - * if the target is NEService::COOKIE_ANY. + * if the target is NEService::TARGET_ALL. * \param target The ID of the target to send the message. - * The message is sent to all clients if the target is NEService::COOKIE_ANY. + * The message is sent to all clients if the target is NEService::TARGET_ALL. * \return Returns true if processed the request with success. Otherwise, returns false. **/ - bool requestSaveConfiguration(const ITEM_ID & target = NEService::COOKIE_ANY); + bool requestSaveConfiguration(const ITEM_ID & target = NEService::TARGET_ALL); /** * \brief Creates of opens the database for the logging. If specified path is null or empty, diff --git a/framework/logcollector/app/LogCollector.hpp b/framework/logcollector/app/LogCollector.hpp index 015e40d96..4389a7e3e 100644 --- a/framework/logcollector/app/LogCollector.hpp +++ b/framework/logcollector/app/LogCollector.hpp @@ -313,7 +313,7 @@ class LogCollector : public ServiceApplicationBase * \param optScope The option entry that contains scope priority update instruction. * If the command contains a list of scopes to update, the should be split by ';'. * \param msgList On output it contains a list a messages to send to the targets. - * If a message is referred to all connected clients, the target is NEService::COOKIE_ANY. + * If a message is referred to all connected clients, the target is NEService::TARGET_ALL. **/ static void _createScopeMessage(const OptionParser::sOption& optScope, TEArrayList & OUT msgList); diff --git a/framework/logcollector/service/private/LogCollectorMessageProcessor.cpp b/framework/logcollector/service/private/LogCollectorMessageProcessor.cpp index 5b9a19660..bce7d17b3 100644 --- a/framework/logcollector/service/private/LogCollectorMessageProcessor.cpp +++ b/framework/logcollector/service/private/LogCollectorMessageProcessor.cpp @@ -46,14 +46,14 @@ void LogCollectorMessageProcessor::queryConnectedInstances(const RemoteMessage & } } -void LogCollectorMessageProcessor::notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID& target /*= NEService::COOKIE_ANY*/) const +void LogCollectorMessageProcessor::notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID& target /*= NEService::TARGET_ALL*/) const { const auto& observers{ mLoggerService.getObservers() }; if (observers.isEmpty()) return; RemoteMessage msgInstances; - ASSERT((target == NEService::COOKIE_ANY) || (instances.contains(target) && isLogObserver(instances.getAt(target).ciSource))); + ASSERT((target == NEService::TARGET_ALL) || (instances.contains(target) && isLogObserver(instances.getAt(target).ciSource))); if (msgInstances.initMessage(NERemoteService::getMessageNotifyInstances().rbHeader) != nullptr) { @@ -77,7 +77,7 @@ void LogCollectorMessageProcessor::notifyConnectedInstances(const NEService::Map msgInstances.moveToEnd(); } - if (target == NEService::COOKIE_ANY) + if (target == NEService::TARGET_ALL) { for (const auto& observer : observers.getData()) { @@ -105,7 +105,7 @@ void LogCollectorMessageProcessor::notifyDisconnectedInstances(const TEArrayList { msgInstances << NERemoteService::eRemoteConnection::RemoteDisconnected; msgInstances << listIds; - if (target == NEService::COOKIE_ANY) + if (target == NEService::TARGET_ALL) { for (const auto& observer : observers.getData()) { @@ -156,7 +156,7 @@ void LogCollectorMessageProcessor::saveLogSourceConfiguration(const RemoteMessag ITEM_ID target{ NEService::COOKIE_UNKNOWN }; msgReceived >> target; - if ((target == NEService::COOKIE_ANY) || (target == NEService::COOKIE_LOGGER)) + if ((target == NEService::TARGET_ALL) || (target == NEService::COOKIE_LOGGER)) { const NEService::MapInstances& instances{ mLoggerService.getInstances() }; for (const auto& entry : instances.getData()) @@ -212,7 +212,7 @@ void LogCollectorMessageProcessor::processNextSaveConfig(void) void LogCollectorMessageProcessor::clientDisconnected(const ITEM_ID& cookie) { - if ((cookie > NEService::COOKIE_ANY) && (mPendingSave == cookie)) + if ((cookie > NEService::TARGET_ALL) && (mPendingSave == cookie)) { processNextSaveConfig(); } @@ -254,7 +254,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToLogSources(const Remo return; ITEM_ID source{ msgReceived.getSource() }; - ITEM_ID target{ msgReceived.getTarget() != NEService::COOKIE_LOGGER ? msgReceived.getTarget() : NEService::COOKIE_ANY }; + ITEM_ID target{ msgReceived.getTarget() != NEService::COOKIE_LOGGER ? msgReceived.getTarget() : NEService::TARGET_ALL }; auto srcPos = source != NEService::COOKIE_LOGGER ? instances.find(source) : instances.invalidPosition(); if ((source == NEService::COOKIE_LOGGER) || (instances.isValidPosition(srcPos) && isLogObserver(instances.valueAtPosition(srcPos).ciSource))) @@ -264,7 +264,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToLogSources(const Remo { mLoggerService.sendMessage(msgReceived); } - else if (target == NEService::COOKIE_ANY) + else if (target == NEService::TARGET_ALL) { for (const auto& instance : instances.getData()) { @@ -285,7 +285,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToObservers(const Remot return; ITEM_ID source{ msgReceived.getSource() }; - ITEM_ID target{ msgReceived.getTarget() != NEService::COOKIE_LOGGER ? msgReceived.getTarget() : NEService::COOKIE_ANY }; + ITEM_ID target{ msgReceived.getTarget() != NEService::COOKIE_LOGGER ? msgReceived.getTarget() : NEService::TARGET_ALL }; const NEService::MapInstances& instances = mLoggerService.getInstances(); auto srcPos = instances.find(source); @@ -296,7 +296,7 @@ inline void LogCollectorMessageProcessor::_forwardMessageToObservers(const Remot { mLoggerService.sendMessage(msgReceived); } - else if (target == NEService::COOKIE_ANY) + else if (target == NEService::TARGET_ALL) { for (const auto& observer : observers.getData()) { diff --git a/framework/logcollector/service/private/LogCollectorMessageProcessor.hpp b/framework/logcollector/service/private/LogCollectorMessageProcessor.hpp index 7fd450c6c..5e38fcb5d 100644 --- a/framework/logcollector/service/private/LogCollectorMessageProcessor.hpp +++ b/framework/logcollector/service/private/LogCollectorMessageProcessor.hpp @@ -66,25 +66,25 @@ class LogCollectorMessageProcessor /** * \brief Creates a communication message with the information of connected instances - * and sends the notification to the specified observer target. If target is NEService::COOKIE_ANY + * and sends the notification to the specified observer target. If target is NEService::TARGET_ALL * the notification is sent to all connected observers. Otherwise, it send to * the specified exact target. * \param instances The list of connected instances to include in the notification message. - * \param target The ID of the target to send the message. If target is NEService::COOKIE_ANY, + * \param target The ID of the target to send the message. If target is NEService::TARGET_ALL, * the notification message is sent to all observers. Otherwise, it is sent to the exact target. **/ - void notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID & target = NEService::COOKIE_ANY) const; + void notifyConnectedInstances(const NEService::MapInstances& instances, const ITEM_ID & target = NEService::TARGET_ALL) const; /** * \brief Creates a communication message with the IDs of disconnected instances - * and sends the notification to the specified observer target. If target is NEService::COOKIE_ANY + * and sends the notification to the specified observer target. If target is NEService::TARGET_ALL * the notification is sent to all connected observers. Otherwise, it send to * the specified exact target. * \param listIds The list of IDs of disconnected instances to include in the notification message. - * \param target The ID of the target to send the message. If target is NEService::COOKIE_ANY, + * \param target The ID of the target to send the message. If target is NEService::TARGET_ALL, * the notification message is sent to all observers. Otherwise, it is sent to the exact target. **/ - void notifyDisconnectedInstances(const TEArrayList & listIds, const ITEM_ID& target = NEService::COOKIE_ANY) const; + void notifyDisconnectedInstances(const TEArrayList & listIds, const ITEM_ID& target = NEService::TARGET_ALL) const; /** * \brief Called when a connected instance of application requests to register scopes. @@ -179,14 +179,14 @@ class LogCollectorMessageProcessor /** * \brief Forwards specified message to the log sources, i.e. clients. - * If the target in the remote message is NEService::COOKIE_ANY, the message is sent to all clients. + * If the target in the remote message is NEService::TARGET_ALL, the message is sent to all clients. * \param msgReceived The remote message received from observer or generated by the Log Collector. **/ inline void _forwardMessageToLogSources(const RemoteMessage& msgReceived) const; /** * \brief Forwards specified message to the log observer. - * If the target in the remote message is NEService::COOKIE_ANY, the message is sent to all observers. + * If the target in the remote message is NEService::TARGET_ALL, the message is sent to all observers. * \param msgReceived The remote message received from a client. **/ inline void _forwardMessageToObservers(const RemoteMessage& msgReceived) const; diff --git a/framework/logcollector/service/private/LogCollectorServerService.cpp b/framework/logcollector/service/private/LogCollectorServerService.cpp index 6e539b3a5..3318fe015 100644 --- a/framework/logcollector/service/private/LogCollectorServerService.cpp +++ b/framework/logcollector/service/private/LogCollectorServerService.cpp @@ -55,7 +55,7 @@ void LogCollectorServerService::addInstance(const ITEM_ID& cookie, const NEServi , instance.ciLocation.c_str()); NELogging::logAnyMessageLocal(logMsgHello); - mLoggerProcessor.notifyConnectedInstances(getInstances(), NEService::COOKIE_ANY); + mLoggerProcessor.notifyConnectedInstances(getInstances(), NEService::TARGET_ALL); } else if (LogCollectorMessageProcessor::isLogObserver(instance.ciSource)) { @@ -86,7 +86,7 @@ void LogCollectorServerService::removeInstance(const ITEM_ID & cookie) NELogging::logAnyMessageLocal(logMsgBye); listIds.add(instance.ciCookie); - mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::COOKIE_ANY); + mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::TARGET_ALL); } else if (LogCollectorMessageProcessor::isLogObserver(instance.ciSource)) { @@ -118,7 +118,7 @@ void LogCollectorServerService::removeAllInstances(void) if (listIds.isEmpty() == false) { - mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::COOKIE_ANY); + mLoggerProcessor.notifyDisconnectedInstances(listIds, NEService::TARGET_ALL); } } diff --git a/framework/logobserver/app/private/LogObserver.cpp b/framework/logobserver/app/private/LogObserver.cpp index 3f6cb709b..6adf57e98 100644 --- a/framework/logobserver/app/private/LogObserver.cpp +++ b/framework/logobserver/app/private/LogObserver.cpp @@ -503,7 +503,7 @@ bool LogObserver::_processSaveConfig(const OptionParser::sOption& optSave) TEArrayList listTargets; if (optSave.inString.empty() || (optSave.inString[0] == NEPersistence::SYNTAX_ALL_MODULES)) { - listTargets.add(NEService::COOKIE_ANY); + listTargets.add(NEService::TARGET_ALL); } else { @@ -512,7 +512,7 @@ bool LogObserver::_processSaveConfig(const OptionParser::sOption& optSave) if (elem == NEPersistence::SYNTAX_ALL_MODULES) { listTargets.clear(); - listTargets.add(NEService::COOKIE_ANY); + listTargets.add(NEService::TARGET_ALL); break; } else if (elem.isNumeric()) @@ -657,7 +657,7 @@ bool LogObserver::_processQueryScopes(const OptionParser::sOption& optScope) TEArrayList listTargets; if (optScope.inString.empty() || (optScope.inString[0] == NEPersistence::SYNTAX_ALL_MODULES)) { - listTargets.add(NEService::COOKIE_ANY); + listTargets.add(NEService::TARGET_ALL); } else { @@ -666,7 +666,7 @@ bool LogObserver::_processQueryScopes(const OptionParser::sOption& optScope) if (elem == NEPersistence::SYNTAX_ALL_MODULES) { listTargets.clear(); - listTargets.add(NEService::COOKIE_ANY); + listTargets.add(NEService::TARGET_ALL); break; } else if (elem.isNumeric()) @@ -737,8 +737,8 @@ bool LogObserver::_sendScopeUpdateMessage(const String& scope) if (prop.isValid() && prop.getPropertyType() == NEPersistence::eConfigKeys::EntryLogScope) { const PropertyKey& key{ prop.getKey() }; - ITEM_ID target{ key.isAllModules() ? NEService::COOKIE_ANY : key.getModule().toUInt32() }; - if (target >= NEService::COOKIE_ANY) + ITEM_ID target{ key.isAllModules() ? NEService::TARGET_ALL : key.getModule().toUInt32() }; + if (target >= NEService::TARGET_ALL) { String scopeName{ key.getPosition() }; uint32_t scopePrio{ prop.getValue().getIndetifier(NEApplication::LogScopePriorityIndentifiers) };