diff --git a/src/Application.cpp b/src/Application.cpp index 0394f1f7..5636a1bc 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -20,610 +20,607 @@ #include "src/Exceptions/InvalidConfig.hpp" -namespace Bloom -{ - using namespace Exceptions; +using namespace Exceptions; - Application::Application(std::vector&& arguments) - : arguments(std::move(arguments)) - , qtApplication( - ( - Thread::blockAllSignals(), - QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true), +Application::Application(std::vector&& arguments) + : arguments(std::move(arguments)) + , qtApplication( + ( + Thread::blockAllSignals(), + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true), #ifndef BLOOM_DEBUG_BUILD - QCoreApplication::addLibraryPath(QString::fromStdString(Services::PathService::applicationDirPath() + "/plugins")), + QCoreApplication::addLibraryPath(QString::fromStdString(Services::PathService::applicationDirPath() + "/plugins")), #endif #ifndef EXCLUDE_INSIGHT - QApplication(this->qtApplicationArgc, this->qtApplicationArgv.data()) + QApplication(this->qtApplicationArgc, this->qtApplicationArgv.data()) #else - QCoreApplication(this->qtApplicationArgc, this->qtApplicationArgv.data()) + QCoreApplication(this->qtApplicationArgc, this->qtApplicationArgv.data()) #endif - ) ) - {} + ) +{} - int Application::run() { - try { - this->setName("Bloom"); +int Application::run() { + try { + this->setName("Bloom"); - if (this->arguments.size() > 1) { - auto& firstArg = this->arguments.at(1); - const auto commandHandlersByCommandName = this->getCommandHandlersByCommandName(); - const auto commandHandlerIt = commandHandlersByCommandName.find(firstArg); + if (this->arguments.size() > 1) { + auto& firstArg = this->arguments.at(1); + const auto commandHandlersByCommandName = this->getCommandHandlersByCommandName(); + const auto commandHandlerIt = commandHandlersByCommandName.find(firstArg); - if (commandHandlerIt != commandHandlersByCommandName.end()) { - // User has passed an argument that maps to a command callback - invoke the callback and shutdown - const auto returnValue = commandHandlerIt->second(); + if (commandHandlerIt != commandHandlersByCommandName.end()) { + // User has passed an argument that maps to a command callback - invoke the callback and shutdown + const auto returnValue = commandHandlerIt->second(); - this->shutdown(); - return returnValue; - } - - // If the first argument didn't map to a command, we assume it's an environment name - this->selectedEnvironmentName = std::move(firstArg); + this->shutdown(); + return returnValue; } - if (Services::ProcessService::isRunningAsRoot()) { - Logger::warning("Please don't run Bloom as root - you're asking for trouble."); - } + // If the first argument didn't map to a command, we assume it's an environment name + this->selectedEnvironmentName = std::move(firstArg); + } + + if (Services::ProcessService::isRunningAsRoot()) { + Logger::warning("Please don't run Bloom as root - you're asking for trouble."); + } #ifdef BLOOM_DEBUG_BUILD - Logger::warning("This is a debug build - some functions may not work as expected"); + Logger::warning("This is a debug build - some functions may not work as expected"); #endif #ifdef EXCLUDE_INSIGHT - Logger::warning( - "The Insight component has been excluded from this build. All Insight related configuration parameters " - "will be ignored." + Logger::warning( + "The Insight component has been excluded from this build. All Insight related configuration parameters " + "will be ignored." + ); +#endif + + this->startup(); + +#ifndef EXCLUDE_INSIGHT + if (this->insightConfig->activateOnStartup) { + this->activateInsight(); + } +#endif + this->checkBloomVersion(); + + /* + * We can't run our own event loop here - we have to use Qt's event loop. But we still need to be able to + * process our events. To address this, we use a QTimer to dispatch our events on an interval. + * + * This allows us to use Qt's event loop whilst still being able to process our own events. + */ + auto* eventDispatchTimer = new QTimer(&(this->qtApplication)); + QObject::connect(eventDispatchTimer, &QTimer::timeout, this, &Application::dispatchEvents); + eventDispatchTimer->start(100); + + this->qtApplication.exec(); + + } catch (const InvalidConfig& exception) { + Logger::error("Invalid project configuration (bloom.yaml) - " + exception.getMessage()); + + } catch (const Exception& exception) { + Logger::error(exception.getMessage()); + } + + this->shutdown(); + return EXIT_SUCCESS; +} + +std::map> Application::getCommandHandlersByCommandName() { + return std::map> { + { + "--help", + std::bind(&Application::presentHelpText, this) + }, + { + "-h", + std::bind(&Application::presentHelpText, this) + }, + { + "--version", + std::bind(&Application::presentVersionText, this) + }, + { + "-v", + std::bind(&Application::presentVersionText, this) + }, + { + "--version-machine", + std::bind(&Application::presentVersionMachineText, this) + }, + { + "init", + std::bind(&Application::initProject, this) + }, + }; +} + +void Application::startup() { + auto& applicationEventListener = this->applicationEventListener; + EventManager::registerListener(applicationEventListener); + applicationEventListener->registerCallbackForEventType( + std::bind(&Application::onShutdownApplicationRequest, this, std::placeholders::_1) + ); + + this->loadProjectSettings(); + this->loadProjectConfiguration(); + Logger::configure(this->projectConfig.value()); + + Logger::debug("Bloom version: " + Application::VERSION.toString()); + + this->startSignalHandler(); + + Logger::info("Selected environment: \"" + this->selectedEnvironmentName + "\""); + Logger::debug("Number of environments extracted from config: " + + std::to_string(this->projectConfig->environments.size())); + + applicationEventListener->registerCallbackForEventType( + std::bind(&Application::onTargetControllerThreadStateChanged, this, std::placeholders::_1) + ); + + applicationEventListener->registerCallbackForEventType( + std::bind(&Application::onDebugServerThreadStateChanged, this, std::placeholders::_1) + ); + + applicationEventListener->registerCallbackForEventType( + std::bind(&Application::onDebugSessionFinished, this, std::placeholders::_1) + ); + +#ifndef EXCLUDE_INSIGHT + applicationEventListener->registerCallbackForEventType( + std::bind(&Application::onInsightActivationRequest, this, std::placeholders::_1) + ); + + applicationEventListener->registerCallbackForEventType( + std::bind(&Application::onInsightMainWindowClosed, this, std::placeholders::_1) + ); +#endif + this->startTargetController(); + this->startDebugServer(); + + Thread::threadState = ThreadState::READY; +} + +void Application::shutdown() { + const auto appState = Thread::getThreadState(); + if (appState == ThreadState::STOPPED || appState == ThreadState::SHUTDOWN_INITIATED) { + return; + } + + Thread::threadState = ThreadState::SHUTDOWN_INITIATED; + Logger::info("Shutting down Bloom"); + + this->stopDebugServer(); + this->stopTargetController(); + this->stopSignalHandler(); + + try { + this->saveProjectSettings(); + + } catch (const Exception& exception) { + Logger::error("Failed to save project settings - " + exception.getMessage()); + } + + Thread::threadState = ThreadState::STOPPED; +} + +void Application::triggerShutdown() { +#ifndef EXCLUDE_INSIGHT + if (this->insight != nullptr) { + this->insight->shutdown(); + } +#endif + + this->qtApplication.exit(EXIT_SUCCESS); +} + +void Application::loadProjectSettings() { + const auto projectSettingsPath = Services::PathService::projectSettingsPath(); + auto jsonSettingsFile = QFile(QString::fromStdString(projectSettingsPath)); + + if (jsonSettingsFile.exists()) { + try { + if (!jsonSettingsFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + throw Exception("Failed to open settings file."); + } + + this->projectSettings = ProjectSettings( + QJsonDocument::fromJson(jsonSettingsFile.readAll()).object() ); -#endif - - this->startup(); - -#ifndef EXCLUDE_INSIGHT - if (this->insightConfig->activateOnStartup) { - this->activateInsight(); - } -#endif - this->checkBloomVersion(); - - /* - * We can't run our own event loop here - we have to use Qt's event loop. But we still need to be able to - * process our events. To address this, we use a QTimer to dispatch our events on an interval. - * - * This allows us to use Qt's event loop whilst still being able to process our own events. - */ - auto* eventDispatchTimer = new QTimer(&(this->qtApplication)); - QObject::connect(eventDispatchTimer, &QTimer::timeout, this, &Application::dispatchEvents); - eventDispatchTimer->start(100); - - this->qtApplication.exec(); - - } catch (const InvalidConfig& exception) { - Logger::error("Invalid project configuration (bloom.yaml) - " + exception.getMessage()); - - } catch (const Exception& exception) { - Logger::error(exception.getMessage()); - } - - this->shutdown(); - return EXIT_SUCCESS; - } - - std::map> Application::getCommandHandlersByCommandName() { - return std::map> { - { - "--help", - std::bind(&Application::presentHelpText, this) - }, - { - "-h", - std::bind(&Application::presentHelpText, this) - }, - { - "--version", - std::bind(&Application::presentVersionText, this) - }, - { - "-v", - std::bind(&Application::presentVersionText, this) - }, - { - "--version-machine", - std::bind(&Application::presentVersionMachineText, this) - }, - { - "init", - std::bind(&Application::initProject, this) - }, - }; - } - - void Application::startup() { - auto& applicationEventListener = this->applicationEventListener; - EventManager::registerListener(applicationEventListener); - applicationEventListener->registerCallbackForEventType( - std::bind(&Application::onShutdownApplicationRequest, this, std::placeholders::_1) - ); - - this->loadProjectSettings(); - this->loadProjectConfiguration(); - Logger::configure(this->projectConfig.value()); - - Logger::debug("Bloom version: " + Application::VERSION.toString()); - - this->startSignalHandler(); - - Logger::info("Selected environment: \"" + this->selectedEnvironmentName + "\""); - Logger::debug("Number of environments extracted from config: " - + std::to_string(this->projectConfig->environments.size())); - - applicationEventListener->registerCallbackForEventType( - std::bind(&Application::onTargetControllerThreadStateChanged, this, std::placeholders::_1) - ); - - applicationEventListener->registerCallbackForEventType( - std::bind(&Application::onDebugServerThreadStateChanged, this, std::placeholders::_1) - ); - - applicationEventListener->registerCallbackForEventType( - std::bind(&Application::onDebugSessionFinished, this, std::placeholders::_1) - ); - -#ifndef EXCLUDE_INSIGHT - applicationEventListener->registerCallbackForEventType( - std::bind(&Application::onInsightActivationRequest, this, std::placeholders::_1) - ); - - applicationEventListener->registerCallbackForEventType( - std::bind(&Application::onInsightMainWindowClosed, this, std::placeholders::_1) - ); -#endif - this->startTargetController(); - this->startDebugServer(); - - Thread::threadState = ThreadState::READY; - } - - void Application::shutdown() { - const auto appState = Thread::getThreadState(); - if (appState == ThreadState::STOPPED || appState == ThreadState::SHUTDOWN_INITIATED) { - return; - } - - Thread::threadState = ThreadState::SHUTDOWN_INITIATED; - Logger::info("Shutting down Bloom"); - - this->stopDebugServer(); - this->stopTargetController(); - this->stopSignalHandler(); - - try { - this->saveProjectSettings(); - - } catch (const Exception& exception) { - Logger::error("Failed to save project settings - " + exception.getMessage()); - } - - Thread::threadState = ThreadState::STOPPED; - } - - void Application::triggerShutdown() { -#ifndef EXCLUDE_INSIGHT - if (this->insight != nullptr) { - this->insight->shutdown(); - } -#endif - - this->qtApplication.exit(EXIT_SUCCESS); - } - - void Application::loadProjectSettings() { - const auto projectSettingsPath = Services::PathService::projectSettingsPath(); - auto jsonSettingsFile = QFile(QString::fromStdString(projectSettingsPath)); - - if (jsonSettingsFile.exists()) { - try { - if (!jsonSettingsFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - throw Exception("Failed to open settings file."); - } - - this->projectSettings = ProjectSettings( - QJsonDocument::fromJson(jsonSettingsFile.readAll()).object() - ); - jsonSettingsFile.close(); - - return; - - } catch (const std::exception& exception) { - Logger::error( - "Failed to load project settings from " + projectSettingsPath + " - " + exception.what() - ); - } - } - - this->projectSettings = ProjectSettings(); - } - - void Application::saveProjectSettings() { - if (!this->projectSettings.has_value()) { - return; - } - - const auto projectSettingsPath = Services::PathService::projectSettingsPath(); - auto jsonSettingsFile = QFile(QString::fromStdString(projectSettingsPath)); - - Logger::debug("Saving project settings to " + projectSettingsPath); - - QDir().mkpath(QString::fromStdString(Services::PathService::projectSettingsDirPath())); - - try { - const auto jsonDocument = QJsonDocument(this->projectSettings->toJson()); - - if (!jsonSettingsFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) { - throw Exception( - "Failed to open/create settings file (" + projectSettingsPath + "). Check file permissions." - ); - } - - jsonSettingsFile.write(jsonDocument.toJson()); jsonSettingsFile.close(); - } catch (const Exception& exception) { + return; + + } catch (const std::exception& exception) { Logger::error( - "Failed to save project settings - " + exception.getMessage() + "Failed to load project settings from " + projectSettingsPath + " - " + exception.what() ); } } - void Application::loadProjectConfiguration() { - auto configFile = QFile(QString::fromStdString(Services::PathService::projectConfigPath())); + this->projectSettings = ProjectSettings(); +} - if (!configFile.exists()) { +void Application::saveProjectSettings() { + if (!this->projectSettings.has_value()) { + return; + } + + const auto projectSettingsPath = Services::PathService::projectSettingsPath(); + auto jsonSettingsFile = QFile(QString::fromStdString(projectSettingsPath)); + + Logger::debug("Saving project settings to " + projectSettingsPath); + + QDir().mkpath(QString::fromStdString(Services::PathService::projectSettingsDirPath())); + + try { + const auto jsonDocument = QJsonDocument(this->projectSettings->toJson()); + + if (!jsonSettingsFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) { throw Exception( - "Bloom configuration file (bloom.yaml) not found. Working directory: " - + Services::PathService::projectDirPath() + "Failed to open/create settings file (" + projectSettingsPath + "). Check file permissions." ); } - if (!configFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - throw InvalidConfig( - "Failed to open Bloom configuration file. Working directory: " + Services::PathService::projectDirPath() - ); - } + jsonSettingsFile.write(jsonDocument.toJson()); + jsonSettingsFile.close(); - try { - const auto configNode = YAML::Load(configFile.readAll().toStdString()); - configFile.close(); + } catch (const Exception& exception) { + Logger::error( + "Failed to save project settings - " + exception.getMessage() + ); + } +} - this->projectConfig = ProjectConfig(configNode); +void Application::loadProjectConfiguration() { + auto configFile = QFile(QString::fromStdString(Services::PathService::projectConfigPath())); - } catch (const YAML::Exception& exception) { - throw InvalidConfig(exception.msg); - } + if (!configFile.exists()) { + throw Exception( + "Bloom configuration file (bloom.yaml) not found. Working directory: " + + Services::PathService::projectDirPath() + ); + } - // Validate the selected environment - const auto selectedEnvironmentIt = this->projectConfig->environments.find(this->selectedEnvironmentName); - if (selectedEnvironmentIt == this->projectConfig->environments.end()) { - throw InvalidConfig( - "Environment (\"" + this->selectedEnvironmentName + "\") not found in configuration." - ); - } + if (!configFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + throw InvalidConfig( + "Failed to open Bloom configuration file. Working directory: " + Services::PathService::projectDirPath() + ); + } - this->environmentConfig = selectedEnvironmentIt->second; + try { + const auto configNode = YAML::Load(configFile.readAll().toStdString()); + configFile.close(); + + this->projectConfig = ProjectConfig(configNode); + + } catch (const YAML::Exception& exception) { + throw InvalidConfig(exception.msg); + } + + // Validate the selected environment + const auto selectedEnvironmentIt = this->projectConfig->environments.find(this->selectedEnvironmentName); + if (selectedEnvironmentIt == this->projectConfig->environments.end()) { + throw InvalidConfig( + "Environment (\"" + this->selectedEnvironmentName + "\") not found in configuration." + ); + } + + this->environmentConfig = selectedEnvironmentIt->second; #ifndef EXCLUDE_INSIGHT - if (this->environmentConfig->insightConfig.has_value()) { - this->insightConfig = this->environmentConfig->insightConfig.value(); + if (this->environmentConfig->insightConfig.has_value()) { + this->insightConfig = this->environmentConfig->insightConfig.value(); - } else if (this->projectConfig->insightConfig.has_value()) { - this->insightConfig = this->projectConfig->insightConfig.value(); + } else if (this->projectConfig->insightConfig.has_value()) { + this->insightConfig = this->projectConfig->insightConfig.value(); - } else { - throw InvalidConfig("Insight configuration missing."); - } + } else { + throw InvalidConfig("Insight configuration missing."); + } #endif - if (this->environmentConfig->debugServerConfig.has_value()) { - this->debugServerConfig = this->environmentConfig->debugServerConfig.value(); + if (this->environmentConfig->debugServerConfig.has_value()) { + this->debugServerConfig = this->environmentConfig->debugServerConfig.value(); - } else if (this->projectConfig->debugServerConfig.has_value()) { - this->debugServerConfig = this->projectConfig->debugServerConfig.value(); + } else if (this->projectConfig->debugServerConfig.has_value()) { + this->debugServerConfig = this->projectConfig->debugServerConfig.value(); - } else { - throw InvalidConfig("Debug server configuration missing."); - } + } else { + throw InvalidConfig("Debug server configuration missing."); + } +} + +int Application::presentHelpText() { + /* + * Silence all logging here, as we're just to display the help text and then exit the application. Any + * further logging will just be noise. + */ + Logger::silence(); + + // The file help.txt is included in Bloom's binary, as a resource. See the root-level CMakeLists.txt for more. + auto helpFile = QFile(QString::fromStdString(Services::PathService::compiledResourcesPath() + "/resources/help.txt")); + + if (!helpFile.open(QIODevice::ReadOnly)) { + // This should never happen - if it does, something has gone very wrong + throw Exception( + "Failed to open help file - please report this issue at " + Services::PathService::homeDomainName() + + "/report-issue" + ); } - int Application::presentHelpText() { - /* - * Silence all logging here, as we're just to display the help text and then exit the application. Any - * further logging will just be noise. - */ - Logger::silence(); + std::cout << "Bloom v" << Application::VERSION.toString() << "\n"; + std::cout << QTextStream(&helpFile).readAll().toUtf8().constData() << "\n"; + return EXIT_SUCCESS; +} - // The file help.txt is included in Bloom's binary, as a resource. See the root-level CMakeLists.txt for more. - auto helpFile = QFile(QString::fromStdString(Services::PathService::compiledResourcesPath() + "/resources/help.txt")); +int Application::presentVersionText() { + Logger::silence(); - if (!helpFile.open(QIODevice::ReadOnly)) { - // This should never happen - if it does, something has gone very wrong - throw Exception( - "Failed to open help file - please report this issue at " + Services::PathService::homeDomainName() - + "/report-issue" - ); - } - - std::cout << "Bloom v" << Application::VERSION.toString() << "\n"; - std::cout << QTextStream(&helpFile).readAll().toUtf8().constData() << "\n"; - return EXIT_SUCCESS; - } - - int Application::presentVersionText() { - Logger::silence(); - - std::cout << "Bloom v" << Application::VERSION.toString() << "\n"; + std::cout << "Bloom v" << Application::VERSION.toString() << "\n"; #ifdef EXCLUDE_INSIGHT - std::cout << "Insight has been excluded from this build.\n"; + std::cout << "Insight has been excluded from this build.\n"; #endif #ifdef BLOOM_DEBUG_BUILD - std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n"; + std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n"; #endif - std::cout << Services::PathService::homeDomainName() + "/\n"; - std::cout << "Nav Mohammed\n"; - return EXIT_SUCCESS; - } + std::cout << Services::PathService::homeDomainName() + "/\n"; + std::cout << "Nav Mohammed\n"; + return EXIT_SUCCESS; +} - int Application::presentVersionMachineText() { - Logger::silence(); +int Application::presentVersionMachineText() { + Logger::silence(); - auto insightAvailable = true; + auto insightAvailable = true; #ifdef EXCLUDE_INSIGHT - insightAvailable = false; + insightAvailable = false; #endif - std::cout << QJsonDocument(QJsonObject({ - {"version", QString::fromStdString(Application::VERSION.toString())}, - {"components", QJsonObject({ - {"major", Application::VERSION.major}, - {"minor", Application::VERSION.minor}, - {"patch", Application::VERSION.patch}, - })}, - {"insightAvailable", insightAvailable}, - })).toJson().toStdString(); + std::cout << QJsonDocument(QJsonObject({ + {"version", QString::fromStdString(Application::VERSION.toString())}, + {"components", QJsonObject({ + {"major", Application::VERSION.major}, + {"minor", Application::VERSION.minor}, + {"patch", Application::VERSION.patch}, + })}, + {"insightAvailable", insightAvailable}, + })).toJson().toStdString(); - return EXIT_SUCCESS; + return EXIT_SUCCESS; +} + +int Application::initProject() { + auto configFile = QFile(QString::fromStdString(Services::PathService::projectConfigPath())); + + if (configFile.exists()) { + throw Exception("Bloom configuration file (bloom.yaml) already exists in working directory."); } - int Application::initProject() { - auto configFile = QFile(QString::fromStdString(Services::PathService::projectConfigPath())); + /* + * The file bloom.template.yaml is just a template Bloom config file that is included in Bloom's binary, as a + * resource. See the root-level CMakeLists.txt for more. + * + * We simply copy the template file into the user's working directory. + */ + auto templateConfigFile = QFile( + QString::fromStdString(Services::PathService::compiledResourcesPath()+ "/resources/bloom.template.yaml") + ); - if (configFile.exists()) { - throw Exception("Bloom configuration file (bloom.yaml) already exists in working directory."); - } + if (!templateConfigFile.open(QIODevice::ReadOnly)) { + throw Exception( + "Failed to open template configuration file - please report this issue at " + + Services::PathService::homeDomainName() + "/report-issue" + ); + } + + if (!configFile.open(QIODevice::ReadWrite)) { + throw Exception("Failed to create Bloom configuration file (bloom.yaml)"); + } + + configFile.write(templateConfigFile.readAll()); + + configFile.close(); + templateConfigFile.close(); + + Logger::info("Bloom configuration file (bloom.yaml) created in working directory."); + return EXIT_SUCCESS; +} + +void Application::startSignalHandler() { + this->signalHandlerThread = std::thread(&SignalHandler::run, std::ref(this->signalHandler)); +} + +void Application::stopSignalHandler() { + const auto shThreadState = this->signalHandler.getThreadState(); + + if (shThreadState != ThreadState::STOPPED && shThreadState != ThreadState::UNINITIALISED) { + this->signalHandler.triggerShutdown(); /* - * The file bloom.template.yaml is just a template Bloom config file that is included in Bloom's binary, as a - * resource. See the root-level CMakeLists.txt for more. - * - * We simply copy the template file into the user's working directory. + * Send meaningless signal to the SignalHandler thread to have it shutdown. The signal will pull it out of + * a blocking state and allow it to action the shutdown. See SignalHandler::run() for more. */ - auto templateConfigFile = QFile( - QString::fromStdString(Services::PathService::compiledResourcesPath()+ "/resources/bloom.template.yaml") - ); - - if (!templateConfigFile.open(QIODevice::ReadOnly)) { - throw Exception( - "Failed to open template configuration file - please report this issue at " - + Services::PathService::homeDomainName() + "/report-issue" - ); - } - - if (!configFile.open(QIODevice::ReadWrite)) { - throw Exception("Failed to create Bloom configuration file (bloom.yaml)"); - } - - configFile.write(templateConfigFile.readAll()); - - configFile.close(); - templateConfigFile.close(); - - Logger::info("Bloom configuration file (bloom.yaml) created in working directory."); - return EXIT_SUCCESS; + pthread_kill(this->signalHandlerThread.native_handle(), SIGUSR1); } - void Application::startSignalHandler() { - this->signalHandlerThread = std::thread(&SignalHandler::run, std::ref(this->signalHandler)); - } - - void Application::stopSignalHandler() { - const auto shThreadState = this->signalHandler.getThreadState(); - - if (shThreadState != ThreadState::STOPPED && shThreadState != ThreadState::UNINITIALISED) { - this->signalHandler.triggerShutdown(); - - /* - * Send meaningless signal to the SignalHandler thread to have it shutdown. The signal will pull it out of - * a blocking state and allow it to action the shutdown. See SignalHandler::run() for more. - */ - pthread_kill(this->signalHandlerThread.native_handle(), SIGUSR1); - } - - if (this->signalHandlerThread.joinable()) { - Logger::debug("Joining SignalHandler thread"); - this->signalHandlerThread.join(); - Logger::debug("SignalHandler thread joined"); - } - } - - void Application::startTargetController() { - this->targetController = std::make_unique( - this->projectConfig.value(), - this->environmentConfig.value() - ); - - this->targetControllerThread = std::thread( - &TargetController::TargetControllerComponent::run, - this->targetController.get() - ); - - const auto tcStateChangeEvent = this->applicationEventListener->waitForEvent< - Events::TargetControllerThreadStateChanged - >(); - - if (!tcStateChangeEvent.has_value() || tcStateChangeEvent->get()->getState() != ThreadState::READY) { - throw Exception("TargetController failed to start up"); - } - } - - void Application::stopTargetController() { - if (this->targetController == nullptr) { - return; - } - - const auto tcThreadState = this->targetController->getThreadState(); - if (tcThreadState == ThreadState::STARTING || tcThreadState == ThreadState::READY) { - EventManager::triggerEvent(std::make_shared()); - this->applicationEventListener->waitForEvent( - std::chrono::milliseconds(10000) - ); - } - - if (this->targetControllerThread.joinable()) { - Logger::debug("Joining TargetController thread"); - this->targetControllerThread.join(); - Logger::debug("TargetController thread joined"); - } - } - - void Application::startDebugServer() { - this->debugServer = std::make_unique( - this->debugServerConfig.value() - ); - - this->debugServerThread = std::thread( - &DebugServer::DebugServerComponent::run, - this->debugServer.get() - ); - - const auto dsStateChangeEvent = this->applicationEventListener->waitForEvent< - Events::DebugServerThreadStateChanged - >(); - - if (!dsStateChangeEvent.has_value() || dsStateChangeEvent->get()->getState() != ThreadState::READY) { - throw Exception("DebugServer failed to start up"); - } - } - - void Application::stopDebugServer() { - if (this->debugServer == nullptr) { - return; - } - - const auto debugServerState = this->debugServer->getThreadState(); - if (debugServerState == ThreadState::STARTING || debugServerState == ThreadState::READY) { - EventManager::triggerEvent(std::make_shared()); - this->applicationEventListener->waitForEvent( - std::chrono::milliseconds(5000) - ); - } - - if (this->debugServerThread.joinable()) { - Logger::debug("Joining DebugServer thread"); - this->debugServerThread.join(); - Logger::debug("DebugServer thread joined"); - } - } - - void Application::dispatchEvents() { - this->applicationEventListener->dispatchCurrentEvents(); - } - - void Application::checkBloomVersion() { - const auto currentVersionNumber = Application::VERSION; - - auto* networkAccessManager = new QNetworkAccessManager(this); - auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/latest-version")); - queryVersionEndpointUrl.setScheme("http"); - queryVersionEndpointUrl.setQuery(QUrlQuery({ - {"currentVersionNumber", QString::fromStdString(currentVersionNumber.toString())} - })); - - QObject::connect( - networkAccessManager, - &QNetworkAccessManager::finished, - this, - [this, currentVersionNumber] (QNetworkReply* response) { - const auto jsonResponseObject = QJsonDocument::fromJson(response->readAll()).object(); - const auto latestVersionNumber = VersionNumber(jsonResponseObject.value("latestVersionNumber").toString()); - - if (latestVersionNumber > currentVersionNumber) { - Logger::warning( - "Bloom v" + latestVersionNumber.toString() - + " is available to download - upgrade via " + Services::PathService::homeDomainName() - ); - } - } - ); - - networkAccessManager->get(QNetworkRequest(queryVersionEndpointUrl)); - } - -#ifndef EXCLUDE_INSIGHT - void Application::activateInsight() { - assert(!this->insight); - - this->insight = std::make_unique( - *(this->applicationEventListener), - this->projectConfig.value(), - this->environmentConfig.value(), - this->insightConfig.value(), - this->projectSettings.value().insightSettings, - &(this->qtApplication) - ); - } - - void Application::onInsightActivationRequest(const Events::InsightActivationRequested&) { - if (this->insight) { - // Insight has already been activated - this->insight->activateMainWindow(); - return; - } - - this->activateInsight(); - } - - void Application::onInsightMainWindowClosed(const Events::InsightMainWindowClosed& event) { - if (this->insightConfig->shutdownOnClose) { - this->triggerShutdown(); - } - } -#endif - - void Application::onShutdownApplicationRequest(const Events::ShutdownApplication&) { - Logger::debug("ShutdownApplication event received."); - this->triggerShutdown(); - } - - void Application::onTargetControllerThreadStateChanged(const Events::TargetControllerThreadStateChanged& event) { - if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) { - // TargetController has unexpectedly shutdown. - this->triggerShutdown(); - } - } - - void Application::onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event) { - if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) { - // DebugServer has unexpectedly shutdown - it must have encountered a fatal error. - this->triggerShutdown(); - } - } - - void Application::onDebugSessionFinished(const Events::DebugSessionFinished& event) { - if (this->environmentConfig->shutdownPostDebugSession || Services::ProcessService::isManagedByClion()) { - this->triggerShutdown(); - } + if (this->signalHandlerThread.joinable()) { + Logger::debug("Joining SignalHandler thread"); + this->signalHandlerThread.join(); + Logger::debug("SignalHandler thread joined"); + } +} + +void Application::startTargetController() { + this->targetController = std::make_unique( + this->projectConfig.value(), + this->environmentConfig.value() + ); + + this->targetControllerThread = std::thread( + &TargetController::TargetControllerComponent::run, + this->targetController.get() + ); + + const auto tcStateChangeEvent = this->applicationEventListener->waitForEvent< + Events::TargetControllerThreadStateChanged + >(); + + if (!tcStateChangeEvent.has_value() || tcStateChangeEvent->get()->getState() != ThreadState::READY) { + throw Exception("TargetController failed to start up"); + } +} + +void Application::stopTargetController() { + if (this->targetController == nullptr) { + return; + } + + const auto tcThreadState = this->targetController->getThreadState(); + if (tcThreadState == ThreadState::STARTING || tcThreadState == ThreadState::READY) { + EventManager::triggerEvent(std::make_shared()); + this->applicationEventListener->waitForEvent( + std::chrono::milliseconds(10000) + ); + } + + if (this->targetControllerThread.joinable()) { + Logger::debug("Joining TargetController thread"); + this->targetControllerThread.join(); + Logger::debug("TargetController thread joined"); + } +} + +void Application::startDebugServer() { + this->debugServer = std::make_unique( + this->debugServerConfig.value() + ); + + this->debugServerThread = std::thread( + &DebugServer::DebugServerComponent::run, + this->debugServer.get() + ); + + const auto dsStateChangeEvent = this->applicationEventListener->waitForEvent< + Events::DebugServerThreadStateChanged + >(); + + if (!dsStateChangeEvent.has_value() || dsStateChangeEvent->get()->getState() != ThreadState::READY) { + throw Exception("DebugServer failed to start up"); + } +} + +void Application::stopDebugServer() { + if (this->debugServer == nullptr) { + return; + } + + const auto debugServerState = this->debugServer->getThreadState(); + if (debugServerState == ThreadState::STARTING || debugServerState == ThreadState::READY) { + EventManager::triggerEvent(std::make_shared()); + this->applicationEventListener->waitForEvent( + std::chrono::milliseconds(5000) + ); + } + + if (this->debugServerThread.joinable()) { + Logger::debug("Joining DebugServer thread"); + this->debugServerThread.join(); + Logger::debug("DebugServer thread joined"); + } +} + +void Application::dispatchEvents() { + this->applicationEventListener->dispatchCurrentEvents(); +} + +void Application::checkBloomVersion() { + const auto currentVersionNumber = Application::VERSION; + + auto* networkAccessManager = new QNetworkAccessManager(this); + auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/latest-version")); + queryVersionEndpointUrl.setScheme("http"); + queryVersionEndpointUrl.setQuery(QUrlQuery({ + {"currentVersionNumber", QString::fromStdString(currentVersionNumber.toString())} + })); + + QObject::connect( + networkAccessManager, + &QNetworkAccessManager::finished, + this, + [this, currentVersionNumber] (QNetworkReply* response) { + const auto jsonResponseObject = QJsonDocument::fromJson(response->readAll()).object(); + const auto latestVersionNumber = VersionNumber(jsonResponseObject.value("latestVersionNumber").toString()); + + if (latestVersionNumber > currentVersionNumber) { + Logger::warning( + "Bloom v" + latestVersionNumber.toString() + + " is available to download - upgrade via " + Services::PathService::homeDomainName() + ); + } + } + ); + + networkAccessManager->get(QNetworkRequest(queryVersionEndpointUrl)); +} + +#ifndef EXCLUDE_INSIGHT +void Application::activateInsight() { + assert(!this->insight); + + this->insight = std::make_unique( + *(this->applicationEventListener), + this->projectConfig.value(), + this->environmentConfig.value(), + this->insightConfig.value(), + this->projectSettings.value().insightSettings, + &(this->qtApplication) + ); +} + +void Application::onInsightActivationRequest(const Events::InsightActivationRequested&) { + if (this->insight) { + // Insight has already been activated + this->insight->activateMainWindow(); + return; + } + + this->activateInsight(); +} + +void Application::onInsightMainWindowClosed(const Events::InsightMainWindowClosed& event) { + if (this->insightConfig->shutdownOnClose) { + this->triggerShutdown(); + } +} +#endif + +void Application::onShutdownApplicationRequest(const Events::ShutdownApplication&) { + Logger::debug("ShutdownApplication event received."); + this->triggerShutdown(); +} + +void Application::onTargetControllerThreadStateChanged(const Events::TargetControllerThreadStateChanged& event) { + if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) { + // TargetController has unexpectedly shutdown. + this->triggerShutdown(); + } +} + +void Application::onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event) { + if (event.getState() == ThreadState::STOPPED || event.getState() == ThreadState::SHUTDOWN_INITIATED) { + // DebugServer has unexpectedly shutdown - it must have encountered a fatal error. + this->triggerShutdown(); + } +} + +void Application::onDebugSessionFinished(const Events::DebugSessionFinished& event) { + if (this->environmentConfig->shutdownPostDebugSession || Services::ProcessService::isManagedByClion()) { + this->triggerShutdown(); } } diff --git a/src/Application.hpp b/src/Application.hpp index 1333ea09..3588b2bf 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -31,291 +31,289 @@ #include "src/VersionNumber.hpp" -namespace Bloom + +/** + * Bloom - a debug interface for embedded systems development on Linux. + * + * This is the main entry-point of execution for the Bloom program. The methods within will run on the main + * thread. If Insight is enabled, execution will be passed over to Insight::run() upon start up. + */ +class Application: public QObject, public Thread { + Q_OBJECT + +public: + static const inline VersionNumber VERSION = VersionNumber(std::string(BLOOM_VERSION)); + + explicit Application(std::vector&& arguments); + /** - * Bloom - a debug interface for embedded systems development on Linux. + * Main entry-point for the Bloom program. * - * This is the main entry-point of execution for the Bloom program. The methods within will run on the main - * thread. If Insight is enabled, execution will be passed over to Insight::run() upon start up. + * @return */ - class Application: public QObject, public Thread - { - Q_OBJECT + int run(); - public: - static const inline VersionNumber VERSION = VersionNumber(std::string(BLOOM_VERSION)); +private: + std::vector arguments; - explicit Application(std::vector&& arguments); - - /** - * Main entry-point for the Bloom program. - * - * @return - */ - int run(); - - private: - std::vector arguments; - - std::string qtApplicationName = "Bloom"; - std::array qtApplicationArgv = {this->qtApplicationName.data()}; - int qtApplicationArgc = 1; + std::string qtApplicationName = "Bloom"; + std::array qtApplicationArgv = {this->qtApplicationName.data()}; + int qtApplicationArgc = 1; #ifndef EXCLUDE_INSIGHT - QApplication qtApplication; + QApplication qtApplication; #else - QCoreApplication qtApplication; + QCoreApplication qtApplication; #endif - EventListenerPointer applicationEventListener = std::make_shared("ApplicationEventListener"); + EventListenerPointer applicationEventListener = std::make_shared("ApplicationEventListener"); - /** - * The SignalHandler deals with any UNIX signals. It runs on a dedicated thread. All other threads - * ignore UNIX signals. - * - * See the SignalHandler class for more on this. - */ - SignalHandler signalHandler = SignalHandler(); - std::thread signalHandlerThread; + /** + * The SignalHandler deals with any UNIX signals. It runs on a dedicated thread. All other threads + * ignore UNIX signals. + * + * See the SignalHandler class for more on this. + */ + SignalHandler signalHandler = SignalHandler(); + std::thread signalHandlerThread; - /** - * The TargetController possesses full control of the connected debug tool and target. It runs on a - * dedicated thread. - * - * See the TargetController class for more on this. - * - * I could have used std::optional here, for the late initialisation, but given that we're using - * std::unique_ptr for the debug server (for polymorphism), I thought I'd keep it consistent. - */ - std::unique_ptr targetController = nullptr; - std::thread targetControllerThread; + /** + * The TargetController possesses full control of the connected debug tool and target. It runs on a + * dedicated thread. + * + * See the TargetController class for more on this. + * + * I could have used std::optional here, for the late initialisation, but given that we're using + * std::unique_ptr for the debug server (for polymorphism), I thought I'd keep it consistent. + */ + std::unique_ptr targetController = nullptr; + std::thread targetControllerThread; - /** - * The DebugServer exposes an interface to the connected target, to third-party software such as IDEs. It runs - * on a dedicated thread. - * - * See the DebugServer and GdbRspDebugServer class for more on this. - */ - std::unique_ptr debugServer = nullptr; - std::thread debugServerThread; + /** + * The DebugServer exposes an interface to the connected target, to third-party software such as IDEs. It runs + * on a dedicated thread. + * + * See the DebugServer and GdbRspDebugServer class for more on this. + */ + std::unique_ptr debugServer = nullptr; + std::thread debugServerThread; #ifndef EXCLUDE_INSIGHT - /** - * Insight is a small Qt application that serves a GUI to the user. It occupies the main thread, as well as a - * single worker thread, and possibly other threads created by Qt. - * - * Insight is optional - users can disable it via their project configuration. - * - * When the user closes the Insight GUI, control of the main thread is returned to Application::run(). See the - * Insight class for more on this. - * - * Because Insight is optional, we only construct the Insight object when we need it. We can't use - * std::optional here because the Insight class extends QObject, which disables the copy constructor and - * the assignment operator. So we use an std::unique_ptr instead, which is perfectly fine for this use case, - * as we want to manage the lifetime of the object here. - */ - std::unique_ptr insight = nullptr; + /** + * Insight is a small Qt application that serves a GUI to the user. It occupies the main thread, as well as a + * single worker thread, and possibly other threads created by Qt. + * + * Insight is optional - users can disable it via their project configuration. + * + * When the user closes the Insight GUI, control of the main thread is returned to Application::run(). See the + * Insight class for more on this. + * + * Because Insight is optional, we only construct the Insight object when we need it. We can't use + * std::optional here because the Insight class extends QObject, which disables the copy constructor and + * the assignment operator. So we use an std::unique_ptr instead, which is perfectly fine for this use case, + * as we want to manage the lifetime of the object here. + */ + std::unique_ptr insight = nullptr; - /** - * Activation of the Insight GUI can be requested by triggering an InsightActivationRequested event. - * - * This flag will be set upon that event being triggered. The Insight GUI will be started shortly after. - */ - bool insightActivationPending = false; + /** + * Activation of the Insight GUI can be requested by triggering an InsightActivationRequested event. + * + * This flag will be set upon that event being triggered. The Insight GUI will be started shortly after. + */ + bool insightActivationPending = false; #endif - /** - * Configuration extracted from the user's project configuration file. - * - * See ProjectConfig.hpp for more on this. - */ - std::optional projectConfig; - std::optional environmentConfig; - std::optional debugServerConfig; - std::optional insightConfig; + /** + * Configuration extracted from the user's project configuration file. + * + * See ProjectConfig.hpp for more on this. + */ + std::optional projectConfig; + std::optional environmentConfig; + std::optional debugServerConfig; + std::optional insightConfig; - /** - * Settings extracted from the settings file in the user's project root. - */ - std::optional projectSettings; + /** + * Settings extracted from the settings file in the user's project root. + */ + std::optional projectSettings; - /** - * The project environment selected by the user. - * - * If an environment name is not provided as an argument when running Bloom, Bloom will fallback to the - * environment named "default". - */ - std::string selectedEnvironmentName = "default"; + /** + * The project environment selected by the user. + * + * If an environment name is not provided as an argument when running Bloom, Bloom will fallback to the + * environment named "default". + */ + std::string selectedEnvironmentName = "default"; - /** - * Some CLI arguments are interpreted as commands and thus require specific handler methods to be called. - * This mapping maps command names to the appropriate handler methods. The mapped handler method is invoked - * when the command name is provided as an argument from the CLI. - * - * See Application::run() for more on this. - * - * @return - */ - std::map> getCommandHandlersByCommandName(); + /** + * Some CLI arguments are interpreted as commands and thus require specific handler methods to be called. + * This mapping maps command names to the appropriate handler methods. The mapped handler method is invoked + * when the command name is provided as an argument from the CLI. + * + * See Application::run() for more on this. + * + * @return + */ + std::map> getCommandHandlersByCommandName(); - /** - * Kicks off the application. - * - * Will start the TargetController and DebugServer. And register the main application's event handlers. - */ - void startup(); + /** + * Kicks off the application. + * + * Will start the TargetController and DebugServer. And register the main application's event handlers. + */ + void startup(); - /** - * Will cleanly shutdown the application. - */ - void shutdown(); + /** + * Will cleanly shutdown the application. + */ + void shutdown(); - /** - * Will trigger a clean shutdown. - */ - void triggerShutdown(); + /** + * Will trigger a clean shutdown. + */ + void triggerShutdown(); - /** - * Extracts or generates project settings. - */ - void loadProjectSettings(); + /** + * Extracts or generates project settings. + */ + void loadProjectSettings(); - /** - * Saves the current project settings. - */ - void saveProjectSettings(); + /** + * Saves the current project settings. + */ + void saveProjectSettings(); - /** - * Extracts the project config from the user's config file and populates the following members: - * - this->projectConfig - * - this->environmentConfig - * - this->debugServerConfig - * - this->insightConfig - * - * @see ProjectConfig declaration for more on this. - */ - void loadProjectConfiguration(); + /** + * Extracts the project config from the user's config file and populates the following members: + * - this->projectConfig + * - this->environmentConfig + * - this->debugServerConfig + * - this->insightConfig + * + * @see ProjectConfig declaration for more on this. + */ + void loadProjectConfiguration(); - /** - * Presents application help text to user. - * - * @return - */ - int presentHelpText(); + /** + * Presents application help text to user. + * + * @return + */ + int presentHelpText(); - /** - * Presents the current Bloom version number to user. - * - * @return - */ - int presentVersionText(); + /** + * Presents the current Bloom version number to user. + * + * @return + */ + int presentVersionText(); - /** - * Presents the current Bloom version number, in JSON format. - * - * @return - */ - int presentVersionMachineText(); + /** + * Presents the current Bloom version number, in JSON format. + * + * @return + */ + int presentVersionMachineText(); - /** - * Initialises a project in the user's working directory. - * - * @return - */ - int initProject(); + /** + * Initialises a project in the user's working directory. + * + * @return + */ + int initProject(); - /** - * Prepares a dedicated thread for the SignalHandler and kicks it off with a call to SignalHandler::run(). - */ - void startSignalHandler(); + /** + * Prepares a dedicated thread for the SignalHandler and kicks it off with a call to SignalHandler::run(). + */ + void startSignalHandler(); - /** - * Sends a shutdown request to the SignalHandler and waits on the dedicated thread to exit. - */ - void stopSignalHandler(); + /** + * Sends a shutdown request to the SignalHandler and waits on the dedicated thread to exit. + */ + void stopSignalHandler(); - /** - * Prepares a dedicated thread for the TargetController and kicks it off with a call to - * TargetControllerComponent::run(). - */ - void startTargetController(); + /** + * Prepares a dedicated thread for the TargetController and kicks it off with a call to + * TargetControllerComponent::run(). + */ + void startTargetController(); - /** - * Invokes a clean shutdown of the TargetController. The TargetController should disconnect from the target - * and debug tool in a clean and safe manner, ensuring that both are left in a sensible state. - * - * This will join the TargetController thread. - */ - void stopTargetController(); + /** + * Invokes a clean shutdown of the TargetController. The TargetController should disconnect from the target + * and debug tool in a clean and safe manner, ensuring that both are left in a sensible state. + * + * This will join the TargetController thread. + */ + void stopTargetController(); - /** - * Prepares a dedicated thread for the DebugServer and kicks it off with a call to DebugServer::run(). - */ - void startDebugServer(); + /** + * Prepares a dedicated thread for the DebugServer and kicks it off with a call to DebugServer::run(). + */ + void startDebugServer(); - /** - * Sends a shutdown request to the DebugServer thread and waits on it to exit. - */ - void stopDebugServer(); + /** + * Sends a shutdown request to the DebugServer thread and waits on it to exit. + */ + void stopDebugServer(); - /** - * Dispatches any pending events. This function will be called periodically, via a QTimer. - */ - void dispatchEvents(); + /** + * Dispatches any pending events. This function will be called periodically, via a QTimer. + */ + void dispatchEvents(); - /** - * Queries the Bloom server for the latest version number. If the current version number doesn't match the - * latest version number returned by the server, we'll display a warning in the logs to instruct the user to - * upgrade. - */ - void checkBloomVersion(); + /** + * Queries the Bloom server for the latest version number. If the current version number doesn't match the + * latest version number returned by the server, we'll display a warning in the logs to instruct the user to + * upgrade. + */ + void checkBloomVersion(); #ifndef EXCLUDE_INSIGHT - /** - * Activate the Insight GUI. - * - * This function should never be called more than once. - */ - void activateInsight(); + /** + * Activate the Insight GUI. + * + * This function should never be called more than once. + */ + void activateInsight(); - /** - * Handles requests to start the Insight GUI. - */ - void onInsightActivationRequest(const Events::InsightActivationRequested&); + /** + * Handles requests to start the Insight GUI. + */ + void onInsightActivationRequest(const Events::InsightActivationRequested&); - /** - * Performs any post-insight-closed actions. - * - * @param event - */ - void onInsightMainWindowClosed(const Events::InsightMainWindowClosed& event); + /** + * Performs any post-insight-closed actions. + * + * @param event + */ + void onInsightMainWindowClosed(const Events::InsightMainWindowClosed& event); #endif - /** - * Triggers a shutdown of Bloom and all of its components. - */ - void onShutdownApplicationRequest(const Events::ShutdownApplication&); + /** + * Triggers a shutdown of Bloom and all of its components. + */ + void onShutdownApplicationRequest(const Events::ShutdownApplication&); - /** - * If the TargetController unexpectedly shuts down, the rest of the application will follow. - * - * @param event - */ - void onTargetControllerThreadStateChanged(const Events::TargetControllerThreadStateChanged& event); + /** + * If the TargetController unexpectedly shuts down, the rest of the application will follow. + * + * @param event + */ + void onTargetControllerThreadStateChanged(const Events::TargetControllerThreadStateChanged& event); - /** - * Same goes for the DebugServer - it should never shutdown unless a shutdown request was issued. If it does, - * something horrible has happened and so we shutdown the rest of the application in response. - * - * @param event - */ - void onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event); + /** + * Same goes for the DebugServer - it should never shutdown unless a shutdown request was issued. If it does, + * something horrible has happened and so we shutdown the rest of the application in response. + * + * @param event + */ + void onDebugServerThreadStateChanged(const Events::DebugServerThreadStateChanged& event); - /** - * If configured to do so, Bloom will shutdown upon the end of the current debug session. - * - * @param event - */ - void onDebugSessionFinished(const Events::DebugSessionFinished& event); - }; -} + /** + * If configured to do so, Bloom will shutdown upon the end of the current debug session. + * + * @param event + */ + void onDebugSessionFinished(const Events::DebugSessionFinished& event); +}; diff --git a/src/DebugServer/DebugServerComponent.cpp b/src/DebugServer/DebugServerComponent.cpp index 3867c3c8..88a8dcb5 100644 --- a/src/DebugServer/DebugServerComponent.cpp +++ b/src/DebugServer/DebugServerComponent.cpp @@ -8,9 +8,9 @@ #include "src/Exceptions/InvalidConfig.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom::DebugServer +namespace DebugServer { - using namespace Bloom::Events; + using namespace Events; DebugServerComponent::DebugServerComponent(const DebugServerConfig& debugServerConfig) : debugServerConfig(debugServerConfig) diff --git a/src/DebugServer/DebugServerComponent.hpp b/src/DebugServer/DebugServerComponent.hpp index a3068476..617c2f69 100644 --- a/src/DebugServer/DebugServerComponent.hpp +++ b/src/DebugServer/DebugServerComponent.hpp @@ -13,7 +13,7 @@ #include "ServerInterface.hpp" -namespace Bloom::DebugServer +namespace DebugServer { /** * The DebugServer exposes the connected target to third-party debugging software such as IDEs. diff --git a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp index 031a9d7a..b3feabb4 100644 --- a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp +++ b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp @@ -11,12 +11,12 @@ #include "CommandPackets/FlashWrite.hpp" #include "CommandPackets/FlashDone.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb +namespace DebugServer::Gdb::AvrGdb { - using namespace Bloom::Exceptions; + using namespace Exceptions; - using Bloom::Targets::TargetRegisterDescriptor; - using Bloom::Targets::TargetRegisterType; + using Targets::TargetRegisterDescriptor; + using Targets::TargetRegisterType; AvrGdbRsp::AvrGdbRsp( const DebugServerConfig& debugServerConfig, diff --git a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp index a0158c34..b294b91d 100644 --- a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp +++ b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp @@ -6,7 +6,7 @@ #include "src/DebugServer/Gdb/GdbRspDebugServer.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb +namespace DebugServer::Gdb::AvrGdb { class AvrGdbRsp: public GdbRspDebugServer { diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.cpp index 50d5ba05..3538d6d3 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.cpp @@ -6,14 +6,14 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; using ResponsePackets::OkResponsePacket; - using namespace Bloom::Exceptions; + using namespace Exceptions; FlashDone::FlashDone(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.hpp index 6d8de761..498a0f6f 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The FlashDone class implements the structure for the "vFlashDone" packet. diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashErase.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashErase.cpp index 686995db..32b32183 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashErase.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashErase.cpp @@ -6,14 +6,14 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; using ResponsePackets::OkResponsePacket; - using namespace Bloom::Exceptions; + using namespace Exceptions; FlashErase::FlashErase(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashErase.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashErase.hpp index dfaaa647..004309f7 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashErase.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashErase.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The FlashErase class implements the structure for the "vFlashErase" packet. Upon receiving this packet, the diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashWrite.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashWrite.cpp index 57d179eb..b1cb28bb 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashWrite.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashWrite.cpp @@ -8,14 +8,14 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; using ResponsePackets::OkResponsePacket; - using namespace Bloom::Exceptions; + using namespace Exceptions; FlashWrite::FlashWrite(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashWrite.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashWrite.hpp index d671c620..2aa2e955 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashWrite.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashWrite.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The FlashWrite class implements the structure for the "vFlashWrite" packet. Upon receiving this packet, the diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp index 011eadbb..acc7bf6f 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp @@ -8,7 +8,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.hpp index f2980a00..998c12e1 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The ReadMemory class implements a structure for "m" packets. Upon receiving these packets, the server is diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.cpp index 4faaa4e0..f64f0c5d 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.cpp @@ -4,7 +4,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.hpp index e7a9eea1..ecfb87a7 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.hpp @@ -4,7 +4,7 @@ #include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The ReadMemoryMap class implements a structure for the "qXfer:memory-map:read::..." packet. Upon receiving this diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegister.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegister.cpp index cdfc02cd..804ec259 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegister.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegister.cpp @@ -10,7 +10,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegister.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegister.hpp index fa5f765d..c35658a4 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegister.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegister.hpp @@ -4,7 +4,7 @@ #include "src/DebugServer/Gdb/RegisterDescriptor.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The ReadRegister class implements a structure for the "p" command packet. In response to this packet, the server diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegisters.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegisters.cpp index c7f91a7e..fd432edf 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegisters.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegisters.cpp @@ -11,7 +11,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegisters.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegisters.hpp index cce6fc66..c85e22eb 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegisters.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadRegisters.hpp @@ -6,7 +6,7 @@ #include "src/DebugServer/Gdb/RegisterDescriptor.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The ReadRegisters class implements a structure for the "g" command packet. In response to this packet, the diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp index 44113e5a..0f64b37c 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp @@ -6,14 +6,14 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; using ResponsePackets::OkResponsePacket; - using namespace Bloom::Exceptions; + using namespace Exceptions; WriteMemory::WriteMemory(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.hpp index 1bc1661b..7d50c5a0 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The WriteMemory class implements the structure for "M" packets. Upon receiving this packet, the server is diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteRegister.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteRegister.cpp index a9ffa4f9..aad4865f 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteRegister.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteRegister.cpp @@ -8,7 +8,7 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { using Services::TargetControllerService; diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteRegister.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteRegister.hpp index 7ea37dcd..bb664f1e 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteRegister.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteRegister.hpp @@ -7,7 +7,7 @@ #include "src/Targets/TargetRegister.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::AvrGdb::CommandPackets { /** * The WriteRegister class implements the structure for "P" packets. diff --git a/src/DebugServer/Gdb/AvrGdb/TargetDescriptor.cpp b/src/DebugServer/Gdb/AvrGdb/TargetDescriptor.cpp index 53a32a12..f0209ee4 100644 --- a/src/DebugServer/Gdb/AvrGdb/TargetDescriptor.cpp +++ b/src/DebugServer/Gdb/AvrGdb/TargetDescriptor.cpp @@ -5,14 +5,14 @@ #include "src/Exceptions/Exception.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb +namespace DebugServer::Gdb::AvrGdb { - using Bloom::Targets::TargetRegisterDescriptor; - using Bloom::Targets::TargetRegisterType; + using Targets::TargetRegisterDescriptor; + using Targets::TargetRegisterType; - using Bloom::Exceptions::Exception; + using Exceptions::Exception; - TargetDescriptor::TargetDescriptor(const Bloom::Targets::TargetDescriptor& targetDescriptor) + TargetDescriptor::TargetDescriptor(const Targets::TargetDescriptor& targetDescriptor) : DebugServer::Gdb::TargetDescriptor( targetDescriptor, { diff --git a/src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp b/src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp index 081235a3..33ed091e 100644 --- a/src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp +++ b/src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp @@ -2,7 +2,7 @@ #include "src/DebugServer/Gdb/TargetDescriptor.hpp" -namespace Bloom::DebugServer::Gdb::AvrGdb +namespace DebugServer::Gdb::AvrGdb { class TargetDescriptor: public DebugServer::Gdb::TargetDescriptor { diff --git a/src/DebugServer/Gdb/BreakpointType.hpp b/src/DebugServer/Gdb/BreakpointType.hpp index 65abdd45..51b352e0 100644 --- a/src/DebugServer/Gdb/BreakpointType.hpp +++ b/src/DebugServer/Gdb/BreakpointType.hpp @@ -1,6 +1,6 @@ #pragma once -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { enum class BreakpointType: int { diff --git a/src/DebugServer/Gdb/CommandPackets/ActivateInsight.cpp b/src/DebugServer/Gdb/CommandPackets/ActivateInsight.cpp index a30512c7..a41a7c4f 100644 --- a/src/DebugServer/Gdb/CommandPackets/ActivateInsight.cpp +++ b/src/DebugServer/Gdb/CommandPackets/ActivateInsight.cpp @@ -10,13 +10,13 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ResponsePacket; using ResponsePackets::ErrorResponsePacket; - using Bloom::Exceptions::Exception; + using ::Exceptions::Exception; ActivateInsight::ActivateInsight(Monitor&& monitorPacket) : Monitor(std::move(monitorPacket)) diff --git a/src/DebugServer/Gdb/CommandPackets/ActivateInsight.hpp b/src/DebugServer/Gdb/CommandPackets/ActivateInsight.hpp index 45a1c213..a23cec75 100644 --- a/src/DebugServer/Gdb/CommandPackets/ActivateInsight.hpp +++ b/src/DebugServer/Gdb/CommandPackets/ActivateInsight.hpp @@ -2,7 +2,7 @@ #include "Monitor.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The ActivateInsight class implements a structure for the "monitor insight" GDB command. diff --git a/src/DebugServer/Gdb/CommandPackets/BloomVersion.cpp b/src/DebugServer/Gdb/CommandPackets/BloomVersion.cpp index a78a8a18..5916a61a 100644 --- a/src/DebugServer/Gdb/CommandPackets/BloomVersion.cpp +++ b/src/DebugServer/Gdb/CommandPackets/BloomVersion.cpp @@ -11,17 +11,13 @@ #include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" -#include "src/Exceptions/Exception.hpp" - -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ResponsePacket; - using Exceptions::Exception; - BloomVersion::BloomVersion(Monitor&& monitorPacket) : Monitor(std::move(monitorPacket)) {} diff --git a/src/DebugServer/Gdb/CommandPackets/BloomVersion.hpp b/src/DebugServer/Gdb/CommandPackets/BloomVersion.hpp index ac66fa20..88962d98 100644 --- a/src/DebugServer/Gdb/CommandPackets/BloomVersion.hpp +++ b/src/DebugServer/Gdb/CommandPackets/BloomVersion.hpp @@ -4,7 +4,7 @@ #include "Monitor.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The BloomVersion class implements a structure for the "monitor version" GDB command. diff --git a/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp b/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp index dafff3ed..7d6850b5 100644 --- a/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp +++ b/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp @@ -11,16 +11,12 @@ #include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" -#include "src/Exceptions/Exception.hpp" - -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ResponsePacket; - using Exceptions::Exception; - BloomVersionMachine::BloomVersionMachine(Monitor&& monitorPacket) : Monitor(std::move(monitorPacket)) {} diff --git a/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.hpp b/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.hpp index 82fd949e..cd5ff4e8 100644 --- a/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.hpp +++ b/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.hpp @@ -4,7 +4,7 @@ #include "Monitor.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The BloomVersionMachine class implements a structure for the "monitor version machine" GDB command. diff --git a/src/DebugServer/Gdb/CommandPackets/CommandPacket.cpp b/src/DebugServer/Gdb/CommandPackets/CommandPacket.cpp index b947babd..97f7e506 100644 --- a/src/DebugServer/Gdb/CommandPackets/CommandPacket.cpp +++ b/src/DebugServer/Gdb/CommandPackets/CommandPacket.cpp @@ -9,9 +9,8 @@ #include "src/DebugServer/Gdb/Signal.hpp" #include "src/Logger/Logger.hpp" -#include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; @@ -21,8 +20,6 @@ namespace Bloom::DebugServer::Gdb::CommandPackets using ResponsePackets::EmptyResponsePacket; using ResponsePackets::ErrorResponsePacket; - using Exceptions::Exception; - void CommandPacket::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) { const auto packetString = std::string(this->data.begin(), this->data.end()); diff --git a/src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp b/src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp index 5c17448e..2016b562 100644 --- a/src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp +++ b/src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp @@ -8,7 +8,7 @@ #include "src/Services/TargetControllerService.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * GDB RSP command packets are sent to the server, from the GDB client. These packets carry instructions that the diff --git a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp index c2c4f856..afec13ec 100644 --- a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp @@ -5,12 +5,12 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; - using Exceptions::Exception; + using ::Exceptions::Exception; ContinueExecution::ContinueExecution(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp index 0253392f..f456edd4 100644 --- a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp @@ -7,7 +7,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The ContinueExecution class implements a structure for "c" packets. These packets instruct the server diff --git a/src/DebugServer/Gdb/CommandPackets/Detach.cpp b/src/DebugServer/Gdb/CommandPackets/Detach.cpp index 4c3f7bf7..13627ec1 100644 --- a/src/DebugServer/Gdb/CommandPackets/Detach.cpp +++ b/src/DebugServer/Gdb/CommandPackets/Detach.cpp @@ -7,14 +7,14 @@ #include "src/Logger/Logger.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::OkResponsePacket; using ResponsePackets::ErrorResponsePacket; - using Exceptions::Exception; + using ::Exceptions::Exception; Detach::Detach(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/CommandPackets/Detach.hpp b/src/DebugServer/Gdb/CommandPackets/Detach.hpp index 8289e159..cc155fd8 100644 --- a/src/DebugServer/Gdb/CommandPackets/Detach.hpp +++ b/src/DebugServer/Gdb/CommandPackets/Detach.hpp @@ -2,7 +2,7 @@ #include "CommandPacket.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { class Detach: public CommandPacket { diff --git a/src/DebugServer/Gdb/CommandPackets/EepromFill.cpp b/src/DebugServer/Gdb/CommandPackets/EepromFill.cpp index 9ebb1155..5b33e757 100644 --- a/src/DebugServer/Gdb/CommandPackets/EepromFill.cpp +++ b/src/DebugServer/Gdb/CommandPackets/EepromFill.cpp @@ -12,13 +12,14 @@ #include "src/DebugServer/Gdb/Exceptions/InvalidCommandOption.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ResponsePacket; using ResponsePackets::ErrorResponsePacket; - using Bloom::Exceptions::Exception; + + using ::Exceptions::Exception; using Exceptions::InvalidCommandOption; EepromFill::EepromFill(Monitor&& monitorPacket) diff --git a/src/DebugServer/Gdb/CommandPackets/EepromFill.hpp b/src/DebugServer/Gdb/CommandPackets/EepromFill.hpp index 320537cc..6e6fa4cf 100644 --- a/src/DebugServer/Gdb/CommandPackets/EepromFill.hpp +++ b/src/DebugServer/Gdb/CommandPackets/EepromFill.hpp @@ -6,7 +6,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The EepromFill class implements a structure for the "monitor eeprom fill" GDB command. diff --git a/src/DebugServer/Gdb/CommandPackets/GenerateSvd.cpp b/src/DebugServer/Gdb/CommandPackets/GenerateSvd.cpp index 404921e4..a8dda194 100644 --- a/src/DebugServer/Gdb/CommandPackets/GenerateSvd.cpp +++ b/src/DebugServer/Gdb/CommandPackets/GenerateSvd.cpp @@ -15,13 +15,14 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ResponsePacket; using ResponsePackets::ErrorResponsePacket; - using Exceptions::Exception; + + using ::Exceptions::Exception; GenerateSvd::GenerateSvd(Monitor&& monitorPacket) : Monitor(std::move(monitorPacket)) diff --git a/src/DebugServer/Gdb/CommandPackets/GenerateSvd.hpp b/src/DebugServer/Gdb/CommandPackets/GenerateSvd.hpp index f01a9c7f..41856f9a 100644 --- a/src/DebugServer/Gdb/CommandPackets/GenerateSvd.hpp +++ b/src/DebugServer/Gdb/CommandPackets/GenerateSvd.hpp @@ -6,7 +6,7 @@ #include "src/Targets/TargetDescriptor.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The GenerateSvd class implements a structure for the "monitor svd" GDB command. diff --git a/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp b/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp index d1df0429..6e098ca9 100644 --- a/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp +++ b/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp @@ -12,14 +12,14 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ResponsePacket; - using Exceptions::Exception; + using ::Exceptions::Exception; HelpMonitorInfo::HelpMonitorInfo(Monitor&& monitorPacket) : Monitor(std::move(monitorPacket)) diff --git a/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.hpp b/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.hpp index bfd04e68..c1cca27f 100644 --- a/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.hpp +++ b/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.hpp @@ -4,7 +4,7 @@ #include "Monitor.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The HelpMonitorInfo class implements a structure for the "monitor help" GDB command. diff --git a/src/DebugServer/Gdb/CommandPackets/InterruptExecution.cpp b/src/DebugServer/Gdb/CommandPackets/InterruptExecution.cpp index 62b7df78..03318574 100644 --- a/src/DebugServer/Gdb/CommandPackets/InterruptExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/InterruptExecution.cpp @@ -7,13 +7,14 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::TargetStopped; using ResponsePackets::ErrorResponsePacket; - using Exceptions::Exception; + + using ::Exceptions::Exception; void InterruptExecution::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) { Logger::info("Handling InterruptExecution packet"); diff --git a/src/DebugServer/Gdb/CommandPackets/InterruptExecution.hpp b/src/DebugServer/Gdb/CommandPackets/InterruptExecution.hpp index e4613b3b..f4b7a9e4 100644 --- a/src/DebugServer/Gdb/CommandPackets/InterruptExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/InterruptExecution.hpp @@ -2,7 +2,7 @@ #include "CommandPacket.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The InterruptException class represents interrupt command packets. Upon receiving an interrupt packet, the diff --git a/src/DebugServer/Gdb/CommandPackets/Monitor.cpp b/src/DebugServer/Gdb/CommandPackets/Monitor.cpp index f07d21cb..ce8834f4 100644 --- a/src/DebugServer/Gdb/CommandPackets/Monitor.cpp +++ b/src/DebugServer/Gdb/CommandPackets/Monitor.cpp @@ -4,7 +4,7 @@ #include "src/Logger/Logger.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; diff --git a/src/DebugServer/Gdb/CommandPackets/Monitor.hpp b/src/DebugServer/Gdb/CommandPackets/Monitor.hpp index b564c64c..ed17ef36 100644 --- a/src/DebugServer/Gdb/CommandPackets/Monitor.hpp +++ b/src/DebugServer/Gdb/CommandPackets/Monitor.hpp @@ -7,7 +7,7 @@ #include "CommandPacket.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * This is a base class for 'qRcmd' packets - invoked by the GDB 'monitor' command. diff --git a/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.cpp b/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.cpp index a7594525..532b9b12 100644 --- a/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.cpp +++ b/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.cpp @@ -10,7 +10,7 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; @@ -19,7 +19,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets using ResponsePackets::OkResponsePacket; using ResponsePackets::ErrorResponsePacket; - using Exceptions::Exception; + using ::Exceptions::Exception; RemoveBreakpoint::RemoveBreakpoint(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.hpp b/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.hpp index 712e6025..1473c765 100644 --- a/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.hpp +++ b/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.hpp @@ -9,7 +9,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The RemoveBreakpoint class implements the structure for "z" command packets. Upon receiving this command, the diff --git a/src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp b/src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp index 981fb450..362e0174 100644 --- a/src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp +++ b/src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp @@ -8,14 +8,14 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ResponsePacket; - using Exceptions::Exception; + using ::Exceptions::Exception; ResetTarget::ResetTarget(Monitor&& monitorPacket) : Monitor(std::move(monitorPacket)) diff --git a/src/DebugServer/Gdb/CommandPackets/ResetTarget.hpp b/src/DebugServer/Gdb/CommandPackets/ResetTarget.hpp index c9a3a13c..ead9d533 100644 --- a/src/DebugServer/Gdb/CommandPackets/ResetTarget.hpp +++ b/src/DebugServer/Gdb/CommandPackets/ResetTarget.hpp @@ -4,7 +4,7 @@ #include "Monitor.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The ResetTarget class implements a structure for the custom reset command (triggered via the "monitor reset" diff --git a/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.cpp b/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.cpp index a0b99f10..5c3aef4a 100644 --- a/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.cpp +++ b/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.cpp @@ -11,7 +11,7 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; @@ -21,7 +21,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets using ResponsePackets::ErrorResponsePacket; using ResponsePackets::EmptyResponsePacket; - using Exceptions::Exception; + using ::Exceptions::Exception; SetBreakpoint::SetBreakpoint(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.hpp b/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.hpp index e837bed3..00479110 100644 --- a/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.hpp +++ b/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.hpp @@ -9,7 +9,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The SetBreakpoint class implements the structure for "Z" command packets. Upon receiving this command, the diff --git a/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp b/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp index def90694..c029cd59 100644 --- a/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp @@ -5,13 +5,13 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::ErrorResponsePacket; - using Exceptions::Exception; + using ::Exceptions::Exception; StepExecution::StepExecution(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp b/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp index a433fe36..eac964db 100644 --- a/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp @@ -7,7 +7,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The StepExecution class implements the structure for "s" command packets. Upon receiving this command, the diff --git a/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.cpp b/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.cpp index 53b4a5de..656ac53a 100644 --- a/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.cpp +++ b/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.cpp @@ -8,18 +8,16 @@ #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/Logger/Logger.hpp" -#include "src/Exceptions/Exception.hpp" #include "src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; using ResponsePackets::SupportedFeaturesResponse; using ResponsePackets::ErrorResponsePacket; - using Bloom::Exceptions::Exception; - using Gdb::Exceptions::ClientNotSupported; + using Exceptions::ClientNotSupported; SupportedFeaturesQuery::SupportedFeaturesQuery(const RawPacket& rawPacket) : CommandPacket(rawPacket) diff --git a/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.hpp b/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.hpp index b8eeba08..78ee3368 100644 --- a/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.hpp +++ b/src/DebugServer/Gdb/CommandPackets/SupportedFeaturesQuery.hpp @@ -6,7 +6,7 @@ #include "CommandPacket.hpp" #include "../Feature.hpp" -namespace Bloom::DebugServer::Gdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The SupportedFeaturesQuery command packet is a query from the GDB client, requesting a list of GDB features diff --git a/src/DebugServer/Gdb/Connection.cpp b/src/DebugServer/Gdb/Connection.cpp index fd2cb44a..0acd5cad 100644 --- a/src/DebugServer/Gdb/Connection.cpp +++ b/src/DebugServer/Gdb/Connection.cpp @@ -15,10 +15,10 @@ #include "src/Logger/Logger.hpp" #include "src/Services/StringService.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { using namespace Exceptions; - using namespace Bloom::Exceptions; + using namespace ::Exceptions; using ResponsePackets::ResponsePacket; diff --git a/src/DebugServer/Gdb/Connection.hpp b/src/DebugServer/Gdb/Connection.hpp index 9eaa8bdd..3ff006b3 100644 --- a/src/DebugServer/Gdb/Connection.hpp +++ b/src/DebugServer/Gdb/Connection.hpp @@ -16,7 +16,7 @@ #include "src/DebugServer/Gdb/Packet.hpp" #include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { /** * The Connection class represents an active connection between the GDB RSP server and client. diff --git a/src/DebugServer/Gdb/DebugSession.cpp b/src/DebugServer/Gdb/DebugSession.cpp index ec8e1c7b..838afbbd 100644 --- a/src/DebugServer/Gdb/DebugSession.cpp +++ b/src/DebugServer/Gdb/DebugSession.cpp @@ -2,7 +2,7 @@ #include "src/EventManager/EventManager.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { DebugSession::DebugSession( Connection&& connection, diff --git a/src/DebugServer/Gdb/DebugSession.hpp b/src/DebugServer/Gdb/DebugSession.hpp index 53d46bd3..367a53fb 100644 --- a/src/DebugServer/Gdb/DebugSession.hpp +++ b/src/DebugServer/Gdb/DebugSession.hpp @@ -11,7 +11,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { class DebugSession { diff --git a/src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp b/src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp index d03f12ae..f061a233 100644 --- a/src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp +++ b/src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::Exceptions +namespace DebugServer::Gdb::Exceptions { /** * In the event that communication between the GDB RSP client and Bloom fails, a ClientCommunicationFailure @@ -10,15 +10,15 @@ namespace Bloom::DebugServer::Gdb::Exceptions * * See GdbRspDebugServer::serve() for handling code. */ - class ClientCommunicationError: public Bloom::Exceptions::Exception + class ClientCommunicationError: public ::Exceptions::Exception { public: explicit ClientCommunicationError(const std::string& message) - : Bloom::Exceptions::Exception(message) + : ::Exceptions::Exception(message) {} explicit ClientCommunicationError(const char* message) - : Bloom::Exceptions::Exception(message) + : ::Exceptions::Exception(message) {} explicit ClientCommunicationError() = default; diff --git a/src/DebugServer/Gdb/Exceptions/ClientDisconnected.hpp b/src/DebugServer/Gdb/Exceptions/ClientDisconnected.hpp index 5a557930..235e5e12 100644 --- a/src/DebugServer/Gdb/Exceptions/ClientDisconnected.hpp +++ b/src/DebugServer/Gdb/Exceptions/ClientDisconnected.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::Exceptions +namespace DebugServer::Gdb::Exceptions { /** * When a GDB RSP client unexpectedly drops the connection in the middle of an IO operation, a ClientDisconnected @@ -11,7 +11,7 @@ namespace Bloom::DebugServer::Gdb::Exceptions * * See GdbRspDebugServer::serve() for handling code. */ - class ClientDisconnected: public Bloom::Exceptions::Exception + class ClientDisconnected: public ::Exceptions::Exception { public: explicit ClientDisconnected() = default; diff --git a/src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp b/src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp index df6deae6..6265a22a 100644 --- a/src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp +++ b/src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::Exceptions +namespace DebugServer::Gdb::Exceptions { /** * In the event that the GDB debug server determines that the connected client cannot be served, @@ -10,15 +10,15 @@ namespace Bloom::DebugServer::Gdb::Exceptions * * See GdbRspDebugServer::serve() for handling code. */ - class ClientNotSupported: public Bloom::Exceptions::Exception + class ClientNotSupported: public ::Exceptions::Exception { public: explicit ClientNotSupported(const std::string& message) - : Bloom::Exceptions::Exception(message) + : ::Exceptions::Exception(message) {} explicit ClientNotSupported(const char* message) - : Bloom::Exceptions::Exception(message) + : ::Exceptions::Exception(message) {} explicit ClientNotSupported() = default; diff --git a/src/DebugServer/Gdb/Exceptions/DebugServerInterrupted.hpp b/src/DebugServer/Gdb/Exceptions/DebugServerInterrupted.hpp index 296e3f38..a5c4d086 100644 --- a/src/DebugServer/Gdb/Exceptions/DebugServerInterrupted.hpp +++ b/src/DebugServer/Gdb/Exceptions/DebugServerInterrupted.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::Exceptions +namespace DebugServer::Gdb::Exceptions { /** * The GDB debug server spends most of its time in a blocking state, waiting for a new connection or for some data @@ -13,7 +13,7 @@ namespace Bloom::DebugServer::Gdb::Exceptions * For more on how the GDB server implementation allows for interruptions, see the "Servicing events" section in * src/DebugServer/README.md. */ - class DebugServerInterrupted: public Bloom::Exceptions::Exception + class DebugServerInterrupted: public ::Exceptions::Exception { public: explicit DebugServerInterrupted() = default; diff --git a/src/DebugServer/Gdb/Exceptions/DebugSessionInitialisationFailure.hpp b/src/DebugServer/Gdb/Exceptions/DebugSessionInitialisationFailure.hpp index cf768ed0..4d631bba 100644 --- a/src/DebugServer/Gdb/Exceptions/DebugSessionInitialisationFailure.hpp +++ b/src/DebugServer/Gdb/Exceptions/DebugSessionInitialisationFailure.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::Exceptions +namespace DebugServer::Gdb::Exceptions { /** * The GDB server may fail to prepare for a debug session, if an internal error occurs. One circumstance where @@ -10,15 +10,15 @@ namespace Bloom::DebugServer::Gdb::Exceptions * * See GdbRspDebugServer::serve() for handling code. */ - class DebugSessionInitialisationFailure: public Bloom::Exceptions::Exception + class DebugSessionInitialisationFailure: public ::Exceptions::Exception { public: explicit DebugSessionInitialisationFailure(const std::string& message) - : Bloom::Exceptions::Exception(message) + : ::Exceptions::Exception(message) {} explicit DebugSessionInitialisationFailure(const char* message) - : Bloom::Exceptions::Exception(message) + : ::Exceptions::Exception(message) {} explicit DebugSessionInitialisationFailure() = default; diff --git a/src/DebugServer/Gdb/Exceptions/InvalidCommandOption.hpp b/src/DebugServer/Gdb/Exceptions/InvalidCommandOption.hpp index 3376392c..a011e311 100644 --- a/src/DebugServer/Gdb/Exceptions/InvalidCommandOption.hpp +++ b/src/DebugServer/Gdb/Exceptions/InvalidCommandOption.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugServer::Gdb::Exceptions +namespace DebugServer::Gdb::Exceptions { /** * For GDB monitor commands, each command can define a set of required/optional command options. @@ -10,15 +10,15 @@ namespace Bloom::DebugServer::Gdb::Exceptions * * This exception is typically thrown and caught within the handling of monitor commands. */ - class InvalidCommandOption: public Bloom::Exceptions::Exception + class InvalidCommandOption: public ::Exceptions::Exception { public: explicit InvalidCommandOption(const std::string& message) - : Bloom::Exceptions::Exception(message) + : ::Exceptions::Exception(message) {} explicit InvalidCommandOption(const char* message) - : Bloom::Exceptions::Exception(message) + : ::Exceptions::Exception(message) {} explicit InvalidCommandOption() = default; diff --git a/src/DebugServer/Gdb/Feature.hpp b/src/DebugServer/Gdb/Feature.hpp index 91ce17cb..ebf27d9d 100644 --- a/src/DebugServer/Gdb/Feature.hpp +++ b/src/DebugServer/Gdb/Feature.hpp @@ -2,7 +2,7 @@ #include "src/Helpers/BiMap.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { enum class Feature: int { diff --git a/src/DebugServer/Gdb/GdbDebugServerConfig.cpp b/src/DebugServer/Gdb/GdbDebugServerConfig.cpp index 14d839ee..d3d2daad 100644 --- a/src/DebugServer/Gdb/GdbDebugServerConfig.cpp +++ b/src/DebugServer/Gdb/GdbDebugServerConfig.cpp @@ -3,7 +3,7 @@ #include "src/Helpers/YamlUtilities.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { GdbDebugServerConfig::GdbDebugServerConfig(const DebugServerConfig& debugServerConfig) : DebugServerConfig(debugServerConfig) diff --git a/src/DebugServer/Gdb/GdbDebugServerConfig.hpp b/src/DebugServer/Gdb/GdbDebugServerConfig.hpp index babde8ca..1a6ff0d0 100644 --- a/src/DebugServer/Gdb/GdbDebugServerConfig.hpp +++ b/src/DebugServer/Gdb/GdbDebugServerConfig.hpp @@ -2,7 +2,7 @@ #include "src/ProjectConfig.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { /** * Extending the generic DebugServerConfig struct to accommodate GDB debug server configuration parameters. diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.cpp b/src/DebugServer/Gdb/GdbRspDebugServer.cpp index cfbc7ef4..78356ebf 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.cpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.cpp @@ -41,10 +41,10 @@ #include "src/Services/ProcessService.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { using namespace Exceptions; - using namespace Bloom::Exceptions; + using namespace ::Exceptions; using CommandPackets::CommandPacket; diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.hpp b/src/DebugServer/Gdb/GdbRspDebugServer.hpp index bcf42c32..968271d5 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.hpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.hpp @@ -26,7 +26,7 @@ #include "src/EventManager/Events/TargetExecutionStopped.hpp" #include "src/EventManager/Events/TargetExecutionResumed.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { /** * The GdbRspDebugServer is an implementation of the GDB Remote Serial Protocol. diff --git a/src/DebugServer/Gdb/Packet.hpp b/src/DebugServer/Gdb/Packet.hpp index 5b348bfe..81678915 100644 --- a/src/DebugServer/Gdb/Packet.hpp +++ b/src/DebugServer/Gdb/Packet.hpp @@ -7,7 +7,7 @@ #include #include -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { using RawPacket = std::vector; diff --git a/src/DebugServer/Gdb/ProgrammingSession.hpp b/src/DebugServer/Gdb/ProgrammingSession.hpp index 747f1666..ffbee358 100644 --- a/src/DebugServer/Gdb/ProgrammingSession.hpp +++ b/src/DebugServer/Gdb/ProgrammingSession.hpp @@ -2,7 +2,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { /** * A programming session is created upon receiving the first FlashWrite (vFlashWrite) packet from GDB. diff --git a/src/DebugServer/Gdb/RegisterDescriptor.hpp b/src/DebugServer/Gdb/RegisterDescriptor.hpp index 6f4e0cf3..98a34319 100644 --- a/src/DebugServer/Gdb/RegisterDescriptor.hpp +++ b/src/DebugServer/Gdb/RegisterDescriptor.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { using GdbRegisterId = std::uint16_t; @@ -60,10 +60,10 @@ namespace std * class). */ template<> - class hash + class hash { public: - std::size_t operator () (const Bloom::DebugServer::Gdb::RegisterDescriptor& descriptor) const { + std::size_t operator () (const DebugServer::Gdb::RegisterDescriptor& descriptor) const { // We use the GDB register number as the hash, as it is unique to the register. return static_cast(descriptor.id); } diff --git a/src/DebugServer/Gdb/ResponsePackets/EmptyResponsePacket.hpp b/src/DebugServer/Gdb/ResponsePackets/EmptyResponsePacket.hpp index 5f60b67d..da8f3e7f 100644 --- a/src/DebugServer/Gdb/ResponsePackets/EmptyResponsePacket.hpp +++ b/src/DebugServer/Gdb/ResponsePackets/EmptyResponsePacket.hpp @@ -2,7 +2,7 @@ #include "ResponsePacket.hpp" -namespace Bloom::DebugServer::Gdb::ResponsePackets +namespace DebugServer::Gdb::ResponsePackets { /** * Empty response packet expected by the GDB client, in response to certain commands. diff --git a/src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp b/src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp index 286ebf31..bac6a007 100644 --- a/src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp +++ b/src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp @@ -2,7 +2,7 @@ #include "ResponsePacket.hpp" -namespace Bloom::DebugServer::Gdb::ResponsePackets +namespace DebugServer::Gdb::ResponsePackets { /** * Error response packet expected by the GDB client, to indicate an error, in response to certain commands. diff --git a/src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp b/src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp index d9e8beb8..9ef1381b 100644 --- a/src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp +++ b/src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp @@ -2,7 +2,7 @@ #include "ResponsePacket.hpp" -namespace Bloom::DebugServer::Gdb::ResponsePackets +namespace DebugServer::Gdb::ResponsePackets { /** * OK response packet expected by the GDB client, in response to certain commands. diff --git a/src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp b/src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp index 36d0dd3f..9b636644 100644 --- a/src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp +++ b/src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp @@ -5,7 +5,7 @@ #include "src/DebugServer/Gdb/Packet.hpp" -namespace Bloom::DebugServer::Gdb::ResponsePackets +namespace DebugServer::Gdb::ResponsePackets { /** * Upon receiving a CommandPacket from the connected GDB RSP client, the server is expected to respond with a diff --git a/src/DebugServer/Gdb/ResponsePackets/SupportedFeaturesResponse.cpp b/src/DebugServer/Gdb/ResponsePackets/SupportedFeaturesResponse.cpp index 939fe46f..49209da4 100644 --- a/src/DebugServer/Gdb/ResponsePackets/SupportedFeaturesResponse.cpp +++ b/src/DebugServer/Gdb/ResponsePackets/SupportedFeaturesResponse.cpp @@ -1,6 +1,6 @@ #include "SupportedFeaturesResponse.hpp" -namespace Bloom::DebugServer::Gdb::ResponsePackets +namespace DebugServer::Gdb::ResponsePackets { SupportedFeaturesResponse::SupportedFeaturesResponse( const std::set>>& supportedFeatures diff --git a/src/DebugServer/Gdb/ResponsePackets/SupportedFeaturesResponse.hpp b/src/DebugServer/Gdb/ResponsePackets/SupportedFeaturesResponse.hpp index 3037c9b3..786022af 100644 --- a/src/DebugServer/Gdb/ResponsePackets/SupportedFeaturesResponse.hpp +++ b/src/DebugServer/Gdb/ResponsePackets/SupportedFeaturesResponse.hpp @@ -8,7 +8,7 @@ #include "src/DebugServer/Gdb/Feature.hpp" -namespace Bloom::DebugServer::Gdb::ResponsePackets +namespace DebugServer::Gdb::ResponsePackets { /** * The SupportedFeaturesResponse class implements the response packet structure for the "qSupported" command. diff --git a/src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp b/src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp index 4d12f9e4..e2673876 100644 --- a/src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp +++ b/src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp @@ -9,7 +9,7 @@ #include "src/Services/StringService.hpp" -namespace Bloom::DebugServer::Gdb::ResponsePackets +namespace DebugServer::Gdb::ResponsePackets { /** * The TargetStopped class implements the response packet structure for any commands that expect a "StopReply" diff --git a/src/DebugServer/Gdb/Signal.hpp b/src/DebugServer/Gdb/Signal.hpp index 8a485688..9fd6f8be 100644 --- a/src/DebugServer/Gdb/Signal.hpp +++ b/src/DebugServer/Gdb/Signal.hpp @@ -1,6 +1,6 @@ #pragma once -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { enum class Signal: unsigned char { diff --git a/src/DebugServer/Gdb/StopReason.hpp b/src/DebugServer/Gdb/StopReason.hpp index 9b8a0573..b0696852 100644 --- a/src/DebugServer/Gdb/StopReason.hpp +++ b/src/DebugServer/Gdb/StopReason.hpp @@ -2,7 +2,7 @@ #include "src/Helpers/BiMap.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { enum class StopReason: int { diff --git a/src/DebugServer/Gdb/TargetDescriptor.cpp b/src/DebugServer/Gdb/TargetDescriptor.cpp index d37cffad..b4c3ea46 100644 --- a/src/DebugServer/Gdb/TargetDescriptor.cpp +++ b/src/DebugServer/Gdb/TargetDescriptor.cpp @@ -1,6 +1,6 @@ #include "TargetDescriptor.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { TargetDescriptor::TargetDescriptor( const Targets::TargetDescriptor& targetDescriptor, diff --git a/src/DebugServer/Gdb/TargetDescriptor.hpp b/src/DebugServer/Gdb/TargetDescriptor.hpp index be143f05..fa8ddfe7 100644 --- a/src/DebugServer/Gdb/TargetDescriptor.hpp +++ b/src/DebugServer/Gdb/TargetDescriptor.hpp @@ -13,7 +13,7 @@ #include "RegisterDescriptor.hpp" -namespace Bloom::DebugServer::Gdb +namespace DebugServer::Gdb { /** * GDB target descriptor. diff --git a/src/DebugServer/ServerInterface.hpp b/src/DebugServer/ServerInterface.hpp index ea2cfd16..9300b023 100644 --- a/src/DebugServer/ServerInterface.hpp +++ b/src/DebugServer/ServerInterface.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::DebugServer +namespace DebugServer { /** * Every debug server must implement this interface. diff --git a/src/DebugToolDrivers/DebugTool.hpp b/src/DebugToolDrivers/DebugTool.hpp index b79d4f4a..8f7e8924 100644 --- a/src/DebugToolDrivers/DebugTool.hpp +++ b/src/DebugToolDrivers/DebugTool.hpp @@ -10,103 +10,100 @@ #include "TargetInterfaces/Microchip/AVR/AvrIspInterface.hpp" -namespace Bloom +/** + * A debug tool can be any device that provides access to the connected target. Debug tools are usually connected + * to the host machine via USB. + * + * Each debug tool must implement this interface. Note that target specific driver code should not be placed here. + * Each target family will expect the debug tool to provide an interface for that particular group of targets. + * For an example, see the Avr8DebugInterface class and DebugTool::getAvr8DebugInterface(), for the family of AVR + * 8-bit targets. + */ +class DebugTool { +public: + DebugTool() = default; + virtual ~DebugTool() = default; + + DebugTool(const DebugTool& other) = default; + DebugTool(DebugTool&& other) = default; + + DebugTool& operator = (const DebugTool& other) = default; + DebugTool& operator = (DebugTool&& other) = default; + /** - * A debug tool can be any device that provides access to the connected target. Debug tools are usually connected - * to the host machine via USB. - * - * Each debug tool must implement this interface. Note that target specific driver code should not be placed here. - * Each target family will expect the debug tool to provide an interface for that particular group of targets. - * For an example, see the Avr8DebugInterface class and DebugTool::getAvr8DebugInterface(), for the family of AVR - * 8-bit targets. + * Should establish a connection to the device and prepare it for a debug session. */ - class DebugTool - { - public: - DebugTool() = default; - virtual ~DebugTool() = default; + virtual void init() = 0; - DebugTool(const DebugTool& other) = default; - DebugTool(DebugTool&& other) = default; + /** + * Should disconnect from the device after performing any tasks required to formally end the debug session. + */ + virtual void close() = 0; - DebugTool& operator = (const DebugTool& other) = default; - DebugTool& operator = (DebugTool&& other) = default; + virtual std::string getName() = 0; - /** - * Should establish a connection to the device and prepare it for a debug session. - */ - virtual void init() = 0; + virtual std::string getSerialNumber() = 0; - /** - * Should disconnect from the device after performing any tasks required to formally end the debug session. - */ - virtual void close() = 0; + /** + * All debug tools that support target power management functions must provide an implementation of the + * TargetPowerManagementInterface class, via this function. + * + * For debug tools that cannot manage target power, a nullptr should be returned. + * + * Note: the caller of this function will not manage the lifetime of the returned TargetPowerManagementInterface + * instance. + * + * @return + */ + virtual DebugToolDrivers::TargetInterfaces::TargetPowerManagementInterface* getTargetPowerManagementInterface() { + return nullptr; + } - virtual std::string getName() = 0; + /** + * All debug tools that support debugging operations on AVR8 targets must provide an implementation of + * the Avr8DebugInterface class, via this function. + * + * For debug tools that do not support debugging on AVR8 targets, this function should return a nullptr. + * + * Note: the caller of this function will not manage the lifetime of the returned Avr8DebugInterface instance. + * + * @return + */ + virtual DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8::Avr8DebugInterface* getAvr8DebugInterface( + const Targets::Microchip::Avr::Avr8Bit::Avr8TargetConfig& targetConfig, + Targets::Microchip::Avr::Avr8Bit::Family targetFamily, + const Targets::Microchip::Avr::Avr8Bit::TargetParameters& targetParameters, + const Targets::TargetRegisterDescriptorMapping& targetRegisterDescriptorsById + ) { + return nullptr; + } - virtual std::string getSerialNumber() = 0; + /** + * All debug tools that support interfacing with AVR targets via the ISP interface must provide an + * implementation of the AvrIspInterface class, via this function. + * + * For debug tools that do not support the interface, a nullptr should be returned. + * + * Note: the caller of this function will not manage the lifetime of the returned AvrIspInterface instance. + * + * @return + */ + virtual DebugToolDrivers::TargetInterfaces::Microchip::Avr::AvrIspInterface* getAvrIspInterface( + const Targets::Microchip::Avr::Avr8Bit::Avr8TargetConfig& targetConfig + ) { + return nullptr; + } - /** - * All debug tools that support target power management functions must provide an implementation of the - * TargetPowerManagementInterface class, via this function. - * - * For debug tools that cannot manage target power, a nullptr should be returned. - * - * Note: the caller of this function will not manage the lifetime of the returned TargetPowerManagementInterface - * instance. - * - * @return - */ - virtual DebugToolDrivers::TargetInterfaces::TargetPowerManagementInterface* getTargetPowerManagementInterface() { - return nullptr; - } + [[nodiscard]] bool isInitialised() const { + return this->initialised; + } - /** - * All debug tools that support debugging operations on AVR8 targets must provide an implementation of - * the Avr8DebugInterface class, via this function. - * - * For debug tools that do not support debugging on AVR8 targets, this function should return a nullptr. - * - * Note: the caller of this function will not manage the lifetime of the returned Avr8DebugInterface instance. - * - * @return - */ - virtual DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8::Avr8DebugInterface* getAvr8DebugInterface( - const Targets::Microchip::Avr::Avr8Bit::Avr8TargetConfig& targetConfig, - Targets::Microchip::Avr::Avr8Bit::Family targetFamily, - const Targets::Microchip::Avr::Avr8Bit::TargetParameters& targetParameters, - const Targets::TargetRegisterDescriptorMapping& targetRegisterDescriptorsById - ) { - return nullptr; - } +protected: + void setInitialised(bool initialised) { + this->initialised = initialised; + } - /** - * All debug tools that support interfacing with AVR targets via the ISP interface must provide an - * implementation of the AvrIspInterface class, via this function. - * - * For debug tools that do not support the interface, a nullptr should be returned. - * - * Note: the caller of this function will not manage the lifetime of the returned AvrIspInterface instance. - * - * @return - */ - virtual DebugToolDrivers::TargetInterfaces::Microchip::Avr::AvrIspInterface* getAvrIspInterface( - const Targets::Microchip::Avr::Avr8Bit::Avr8TargetConfig& targetConfig - ) { - return nullptr; - } - - [[nodiscard]] bool isInitialised() const { - return this->initialised; - } - - protected: - void setInitialised(bool initialised) { - this->initialised = initialised; - } - - private: - bool initialised = false; - }; -} +private: + bool initialised = false; +}; diff --git a/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.cpp b/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.cpp index a062a767..bdd3f63a 100644 --- a/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.cpp +++ b/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.cpp @@ -1,6 +1,6 @@ #include "AtmelIce.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { AtmelIce::AtmelIce() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.hpp b/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.hpp index 0102a05a..d50fa1f8 100644 --- a/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.hpp +++ b/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * The Atmel-ICE device is an EDBG (Embedded Debugger) device. diff --git a/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.cpp b/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.cpp index d39e1ffa..d2ceabbf 100644 --- a/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.cpp +++ b/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.cpp @@ -1,6 +1,6 @@ #include "CuriosityNano.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { CuriosityNano::CuriosityNano() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.hpp b/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.hpp index a1adbac0..b62035de 100644 --- a/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.hpp +++ b/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * The Curiosity Nano is an evaluation board featuring an on-board debugger. The debugger is EDBG-based. diff --git a/src/DebugToolDrivers/Microchip/EdbgDevice.cpp b/src/DebugToolDrivers/Microchip/EdbgDevice.cpp index d0fea6aa..f9eb54cb 100644 --- a/src/DebugToolDrivers/Microchip/EdbgDevice.cpp +++ b/src/DebugToolDrivers/Microchip/EdbgDevice.cpp @@ -6,10 +6,10 @@ #include "src/TargetController/Exceptions/DeviceFailure.hpp" #include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { using namespace Protocols::CmsisDap::Edbg::Avr; - using namespace Bloom::Exceptions; + using namespace Exceptions; using Protocols::CmsisDap::Edbg::EdbgInterface; using Protocols::CmsisDap::Edbg::EdbgTargetPowerManagementInterface; diff --git a/src/DebugToolDrivers/Microchip/EdbgDevice.hpp b/src/DebugToolDrivers/Microchip/EdbgDevice.hpp index b588aafa..f6f17f7c 100644 --- a/src/DebugToolDrivers/Microchip/EdbgDevice.hpp +++ b/src/DebugToolDrivers/Microchip/EdbgDevice.hpp @@ -12,7 +12,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * Microchip EDBG (Embedded Debugger) devices implement the CMSIS-DAP interface. As well as the CMSIS-DAP protocol, diff --git a/src/DebugToolDrivers/Microchip/JtagIce3/JtagIce3.cpp b/src/DebugToolDrivers/Microchip/JtagIce3/JtagIce3.cpp index a1fbdb72..d0ce32dd 100644 --- a/src/DebugToolDrivers/Microchip/JtagIce3/JtagIce3.cpp +++ b/src/DebugToolDrivers/Microchip/JtagIce3/JtagIce3.cpp @@ -1,6 +1,6 @@ #include "JtagIce3.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { JtagIce3::JtagIce3() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/JtagIce3/JtagIce3.hpp b/src/DebugToolDrivers/Microchip/JtagIce3/JtagIce3.hpp index f660dc68..1cc7aff2 100644 --- a/src/DebugToolDrivers/Microchip/JtagIce3/JtagIce3.hpp +++ b/src/DebugToolDrivers/Microchip/JtagIce3/JtagIce3.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * The JTAGICE3, from firmware version 3.x+, is an EDBG device. diff --git a/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.cpp b/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.cpp index 35f7a6c3..26878bdd 100644 --- a/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.cpp +++ b/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.cpp @@ -3,7 +3,7 @@ #include "src/TargetController/Exceptions/DeviceNotFound.hpp" #include "src/Services/PathService.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { MplabPickit4::MplabPickit4() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.hpp b/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.hpp index 1ab4c8e1..b82bec29 100644 --- a/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.hpp +++ b/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * Like the MPLAB Snap, the PICkit 4 is a hybrid device. It can present itself as an EDBG (Embedded Debugger) diff --git a/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.cpp b/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.cpp index 732cfaa1..1afd5e94 100644 --- a/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.cpp +++ b/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.cpp @@ -3,7 +3,7 @@ #include "src/TargetController/Exceptions/DeviceNotFound.hpp" #include "src/Services/PathService.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { MplabSnap::MplabSnap() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.hpp b/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.hpp index 3c71d2cf..cb71536d 100644 --- a/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.hpp +++ b/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * The MPLAB Snap device is a hybrid device - that is, it can present itself as an "MPLAB Snap ICD" device, as well diff --git a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp index ae831885..d06a3605 100644 --- a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp +++ b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp @@ -1,6 +1,6 @@ #include "PowerDebugger.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { PowerDebugger::PowerDebugger() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.hpp b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.hpp index 5b53936d..d8770eae 100644 --- a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.hpp +++ b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * The Power Debugger device is very similar to the Atmel-ICE. It is an EDBG device. diff --git a/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.cpp b/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.cpp index 131d4f6f..cdca0ae3 100644 --- a/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.cpp +++ b/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.cpp @@ -1,6 +1,6 @@ #include "XplainedMini.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { XplainedMini::XplainedMini() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.hpp b/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.hpp index 8f09961c..d6d94370 100644 --- a/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.hpp +++ b/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * The Xplained Mini is an evaluation board featuring an on-board debugger. The debugger is EDBG-based. diff --git a/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.cpp b/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.cpp index c2c7cb03..be519aed 100644 --- a/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.cpp +++ b/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.cpp @@ -1,6 +1,6 @@ #include "XplainedNano.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { XplainedNano::XplainedNano() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.hpp b/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.hpp index d9e08514..bbdd0ad9 100644 --- a/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.hpp +++ b/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * The Xplained Nano is an evaluation board featuring an on-board debugger. The debugger is EDBG-based. diff --git a/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.cpp b/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.cpp index bdf913bb..a6c833f1 100644 --- a/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.cpp +++ b/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.cpp @@ -1,6 +1,6 @@ #include "XplainedPro.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { XplainedPro::XplainedPro() : EdbgDevice( diff --git a/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.hpp b/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.hpp index 52d66e93..25cf6b67 100644 --- a/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.hpp +++ b/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Microchip/EdbgDevice.hpp" -namespace Bloom::DebugToolDrivers +namespace DebugToolDrivers { /** * The Xplained Pro is an evaluation board featuring an on-board debugger. The debugger is EDBG-based. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.cpp index 7eb420f3..a50e5a6d 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.cpp @@ -4,9 +4,9 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap +namespace DebugToolDrivers::Protocols::CmsisDap { - using namespace Bloom::Exceptions; + using namespace Exceptions; CmsisDapInterface::CmsisDapInterface(Usb::HidInterface&& usbHidInterface) : usbHidInterface(std::move(usbHidInterface)) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.hpp index 6e85f545..474975f9 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.hpp @@ -11,7 +11,7 @@ #include "src/TargetController/Exceptions/DeviceCommunicationFailure.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap +namespace DebugToolDrivers::Protocols::CmsisDap { /** * The CmsisDapInterface class implements the CMSIS-DAP protocol. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp index e22dd131..c916fa8e 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp @@ -1,6 +1,6 @@ #include "Command.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap +namespace DebugToolDrivers::Protocols::CmsisDap { Command::Command(unsigned char commandId) : id(commandId) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp index fa3c5b73..3d399a07 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp @@ -5,7 +5,7 @@ #include "Response.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap +namespace DebugToolDrivers::Protocols::CmsisDap { /** * CMSIS-DAP command. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.cpp index 43749289..e3c2bf8b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.cpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap +namespace DebugToolDrivers::Protocols::CmsisDap { Response::Response(const std::vector& rawResponse) { if (rawResponse.empty()) { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp index 1306b401..6fa33ef3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap +namespace DebugToolDrivers::Protocols::CmsisDap { class Response { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp index 00955c9d..fe2cbc5d 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp @@ -4,7 +4,7 @@ #include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { struct Avr8EdbgParameter { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.cpp index b01f1348..2ec8a0d2 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.cpp @@ -1,6 +1,6 @@ #include "AvrCommand.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { AvrCommand::AvrCommand( std::size_t fragmentCount, diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp index bf633da3..d2bfb60b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp @@ -7,7 +7,7 @@ #include "AvrResponse.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { /** * AVR CMSIS-DAP vendor command. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.cpp index 497f7ade..99b5a105 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.cpp @@ -2,9 +2,9 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using namespace Bloom::Exceptions; + using namespace Exceptions; AvrEvent::AvrEvent(const std::vector& rawResponse) : Response(rawResponse) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp index afec50b1..e3bac5b2 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { enum class AvrEventId: unsigned char { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEventCommand.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEventCommand.hpp index a8c786e8..72893576 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEventCommand.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEventCommand.hpp @@ -3,7 +3,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp" #include "AvrEvent.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { class AvrEventCommand: public Command { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.cpp index 0fc97eac..ae58b99b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.cpp @@ -2,9 +2,9 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using namespace Bloom::Exceptions; + using namespace Exceptions; AvrResponse::AvrResponse(const std::vector& rawResponse) : Response(rawResponse) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp index 06e9f815..cd3fd58d 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/Response.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { class AvrResponse: public Response { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponseCommand.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponseCommand.hpp index d438b33d..6b809f8a 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponseCommand.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponseCommand.hpp @@ -6,7 +6,7 @@ #include "AvrResponse.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { /** * All AVR commands result in an automatic response, but that is just a response to confirm diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ActivatePhysical.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ActivatePhysical.hpp index 144d4d47..43b564f0 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ActivatePhysical.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ActivatePhysical.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class ActivatePhysical: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Attach.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Attach.hpp index 52e64baa..4ecd9224 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Attach.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Attach.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class Attach: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp index 212ad75b..38a72a01 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { template class Avr8GenericCommandFrame: public AvrCommandFrame diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp index 5ec108ac..823ededb 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearAllSoftwareBreakpoints.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class ClearAllSoftwareBreakpoints: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp index 00608b30..56d560a0 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ClearSoftwareBreakpoints.hpp @@ -5,7 +5,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class ClearSoftwareBreakpoints: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DeactivatePhysical.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DeactivatePhysical.hpp index b61a1554..a55b15b3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DeactivatePhysical.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DeactivatePhysical.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class DeactivatePhysical: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Detach.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Detach.hpp index a10192b2..d8d8dc72 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Detach.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Detach.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class Detach: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DisableDebugWire.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DisableDebugWire.hpp index a99518b4..01183339 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DisableDebugWire.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/DisableDebugWire.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class DisableDebugWire: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EnterProgrammingMode.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EnterProgrammingMode.hpp index ae01d36c..835ed83f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EnterProgrammingMode.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EnterProgrammingMode.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class EnterProgrammingMode: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EraseMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EraseMemory.hpp index d387a1da..6fcf0599 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EraseMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/EraseMemory.hpp @@ -4,7 +4,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class EraseMemory: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetDeviceId.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetDeviceId.hpp index 2495bbd7..4f97e240 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetDeviceId.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetDeviceId.hpp @@ -3,7 +3,7 @@ #include "Avr8GenericCommandFrame.hpp" #include "../../ResponseFrames/AVR8Generic/GetDeviceId.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class GetDeviceId: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetParameter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetParameter.hpp index 9f0275c2..e71a2b33 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetParameter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetParameter.hpp @@ -4,7 +4,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class GetParameter: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetProgramCounter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetProgramCounter.hpp index 9f2b9364..e30ec680 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetProgramCounter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/GetProgramCounter.hpp @@ -3,7 +3,7 @@ #include "Avr8GenericCommandFrame.hpp" #include "../../ResponseFrames/AVR8Generic/GetProgramCounter.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class GetProgramCounter: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/LeaveProgrammingMode.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/LeaveProgrammingMode.hpp index 186d83b6..8fa665f0 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/LeaveProgrammingMode.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/LeaveProgrammingMode.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class LeaveProgrammingMode: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.cpp index 73014da7..428eda44 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { ReadMemory::ReadMemory( const Avr8MemoryType& type, diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp index ba7a38e0..a4cee1d3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp @@ -6,7 +6,7 @@ #include "Avr8GenericCommandFrame.hpp" #include "../../ResponseFrames/AVR8Generic/ReadMemory.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class ReadMemory: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Reset.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Reset.hpp index 836019e7..5782573a 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Reset.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Reset.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class Reset: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Run.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Run.hpp index daf90b93..095f5a98 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Run.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Run.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class Run: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/RunTo.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/RunTo.hpp index 28a89b16..1d1e5622 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/RunTo.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/RunTo.hpp @@ -4,7 +4,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class RunTo: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp index 0eb2404a..ac642559 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class SetParameter: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp index 24c3b029..c3afe023 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp @@ -4,7 +4,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class SetProgramCounter: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetSoftwareBreakpoints.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetSoftwareBreakpoints.hpp index f80f4a69..f8d97163 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetSoftwareBreakpoints.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetSoftwareBreakpoints.hpp @@ -5,7 +5,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class SetSoftwareBreakpoints: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp index 4cefc47f..6ffc3804 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetXmegaSoftwareBreakpoint.hpp @@ -4,7 +4,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class SetXmegaSoftwareBreakpoint: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Step.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Step.hpp index c47c01ff..dc4736c2 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Step.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Step.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class Step: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Stop.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Stop.hpp index 1d0a517e..fbfdba3e 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Stop.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Stop.hpp @@ -2,7 +2,7 @@ #include "Avr8GenericCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class Stop: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp index 3be30000..9d61b48b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp @@ -5,7 +5,7 @@ #include "Avr8GenericCommandFrame.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { class WriteMemory: public Avr8GenericCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/AvrIspCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/AvrIspCommandFrame.hpp index 5811c2ef..6ceab476 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/AvrIspCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/AvrIspCommandFrame.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp { template class AvrIspCommandFrame: public AvrCommandFrame diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/EnterProgrammingMode.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/EnterProgrammingMode.hpp index 27a095ad..364b1647 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/EnterProgrammingMode.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/EnterProgrammingMode.hpp @@ -4,7 +4,7 @@ #include "AvrIspCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp { class EnterProgrammingMode: public AvrIspCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/LeaveProgrammingMode.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/LeaveProgrammingMode.hpp index b4b26634..0305cebb 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/LeaveProgrammingMode.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/LeaveProgrammingMode.hpp @@ -4,7 +4,7 @@ #include "AvrIspCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp { class LeaveProgrammingMode: public AvrIspCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ProgramFuse.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ProgramFuse.hpp index d7394cc4..94a0d32b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ProgramFuse.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ProgramFuse.hpp @@ -6,7 +6,7 @@ #include "src/Targets/Microchip/AVR/Fuse.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp { class ProgramFuse: public AvrIspCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadFuse.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadFuse.hpp index 3e571905..b17e8e65 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadFuse.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadFuse.hpp @@ -6,7 +6,7 @@ #include "src/Targets/Microchip/AVR/Fuse.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp { class ReadFuse: public AvrIspCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadLock.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadLock.hpp index 124e9aa7..7a4acd54 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadLock.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadLock.hpp @@ -4,7 +4,7 @@ #include "AvrIspCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp { class ReadLock: public AvrIspCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadSignature.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadSignature.hpp index d4f95254..435e14c0 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadSignature.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadSignature.hpp @@ -7,7 +7,7 @@ #include "src/Targets/Microchip/AVR/Fuse.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::AvrIsp { class ReadSignature: public AvrIspCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp index a35a0ff1..83d0b57c 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp @@ -13,7 +13,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { static inline std::atomic lastSequenceId = 0; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp index c6621565..0f0ea3ed 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp @@ -3,7 +3,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Discovery +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Discovery { template class DiscoveryCommandFrame: public AvrCommandFrame diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/Query.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/Query.hpp index 158bf144..a4e246ec 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/Query.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/Query.hpp @@ -2,7 +2,7 @@ #include "DiscoveryCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Discovery +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Discovery { /** * The query context is the type of query to execute. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/EdbgControlCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/EdbgControlCommandFrame.hpp index c5160e97..d30fb9d4 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/EdbgControlCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/EdbgControlCommandFrame.hpp @@ -3,7 +3,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::EdbgControl +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::EdbgControl { template class EdbgControlCommandFrame: public AvrCommandFrame diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/GetParameter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/GetParameter.hpp index 9f3e2bd5..ad3c3446 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/GetParameter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/GetParameter.hpp @@ -4,7 +4,7 @@ #include "EdbgControlCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::EdbgControl +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::EdbgControl { class GetParameter: public EdbgControlCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/SetParameter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/SetParameter.hpp index 9d110ac5..1ba36d6b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/SetParameter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/SetParameter.hpp @@ -5,7 +5,7 @@ #include "EdbgControlCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::EdbgControl +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::EdbgControl { class SetParameter: public EdbgControlCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/EndSession.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/EndSession.hpp index dd04d44e..e849d2c6 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/EndSession.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/EndSession.hpp @@ -2,7 +2,7 @@ #include "HouseKeepingCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping { /** * The End Session command ends the active session with the tool. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/GetParameter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/GetParameter.hpp index 826ead7d..9b471789 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/GetParameter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/GetParameter.hpp @@ -5,7 +5,7 @@ #include "HouseKeepingCommandFrame.hpp" #include "Parameters.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping { class GetParameter: public HouseKeepingCommandFrame> { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/HouseKeepingCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/HouseKeepingCommandFrame.hpp index 870f16fd..7ec38432 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/HouseKeepingCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/HouseKeepingCommandFrame.hpp @@ -3,7 +3,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping { template class HouseKeepingCommandFrame: public AvrCommandFrame diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/Parameters.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/Parameters.hpp index f021a2fc..24ee65da 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/Parameters.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/Parameters.hpp @@ -4,7 +4,7 @@ #include "HouseKeepingCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping { enum class ParameterContext: unsigned char { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/StartSession.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/StartSession.hpp index b7e700cb..20b4cf81 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/StartSession.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/HouseKeeping/StartSession.hpp @@ -4,7 +4,7 @@ #include "HouseKeepingCommandFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping { /** * The Start Session command begins a session with the tool. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index d49c47eb..3c42554f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -41,11 +41,11 @@ // AVR events #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using namespace Bloom::Targets::Microchip::Avr; + using namespace Targets::Microchip::Avr; using namespace Avr8Bit; - using namespace Bloom::Exceptions; + using namespace Exceptions; using CommandFrames::Avr8Generic::Stop; using CommandFrames::Avr8Generic::Run; @@ -72,19 +72,19 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr using CommandFrames::Avr8Generic::EraseMemory; using CommandFrames::Avr8Generic::DisableDebugWire; - using Bloom::Targets::TargetState; - using Bloom::Targets::TargetMemoryType; - using Bloom::Targets::TargetMemoryBuffer; - using Bloom::Targets::TargetMemoryAddress; - using Bloom::Targets::TargetMemorySize; - using Bloom::Targets::TargetProgramCounter; - using Bloom::Targets::TargetRegister; - using Bloom::Targets::TargetRegisterDescriptor; - using Bloom::Targets::TargetRegisterDescriptors; - using Bloom::Targets::TargetRegisterDescriptorId; - using Bloom::Targets::TargetRegisterDescriptorIds; - using Bloom::Targets::TargetRegisterType; - using Bloom::Targets::TargetRegisters; + using Targets::TargetState; + using Targets::TargetMemoryType; + using Targets::TargetMemoryBuffer; + using Targets::TargetMemoryAddress; + using Targets::TargetMemorySize; + using Targets::TargetProgramCounter; + using Targets::TargetRegister; + using Targets::TargetRegisterDescriptor; + using Targets::TargetRegisterDescriptors; + using Targets::TargetRegisterDescriptorId; + using Targets::TargetRegisterDescriptorIds; + using Targets::TargetRegisterType; + using Targets::TargetRegisters; EdbgAvr8Interface::EdbgAvr8Interface( EdbgInterface* edbgInterface, diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp index f54726db..f0fd555d 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp @@ -15,7 +15,7 @@ #include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp" #include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { /** * The EdbgAvr8Interface implements the AVR8 Generic EDBG/CMSIS-DAP protocol, as an Avr8DebugInterface. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.cpp index c1b12bab..e7e7f465 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.cpp @@ -11,7 +11,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ReadLock.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVRISP/ProgramFuse.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { using namespace Targets::Microchip::Avr; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.hpp index 9cf2374c..9ad2caa5 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvrIspInterface.hpp @@ -8,7 +8,7 @@ #include "src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AvrIspInterface.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { /** * The EdbgAvrIspInterface implements the AVRISP EDBG/CMSIS-DAP protocol, as an AvrIspInterface. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.cpp index 96545feb..e8abadc9 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.cpp @@ -2,11 +2,11 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using namespace Bloom::Exceptions; + using namespace Exceptions; - using Bloom::Targets::TargetBreakCause; + using Targets::TargetBreakCause; BreakEvent::BreakEvent(const AvrEvent& event) : AvrEvent(event) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp index ce57a67a..8e652201 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp" #include "src/Targets/TargetBreakpoint.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { class BreakEvent: public AvrEvent { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp index 976433a8..c9be73ff 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp @@ -5,7 +5,7 @@ #include "src/TargetController/Exceptions/TargetOperationFailure.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { enum class Avr8CommandFailureCode: std::uint8_t { @@ -58,7 +58,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr UNKNOWN_ERROR = 0xFF, }; - class Avr8CommandFailure: public Bloom::Exceptions::TargetOperationFailure + class Avr8CommandFailure: public Exceptions::TargetOperationFailure { public: std::optional code; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.cpp index 6f68ab81..c50e5952 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.cpp @@ -2,9 +2,9 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { - using namespace Bloom::Exceptions; + using namespace Exceptions; Avr8GenericResponseFrame::Avr8GenericResponseFrame(const std::vector& avrResponses) : AvrResponseFrame(avrResponses) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp index 6321f44d..57fbc432 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/Avr8GenericResponseFrame.hpp @@ -3,7 +3,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { class Avr8GenericResponseFrame: public AvrResponseFrame { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.cpp index 31464691..d3fa4d6b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.cpp @@ -1,6 +1,6 @@ #include "GetDeviceId.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { GetDeviceId::GetDeviceId(const std::vector& AvrResponses) : Avr8GenericResponseFrame(AvrResponses) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp index ba9d6130..5591a564 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp @@ -5,7 +5,7 @@ #include "src/Targets/Microchip/AVR/TargetSignature.hpp" #include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { class GetDeviceId: public Avr8GenericResponseFrame { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp index 33d710b9..0676d69b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp @@ -8,7 +8,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { class GetProgramCounter: public Avr8GenericResponseFrame { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp index a4c17379..8c2d2c82 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp @@ -3,7 +3,7 @@ #include "Avr8GenericResponseFrame.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { class ReadMemory: public Avr8GenericResponseFrame { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.cpp index 690d46eb..cb9f17ae 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.cpp @@ -2,9 +2,9 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::AvrIsp { - using namespace Bloom::Exceptions; + using namespace Exceptions; AvrIspResponseFrame::AvrIspResponseFrame(const std::vector& avrResponses) : AvrResponseFrame(avrResponses) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.hpp index 1e888ca9..cf17e6b2 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVRISP/AvrIspResponseFrame.hpp @@ -2,7 +2,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::AvrIsp +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::AvrIsp { enum class StatusCode: unsigned char { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.cpp index 57a4561c..00b2085b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.cpp @@ -2,9 +2,9 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using namespace Bloom::Exceptions; + using namespace Exceptions; void AvrResponseFrame::initFromAvrResponses(const std::vector& avrResponses) { // Build a raw frame buffer from the AvrResponse objects and just call initFromRawFrame() diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp index 13234757..265e4fc8 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp @@ -9,7 +9,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrResponse.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { class AvrResponseFrame { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.cpp index edfb40e6..e6bba7dc 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.cpp @@ -2,9 +2,9 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Discovery +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Discovery { - using namespace Bloom::Exceptions; + using namespace Exceptions; DiscoveryResponseFrame::DiscoveryResponseFrame(const std::vector& avrResponses) : AvrResponseFrame(avrResponses) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp index d274254b..2c665212 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp @@ -2,7 +2,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Discovery +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Discovery { /** * Discovery commands can only return two responses; A LIST response and a failure. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.cpp index 120caa8a..4013f59c 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.cpp @@ -2,9 +2,9 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::EdbgControl +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::EdbgControl { - using namespace Bloom::Exceptions; + using namespace Exceptions; EdbgControlResponseFrame::EdbgControlResponseFrame(const std::vector& avrResponses) : AvrResponseFrame(avrResponses) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.hpp index f42b2901..f04a1ee0 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/EDBGControl/EdbgControlResponseFrame.hpp @@ -2,7 +2,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::EdbgControl +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::EdbgControl { enum class EdbgControlResponseId: unsigned char { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.cpp index 9899c164..60acc7ad 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.cpp @@ -2,9 +2,9 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::HouseKeeping +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::HouseKeeping { - using namespace Bloom::Exceptions; + using namespace Exceptions; HouseKeepingResponseFrame::HouseKeepingResponseFrame(const std::vector& avrResponses) : AvrResponseFrame(avrResponses) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.hpp index e5330647..c11e8e67 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/HouseKeeping/HouseKeepingResponseFrame.hpp @@ -2,7 +2,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::HouseKeeping +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::HouseKeeping { enum class ResponseId: unsigned char { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp index 35d11a2a..e99639ad 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/Edbg.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg { enum class ProtocolHandlerId: unsigned char { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp index 778edb9e..aab84fa1 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp @@ -4,9 +4,9 @@ #include "src/TargetController/Exceptions/DeviceCommunicationFailure.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg { - using namespace Bloom::Exceptions; + using namespace Exceptions; EdbgInterface::EdbgInterface(Usb::HidInterface&& cmsisHidInterface) : CmsisDapInterface(std::move(cmsisHidInterface)) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp index 16eb03bc..a7ace03b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp @@ -15,7 +15,7 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp" #include "src/TargetController/Exceptions/DeviceCommunicationFailure.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg { /** * The EdbgInterface class implements the EDBG sub-protocol, which takes the form of numerous CMSIS-DAP vendor diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.cpp index ae0a8622..4537133b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.cpp @@ -3,9 +3,9 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/GetParameter.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/EDBGControl/SetParameter.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg { - using namespace Bloom::Exceptions; + using namespace Exceptions; using Protocols::CmsisDap::Edbg::Avr::ResponseFrames::EdbgControl::EdbgControlResponseId; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.hpp index 37de1fd9..e74f67e1 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgTargetPowerManagementInterface.hpp @@ -5,7 +5,7 @@ #include "src/DebugToolDrivers/TargetInterfaces/TargetPowerManagementInterface.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp" -namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg +namespace DebugToolDrivers::Protocols::CmsisDap::Edbg { class EdbgTargetPowerManagementInterface: public TargetInterfaces::TargetPowerManagementInterface { diff --git a/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp b/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp index 3f2359a1..2c4f8300 100644 --- a/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp +++ b/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp @@ -16,7 +16,7 @@ #include "src/Targets/TargetRegister.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 +namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 { /** * Interfacing with an AVR8 target for debugging operations can vary significantly, depending on the debug tool @@ -26,8 +26,8 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 * * Each debug tool that supports interfacing with AVR8 targets must provide an implementation * of this interface class. For example, the Atmel-ICE provides the EdbgAvr8Interface implementation for - * interfacing with AVR8 targets. See Bloom::DebugToolDrivers::AtmelIce::getAvr8DebugInterface() and - * Bloom::DebugTool::getAvr8DebugInterface() for more on this. + * interfacing with AVR8 targets. See DebugToolDrivers::AtmelIce::getAvr8DebugInterface() and + * DebugTool::getAvr8DebugInterface() for more on this. */ class Avr8DebugInterface { diff --git a/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AvrIspInterface.hpp b/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AvrIspInterface.hpp index a7bf256c..e67301a5 100644 --- a/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AvrIspInterface.hpp +++ b/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AvrIspInterface.hpp @@ -8,7 +8,7 @@ #include "src/ProjectConfig.hpp" -namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr +namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr { /** * Many AVRs can be programmed via an SPI interface. Some debug tools provide access to this interface via the AVR diff --git a/src/DebugToolDrivers/TargetInterfaces/TargetPowerManagementInterface.hpp b/src/DebugToolDrivers/TargetInterfaces/TargetPowerManagementInterface.hpp index 5454a26e..b266f1fe 100644 --- a/src/DebugToolDrivers/TargetInterfaces/TargetPowerManagementInterface.hpp +++ b/src/DebugToolDrivers/TargetInterfaces/TargetPowerManagementInterface.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::DebugToolDrivers::TargetInterfaces +namespace DebugToolDrivers::TargetInterfaces { /** * Some debug tools provide target power management functions. Those that do should expose an implementation of diff --git a/src/DebugToolDrivers/USB/HID/HidInterface.cpp b/src/DebugToolDrivers/USB/HID/HidInterface.cpp index a51a75ab..a2613ffd 100644 --- a/src/DebugToolDrivers/USB/HID/HidInterface.cpp +++ b/src/DebugToolDrivers/USB/HID/HidInterface.cpp @@ -5,9 +5,9 @@ #include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp" #include "src/TargetController/Exceptions/DeviceCommunicationFailure.hpp" -namespace Bloom::Usb +namespace Usb { - using namespace Bloom::Exceptions; + using namespace Exceptions; HidInterface::HidInterface( std::uint8_t interfaceNumber, diff --git a/src/DebugToolDrivers/USB/HID/HidInterface.hpp b/src/DebugToolDrivers/USB/HID/HidInterface.hpp index e0602d2f..ce28caf0 100644 --- a/src/DebugToolDrivers/USB/HID/HidInterface.hpp +++ b/src/DebugToolDrivers/USB/HID/HidInterface.hpp @@ -10,7 +10,7 @@ #include #include -namespace Bloom::Usb +namespace Usb { /** * The HidInterface uses the HIDAPI library to implement communication with HID endpoints. diff --git a/src/DebugToolDrivers/USB/UsbDevice.cpp b/src/DebugToolDrivers/USB/UsbDevice.cpp index 7ab0419b..a1cd6996 100644 --- a/src/DebugToolDrivers/USB/UsbDevice.cpp +++ b/src/DebugToolDrivers/USB/UsbDevice.cpp @@ -6,9 +6,9 @@ #include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp" #include "src/TargetController/Exceptions/DeviceNotFound.hpp" -namespace Bloom::Usb +namespace Usb { - using namespace Bloom::Exceptions; + using namespace Exceptions; UsbDevice::UsbDevice(std::uint16_t vendorId, std::uint16_t productId) : vendorId(vendorId) diff --git a/src/DebugToolDrivers/USB/UsbDevice.hpp b/src/DebugToolDrivers/USB/UsbDevice.hpp index 2ba353ce..a7ce771b 100644 --- a/src/DebugToolDrivers/USB/UsbDevice.hpp +++ b/src/DebugToolDrivers/USB/UsbDevice.hpp @@ -8,7 +8,7 @@ #include "src/DebugToolDrivers/DebugTool.hpp" -namespace Bloom::Usb +namespace Usb { using LibusbContext = std::unique_ptr<::libusb_context, decltype(&::libusb_exit)>; using LibusbDevice = std::unique_ptr<::libusb_device, decltype(&::libusb_unref_device)>; diff --git a/src/EventManager/EventListener.cpp b/src/EventManager/EventListener.cpp index 06a83791..5829a5ea 100644 --- a/src/EventManager/EventListener.cpp +++ b/src/EventManager/EventListener.cpp @@ -2,110 +2,107 @@ #include "src/Logger/Logger.hpp" -namespace Bloom -{ - using namespace Bloom::Events; +using namespace Events; - std::set EventListener::getRegisteredEventTypes() { - return *(this->registeredEventTypes.accessor()); - } +std::set EventListener::getRegisteredEventTypes() { + return *(this->registeredEventTypes.accessor()); +} - void EventListener::registerEvent(SharedGenericEventPointer event) { - Logger::debug( - "Event \"" + event->getName() + "\" (" + std::to_string(event->id) + ") registered for listener " - + this->name - ); +void EventListener::registerEvent(SharedGenericEventPointer event) { + Logger::debug( + "Event \"" + event->getName() + "\" (" + std::to_string(event->id) + ") registered for listener " + + this->name + ); - auto eventQueueByTypeAccessor = this->eventQueueByEventType.accessor(); - auto& eventQueueByType = *(eventQueueByTypeAccessor); + auto eventQueueByTypeAccessor = this->eventQueueByEventType.accessor(); + auto& eventQueueByType = *(eventQueueByTypeAccessor); - eventQueueByType[event->getType()].push(std::move(event)); - this->eventQueueByEventTypeCV.notify_all(); + eventQueueByType[event->getType()].push(std::move(event)); + this->eventQueueByEventTypeCV.notify_all(); - if (this->interruptEventNotifier != nullptr) { - this->interruptEventNotifier->notify(); - } - } - - void EventListener::waitAndDispatch(int msTimeout) { - { - auto queueLock = this->eventQueueByEventType.lock(); - const auto& eventQueueByType = this->eventQueueByEventType.unsafeReference(); - - const auto registeredEventTypes = this->getRegisteredEventTypes(); - std::optional event; - - const auto eventsFound = [®isteredEventTypes, &event, &eventQueueByType]() -> bool { - for (auto& eventQueue: eventQueueByType) { - if (registeredEventTypes.contains(eventQueue.first) && !eventQueue.second.empty()) { - return true; - } - } - return false; - }; - - if (msTimeout > 0) { - this->eventQueueByEventTypeCV.wait_for(queueLock, std::chrono::milliseconds(msTimeout), eventsFound); - - } else { - this->eventQueueByEventTypeCV.wait(queueLock, eventsFound); - } - } - - this->dispatchCurrentEvents(); - } - - void EventListener::dispatchEvent(const SharedGenericEventPointer& event) { - Logger::debug("Dispatching event " + event->getName() + " (" + std::to_string(event->id) + ")."); - - // Dispatch the event to all registered handlers - auto callbacks = std::vector>(); - - { - const auto callbackMappingAccessor = this->eventTypeToCallbacksMapping.accessor(); - - const auto callbacksIt = callbackMappingAccessor->find(event->getType()); - if (callbacksIt != callbackMappingAccessor->end()) { - callbacks = callbacksIt->second; - } - } - - for (auto& callback : callbacks) { - callback(*(event.get())); - } - } - - void EventListener::dispatchCurrentEvents() { - auto events = this->getEvents(); - - for (const auto& event: events) { - dispatchEvent(event); - } - } - - std::vector EventListener::getEvents() { - auto eventQueueByType = this->eventQueueByEventType.accessor(); - std::vector output; - - for (auto& eventQueue: *eventQueueByType) { - while (!eventQueue.second.empty()) { - output.push_back(std::move(eventQueue.second.front())); - eventQueue.second.pop(); - } - } - - std::sort( - output.begin(), - output.end(), - [] (const SharedGenericEventPointer& a, const SharedGenericEventPointer& b) { - return a->id < b->id; - } - ); - - return output; - } - - void EventListener::clearAllCallbacks() { - this->eventTypeToCallbacksMapping.accessor()->clear(); + if (this->interruptEventNotifier != nullptr) { + this->interruptEventNotifier->notify(); } } + +void EventListener::waitAndDispatch(int msTimeout) { + { + auto queueLock = this->eventQueueByEventType.lock(); + const auto& eventQueueByType = this->eventQueueByEventType.unsafeReference(); + + const auto registeredEventTypes = this->getRegisteredEventTypes(); + std::optional event; + + const auto eventsFound = [®isteredEventTypes, &event, &eventQueueByType]() -> bool { + for (auto& eventQueue: eventQueueByType) { + if (registeredEventTypes.contains(eventQueue.first) && !eventQueue.second.empty()) { + return true; + } + } + return false; + }; + + if (msTimeout > 0) { + this->eventQueueByEventTypeCV.wait_for(queueLock, std::chrono::milliseconds(msTimeout), eventsFound); + + } else { + this->eventQueueByEventTypeCV.wait(queueLock, eventsFound); + } + } + + this->dispatchCurrentEvents(); +} + +void EventListener::dispatchEvent(const SharedGenericEventPointer& event) { + Logger::debug("Dispatching event " + event->getName() + " (" + std::to_string(event->id) + ")."); + + // Dispatch the event to all registered handlers + auto callbacks = std::vector>(); + + { + const auto callbackMappingAccessor = this->eventTypeToCallbacksMapping.accessor(); + + const auto callbacksIt = callbackMappingAccessor->find(event->getType()); + if (callbacksIt != callbackMappingAccessor->end()) { + callbacks = callbacksIt->second; + } + } + + for (auto& callback : callbacks) { + callback(*(event.get())); + } +} + +void EventListener::dispatchCurrentEvents() { + auto events = this->getEvents(); + + for (const auto& event: events) { + dispatchEvent(event); + } +} + +std::vector EventListener::getEvents() { + auto eventQueueByType = this->eventQueueByEventType.accessor(); + std::vector output; + + for (auto& eventQueue: *eventQueueByType) { + while (!eventQueue.second.empty()) { + output.push_back(std::move(eventQueue.second.front())); + eventQueue.second.pop(); + } + } + + std::sort( + output.begin(), + output.end(), + [] (const SharedGenericEventPointer& a, const SharedGenericEventPointer& b) { + return a->id < b->id; + } + ); + + return output; +} + +void EventListener::clearAllCallbacks() { + this->eventTypeToCallbacksMapping.accessor()->clear(); +} diff --git a/src/EventManager/EventListener.hpp b/src/EventManager/EventListener.hpp index 2c74b261..d3454860 100644 --- a/src/EventManager/EventListener.hpp +++ b/src/EventManager/EventListener.hpp @@ -17,347 +17,344 @@ #include "src/Helpers/Synchronised.hpp" #include "src/Helpers/NotifierInterface.hpp" -namespace Bloom +/** + * The EventListener allows specific threads the ability to handle any events, from other threads, that + * are of interest. + * + * Usage is fairly simple: + * - Thread A creates an instance to EventListener. + * - Thread A registers callbacks for specific event types via EventListener::registerCallbackForEventType(). + * - Thread A waits for events via EventListener::waitAndDispatch() (or similar methods). + * - Thread B triggers an event of a type that Thread A registered a callback for. + * - Thread A is woken and the triggered event is dispatched to the registered callbacks for the event type. + * + * Events are distributed with shared pointers to const event objects, as each registered handler will own + * the memory (but should never make any changes to it, hence the const state). Once the final handler has + * processed the event, the shared pointer reference count will reach 0 and the event object will be destroyed. + * The type of object within the shared pointers will match that of the specific event type, once it reaches the + * callback functions. We do this by downcasting the events before we dispatch them to the callback functions. + * + * @TODO Whilst event managing should be thread safe, the same cannot be said for all of the event types. + * We need to ensure that all event types are thread safe. + */ +class EventListener { - /** - * The EventListener allows specific threads the ability to handle any events, from other threads, that - * are of interest. - * - * Usage is fairly simple: - * - Thread A creates an instance to EventListener. - * - Thread A registers callbacks for specific event types via EventListener::registerCallbackForEventType(). - * - Thread A waits for events via EventListener::waitAndDispatch() (or similar methods). - * - Thread B triggers an event of a type that Thread A registered a callback for. - * - Thread A is woken and the triggered event is dispatched to the registered callbacks for the event type. - * - * Events are distributed with shared pointers to const event objects, as each registered handler will own - * the memory (but should never make any changes to it, hence the const state). Once the final handler has - * processed the event, the shared pointer reference count will reach 0 and the event object will be destroyed. - * The type of object within the shared pointers will match that of the specific event type, once it reaches the - * callback functions. We do this by downcasting the events before we dispatch them to the callback functions. - * - * @TODO Whilst event managing should be thread safe, the same cannot be said for all of the event types. - * We need to ensure that all event types are thread safe. - */ - class EventListener - { - public: - explicit EventListener(std::string name): name(std::move(name)) {}; +public: + explicit EventListener(std::string name): name(std::move(name)) {}; - std::size_t getId() const { - return this->id; - }; - - /** - * Generates a list of event types currently registered in the listener. - * - * @return - */ - std::set getRegisteredEventTypes(); - - bool isEventTypeRegistered(Events::EventType eventType) { - return this->registeredEventTypes.accessor()->contains(eventType); - }; - - /** - * Registers an event type for the listener. - * - * Any events of EventType that are triggered from the point of calling this function, will be stored in - * listener queue until they are dispatched to a callback, or retrieved via a call to this->waitForEvent() or - * similar. - * - * @tparam EventType - */ - template - void registerEventType() { - this->registeredEventTypes.accessor()->insert(EventType::type); - } - - template - void deRegisterEventType() { - this->registeredEventTypes.accessor()->erase(EventType::type); - } - - /** - * Registers an event with the event listener - * - * @param event - */ - void registerEvent(Events::SharedGenericEventPointer event); - - void setInterruptEventNotifier(NotifierInterface* interruptEventNotifier) { - this->interruptEventNotifier = interruptEventNotifier; - } - - [[nodiscard]] NotifierInterface* getInterruptEventNotifier() { - return this->interruptEventNotifier; - } - - /** - * Registers a callback function for an event type. The callback function will be - * invoked upon an event of type EventType being dispatched to the listener. - * - * @tparam EventType - * @param callback - */ - template - void registerCallbackForEventType(std::function callback) { - // We encapsulate the callback in a lambda to handle the downcasting. - std::function parentCallback = - [callback] (const Events::Event& event) { - // Downcast the event to the expected type - callback(dynamic_cast(event)); - } - ; - - auto mappingAccessor = this->eventTypeToCallbacksMapping.accessor(); - auto& mapping = *(mappingAccessor); - - mapping[EventType::type].push_back(parentCallback); - this->template registerEventType(); - } - - /** - * Clears all registered callbacks for a specific event type. - * - * @tparam EventType - */ - template - void deregisterCallbacksForEventType() { - static_assert( - std::is_base_of::value, - "EventType is not a derivation of Event" - ); - - { - auto mappingAccessor = this->eventTypeToCallbacksMapping.accessor(); - auto& mapping = *(mappingAccessor); - - if (mapping.contains(EventType::type)) { - mapping.at(EventType::type).clear(); - } - } - - this->registeredEventTypes.accessor()->erase(EventType::type); - - auto eventQueueByType = this->eventQueueByEventType.accessor(); - if (eventQueueByType->contains(EventType::type)) { - eventQueueByType->erase(EventType::type); - } - } - - /** - * Waits for an event (of type EventTypeA, EventTypeB or EventTypeC) to be dispatched to the listener. - * Then returns the event object. If timeout is reached, an std::nullopt object will be returned. - * - * @tparam EventType - * @param timeout - * Millisecond duration to wait for an event to be dispatched to the listener. - * A value of std::nullopt will disable the timeout, meaning the function will block until the appropriate - * event has been dispatched. - * - * @param correlationId - * If a correlation ID is provided, this function will ignore any events that do not contain a matching - * correlation ID. - * - * @return - * If only one event type is passed (EventTypeA), an std::optional will be returned, carrying an - * event pointer to that event type (or std::nullopt if timeout was reached). If numerous event types are - * passed, an std::optional will carry an std::variant of the event pointers to the passed event types - * (or std::nullopt if timeout was reached). - */ - template - auto waitForEvent( - std::optional timeout = std::nullopt - ) { - // Different return types, depending on how many event type arguments are passed in. - using MonoType = std::optional>; - using BiVariantType = std::optional< - std::variant< - std::monostate, - Events::SharedEventPointer, - Events::SharedEventPointer - > - >; - using TriVariantType = std::optional< - std::variant< - std::monostate, - Events::SharedEventPointer, - Events::SharedEventPointer, - Events::SharedEventPointer - > - >; - using ReturnType = typename std::conditional< - !std::is_same_v && !std::is_same_v, - TriVariantType, - typename std::conditional, - BiVariantType, - MonoType - >::type - >::type; - - ReturnType output = std::nullopt; - - auto queueLock = this->eventQueueByEventType.lock(); - auto& eventQueueByType = this->eventQueueByEventType.unsafeReference(); - - auto eventTypes = std::set({EventTypeA::type}); - auto eventTypesToDeRegister = std::set(); - - if constexpr (!std::is_same_v) { - static_assert( - std::is_base_of_v, - "All event types must be derived from the Event base class." - ); - eventTypes.insert(EventTypeB::type); - } - - if constexpr (!std::is_same_v) { - static_assert( - std::is_base_of_v, - "All event types must be derived from the Event base class." - ); - eventTypes.insert(EventTypeC::type); - } - - { - auto registeredEventTypes = this->registeredEventTypes.accessor(); - - for (const auto& eventType : eventTypes) { - if (!registeredEventTypes->contains(eventType)) { - registeredEventTypes->insert(eventType); - eventTypesToDeRegister.insert(eventType); - } - } - } - - Events::SharedGenericEventPointer foundEvent = nullptr; - auto eventsFound = [&eventTypes, &eventQueueByType, &foundEvent] () -> bool { - for (const auto& eventType : eventTypes) { - if (eventQueueByType.find(eventType) != eventQueueByType.end() - && !eventQueueByType.find(eventType)->second.empty() - ) { - auto& queue = eventQueueByType.find(eventType)->second; - while (!queue.empty()) { - foundEvent = queue.front(); - queue.pop(); - return true; - } - } - } - - return false; - }; - - if (timeout.has_value()) { - this->eventQueueByEventTypeCV.wait_for(queueLock, timeout.value(), eventsFound); - - } else { - this->eventQueueByEventTypeCV.wait(queueLock, eventsFound); - } - - if (!eventTypesToDeRegister.empty()) { - auto registeredEventTypes = this->registeredEventTypes.accessor(); - - for (const auto& eventType : eventTypesToDeRegister) { - registeredEventTypes->erase(eventType); - } - } - - if (foundEvent != nullptr) { - // If we're looking for multiple event types, use an std::variant. - if constexpr (!std::is_same_v || !std::is_same_v) { - if (foundEvent->getType() == EventTypeA::type) { - output = std::optional( - std::dynamic_pointer_cast(foundEvent) - ); - - } else if constexpr (!std::is_same_v) { - if (foundEvent->getType() == EventTypeB::type) { - output = std::optional( - std::dynamic_pointer_cast(foundEvent) - ); - } - } - - if constexpr (!std::is_same_v) { - if (foundEvent->getType() == EventTypeC::type) { - output = std::optional( - std::dynamic_pointer_cast(foundEvent) - ); - } - } - - } else { - if (foundEvent->getType() == EventTypeA::type) { - output = std::dynamic_pointer_cast(foundEvent); - } - } - } - - return output; - } - - /** - * Waits for new events with types that have been registered with registerCallbackForEventType() and dispatches - * any events to their appropriate registered callback handlers. - * - * This method will return after one event has been handled. - */ - void waitAndDispatch(int msTimeout = 0); - - void dispatchEvent(const Events::SharedGenericEventPointer& event); - - void dispatchCurrentEvents(); - - /** - * Removes all callbacks registered for the event listener. - */ - void clearAllCallbacks(); - - private: - /** - * Human readable name for event listeners. - * - * TODO: This was useful during development, but may no longer be needed. - */ - std::string name; - - static inline std::atomic lastId = 0; - std::size_t id = ++(EventListener::lastId); - - /** - * Holds all events registered to this listener. - * - * Events are grouped by event type, and removed from their queue just *before* the dispatching to - * registered handlers begins. - */ - Synchronised>> eventQueueByEventType; - std::condition_variable eventQueueByEventTypeCV; - - /** - * A mapping of event types to a vector of callback functions. Events will be dispatched to these - * callback functions, during a call to EventListener::dispatchEvent(). - * - * Each callback will be passed a reference to the event (we wrap all registered callbacks in a lambda, where - * we perform a downcast before invoking the callback. See EventListener::registerCallbackForEventType() - * for more) - */ - Synchronised>>> eventTypeToCallbacksMapping; - Synchronised> registeredEventTypes; - - NotifierInterface* interruptEventNotifier = nullptr; - - std::vector getEvents(); + std::size_t getId() const { + return this->id; }; /** - * Every component within Bloom that requires access to events will possess an instance to the EventListener class. - * At some point (usually at component initialisation), the event listener will be registered with the EventManager, - * using EventManager::registerListener(). Upon registering the listener, the EventManager obtains partial ownership - * of the event listener. + * Generates a list of event types currently registered in the listener. * - * In other words, event listeners are managed by numerous entities and that's why we use a shared_ptr here. + * @return */ - using EventListenerPointer = std::shared_ptr; -} + std::set getRegisteredEventTypes(); + + bool isEventTypeRegistered(Events::EventType eventType) { + return this->registeredEventTypes.accessor()->contains(eventType); + }; + + /** + * Registers an event type for the listener. + * + * Any events of EventType that are triggered from the point of calling this function, will be stored in + * listener queue until they are dispatched to a callback, or retrieved via a call to this->waitForEvent() or + * similar. + * + * @tparam EventType + */ + template + void registerEventType() { + this->registeredEventTypes.accessor()->insert(EventType::type); + } + + template + void deRegisterEventType() { + this->registeredEventTypes.accessor()->erase(EventType::type); + } + + /** + * Registers an event with the event listener + * + * @param event + */ + void registerEvent(Events::SharedGenericEventPointer event); + + void setInterruptEventNotifier(NotifierInterface* interruptEventNotifier) { + this->interruptEventNotifier = interruptEventNotifier; + } + + [[nodiscard]] NotifierInterface* getInterruptEventNotifier() { + return this->interruptEventNotifier; + } + + /** + * Registers a callback function for an event type. The callback function will be + * invoked upon an event of type EventType being dispatched to the listener. + * + * @tparam EventType + * @param callback + */ + template + void registerCallbackForEventType(std::function callback) { + // We encapsulate the callback in a lambda to handle the downcasting. + std::function parentCallback = + [callback] (const Events::Event& event) { + // Downcast the event to the expected type + callback(dynamic_cast(event)); + } + ; + + auto mappingAccessor = this->eventTypeToCallbacksMapping.accessor(); + auto& mapping = *(mappingAccessor); + + mapping[EventType::type].push_back(parentCallback); + this->template registerEventType(); + } + + /** + * Clears all registered callbacks for a specific event type. + * + * @tparam EventType + */ + template + void deregisterCallbacksForEventType() { + static_assert( + std::is_base_of::value, + "EventType is not a derivation of Event" + ); + + { + auto mappingAccessor = this->eventTypeToCallbacksMapping.accessor(); + auto& mapping = *(mappingAccessor); + + if (mapping.contains(EventType::type)) { + mapping.at(EventType::type).clear(); + } + } + + this->registeredEventTypes.accessor()->erase(EventType::type); + + auto eventQueueByType = this->eventQueueByEventType.accessor(); + if (eventQueueByType->contains(EventType::type)) { + eventQueueByType->erase(EventType::type); + } + } + + /** + * Waits for an event (of type EventTypeA, EventTypeB or EventTypeC) to be dispatched to the listener. + * Then returns the event object. If timeout is reached, an std::nullopt object will be returned. + * + * @tparam EventType + * @param timeout + * Millisecond duration to wait for an event to be dispatched to the listener. + * A value of std::nullopt will disable the timeout, meaning the function will block until the appropriate + * event has been dispatched. + * + * @param correlationId + * If a correlation ID is provided, this function will ignore any events that do not contain a matching + * correlation ID. + * + * @return + * If only one event type is passed (EventTypeA), an std::optional will be returned, carrying an + * event pointer to that event type (or std::nullopt if timeout was reached). If numerous event types are + * passed, an std::optional will carry an std::variant of the event pointers to the passed event types + * (or std::nullopt if timeout was reached). + */ + template + auto waitForEvent( + std::optional timeout = std::nullopt + ) { + // Different return types, depending on how many event type arguments are passed in. + using MonoType = std::optional>; + using BiVariantType = std::optional< + std::variant< + std::monostate, + Events::SharedEventPointer, + Events::SharedEventPointer + > + >; + using TriVariantType = std::optional< + std::variant< + std::monostate, + Events::SharedEventPointer, + Events::SharedEventPointer, + Events::SharedEventPointer + > + >; + using ReturnType = typename std::conditional< + !std::is_same_v && !std::is_same_v, + TriVariantType, + typename std::conditional, + BiVariantType, + MonoType + >::type + >::type; + + ReturnType output = std::nullopt; + + auto queueLock = this->eventQueueByEventType.lock(); + auto& eventQueueByType = this->eventQueueByEventType.unsafeReference(); + + auto eventTypes = std::set({EventTypeA::type}); + auto eventTypesToDeRegister = std::set(); + + if constexpr (!std::is_same_v) { + static_assert( + std::is_base_of_v, + "All event types must be derived from the Event base class." + ); + eventTypes.insert(EventTypeB::type); + } + + if constexpr (!std::is_same_v) { + static_assert( + std::is_base_of_v, + "All event types must be derived from the Event base class." + ); + eventTypes.insert(EventTypeC::type); + } + + { + auto registeredEventTypes = this->registeredEventTypes.accessor(); + + for (const auto& eventType : eventTypes) { + if (!registeredEventTypes->contains(eventType)) { + registeredEventTypes->insert(eventType); + eventTypesToDeRegister.insert(eventType); + } + } + } + + Events::SharedGenericEventPointer foundEvent = nullptr; + auto eventsFound = [&eventTypes, &eventQueueByType, &foundEvent] () -> bool { + for (const auto& eventType : eventTypes) { + if (eventQueueByType.find(eventType) != eventQueueByType.end() + && !eventQueueByType.find(eventType)->second.empty() + ) { + auto& queue = eventQueueByType.find(eventType)->second; + while (!queue.empty()) { + foundEvent = queue.front(); + queue.pop(); + return true; + } + } + } + + return false; + }; + + if (timeout.has_value()) { + this->eventQueueByEventTypeCV.wait_for(queueLock, timeout.value(), eventsFound); + + } else { + this->eventQueueByEventTypeCV.wait(queueLock, eventsFound); + } + + if (!eventTypesToDeRegister.empty()) { + auto registeredEventTypes = this->registeredEventTypes.accessor(); + + for (const auto& eventType : eventTypesToDeRegister) { + registeredEventTypes->erase(eventType); + } + } + + if (foundEvent != nullptr) { + // If we're looking for multiple event types, use an std::variant. + if constexpr (!std::is_same_v || !std::is_same_v) { + if (foundEvent->getType() == EventTypeA::type) { + output = std::optional( + std::dynamic_pointer_cast(foundEvent) + ); + + } else if constexpr (!std::is_same_v) { + if (foundEvent->getType() == EventTypeB::type) { + output = std::optional( + std::dynamic_pointer_cast(foundEvent) + ); + } + } + + if constexpr (!std::is_same_v) { + if (foundEvent->getType() == EventTypeC::type) { + output = std::optional( + std::dynamic_pointer_cast(foundEvent) + ); + } + } + + } else { + if (foundEvent->getType() == EventTypeA::type) { + output = std::dynamic_pointer_cast(foundEvent); + } + } + } + + return output; + } + + /** + * Waits for new events with types that have been registered with registerCallbackForEventType() and dispatches + * any events to their appropriate registered callback handlers. + * + * This method will return after one event has been handled. + */ + void waitAndDispatch(int msTimeout = 0); + + void dispatchEvent(const Events::SharedGenericEventPointer& event); + + void dispatchCurrentEvents(); + + /** + * Removes all callbacks registered for the event listener. + */ + void clearAllCallbacks(); + +private: + /** + * Human readable name for event listeners. + * + * TODO: This was useful during development, but may no longer be needed. + */ + std::string name; + + static inline std::atomic lastId = 0; + std::size_t id = ++(EventListener::lastId); + + /** + * Holds all events registered to this listener. + * + * Events are grouped by event type, and removed from their queue just *before* the dispatching to + * registered handlers begins. + */ + Synchronised>> eventQueueByEventType; + std::condition_variable eventQueueByEventTypeCV; + + /** + * A mapping of event types to a vector of callback functions. Events will be dispatched to these + * callback functions, during a call to EventListener::dispatchEvent(). + * + * Each callback will be passed a reference to the event (we wrap all registered callbacks in a lambda, where + * we perform a downcast before invoking the callback. See EventListener::registerCallbackForEventType() + * for more) + */ + Synchronised>>> eventTypeToCallbacksMapping; + Synchronised> registeredEventTypes; + + NotifierInterface* interruptEventNotifier = nullptr; + + std::vector getEvents(); +}; + +/** + * Every component within Bloom that requires access to events will possess an instance to the EventListener class. + * At some point (usually at component initialisation), the event listener will be registered with the EventManager, + * using EventManager::registerListener(). Upon registering the listener, the EventManager obtains partial ownership + * of the event listener. + * + * In other words, event listeners are managed by numerous entities and that's why we use a shared_ptr here. + */ +using EventListenerPointer = std::shared_ptr; diff --git a/src/EventManager/EventManager.cpp b/src/EventManager/EventManager.cpp index 035dbfdc..43f8b0e1 100644 --- a/src/EventManager/EventManager.cpp +++ b/src/EventManager/EventManager.cpp @@ -1,36 +1,33 @@ #include "EventManager.hpp" -namespace Bloom -{ - void EventManager::registerListener(std::shared_ptr listener) { - auto registerListenersLock = std::unique_lock(EventManager::registerListenerMutex); - EventManager::registeredListeners.insert(std::pair(listener->getId(), std::move(listener))); - } +void EventManager::registerListener(std::shared_ptr listener) { + auto registerListenersLock = std::unique_lock(EventManager::registerListenerMutex); + EventManager::registeredListeners.insert(std::pair(listener->getId(), std::move(listener))); +} - void EventManager::deregisterListener(size_t listenerId) { - auto registerListenersLock = std::unique_lock(EventManager::registerListenerMutex); - EventManager::registeredListeners.erase(listenerId); - } +void EventManager::deregisterListener(size_t listenerId) { + auto registerListenersLock = std::unique_lock(EventManager::registerListenerMutex); + EventManager::registeredListeners.erase(listenerId); +} - void EventManager::triggerEvent(const std::shared_ptr& event) { - auto registerListenersLock = std::unique_lock(EventManager::registerListenerMutex); +void EventManager::triggerEvent(const std::shared_ptr& event) { + auto registerListenersLock = std::unique_lock(EventManager::registerListenerMutex); - for (const auto&[listenerId, listener] : EventManager::registeredListeners) { - if (listener->isEventTypeRegistered(event->getType())) { - listener->registerEvent(event); - } + for (const auto&[listenerId, listener] : EventManager::registeredListeners) { + if (listener->isEventTypeRegistered(event->getType())) { + listener->registerEvent(event); } } - - bool EventManager::isEventTypeListenedFor(Events::EventType eventType) { - auto registerListenersLock = std::unique_lock(EventManager::registerListenerMutex); - - for (const auto& [listenerId, listener] : EventManager::registeredListeners) { - if (listener->isEventTypeRegistered(eventType)) { - return true; - } - } - - return false; - } +} + +bool EventManager::isEventTypeListenedFor(Events::EventType eventType) { + auto registerListenersLock = std::unique_lock(EventManager::registerListenerMutex); + + for (const auto& [listenerId, listener] : EventManager::registeredListeners) { + if (listener->isEventTypeRegistered(eventType)) { + return true; + } + } + + return false; } diff --git a/src/EventManager/EventManager.hpp b/src/EventManager/EventManager.hpp index 7a6959b9..4a2b9cef 100644 --- a/src/EventManager/EventManager.hpp +++ b/src/EventManager/EventManager.hpp @@ -6,55 +6,52 @@ #include "Events/Events.hpp" #include "EventListener.hpp" -namespace Bloom +/** + * The static EventManager class provides a method of dispatching events to a set of listeners. + */ +class EventManager { +public: /** - * The static EventManager class provides a method of dispatching events to a set of listeners. + * Registers an EventListener instance with the manager. + * + * All EventListener instances must be registered with the EventManager before any events can + * be dispatched to them. + * + * The EventManager possesses partial ownership of the EventListener. This is why we use a shared_ptr here. + * + * @param listenerName */ - class EventManager - { - public: - /** - * Registers an EventListener instance with the manager. - * - * All EventListener instances must be registered with the EventManager before any events can - * be dispatched to them. - * - * The EventManager possesses partial ownership of the EventListener. This is why we use a shared_ptr here. - * - * @param listenerName - */ - static void registerListener(std::shared_ptr listener); + static void registerListener(std::shared_ptr listener); - /** - * Deregister an EventListener instance. - * - * @param listenerId - * The ID of the EventListener to deregister. See EventListener::getId(); - */ - static void deregisterListener(size_t listenerId); + /** + * Deregister an EventListener instance. + * + * @param listenerId + * The ID of the EventListener to deregister. See EventListener::getId(); + */ + static void deregisterListener(size_t listenerId); - /** - * Dispatches an event to all registered listeners, if they have registered an interest in the event type. - * See EventListener::registeredEventTypes for more. - * - * @param event - */ - static void triggerEvent(const Events::SharedGenericEventPointer& event); + /** + * Dispatches an event to all registered listeners, if they have registered an interest in the event type. + * See EventListener::registeredEventTypes for more. + * + * @param event + */ + static void triggerEvent(const Events::SharedGenericEventPointer& event); - /** - * Checks if any registered listener is listening for a particular event type. - * - * @param eventType - * @return - */ - static bool isEventTypeListenedFor(Events::EventType eventType); + /** + * Checks if any registered listener is listening for a particular event type. + * + * @param eventType + * @return + */ + static bool isEventTypeListenedFor(Events::EventType eventType); - private: - /** - * A mapping of listener IDs to registered listeners. Each registered listener is given an interger ID. - */ - static inline std::map> registeredListeners; - static inline std::mutex registerListenerMutex; - }; -} +private: + /** + * A mapping of listener IDs to registered listeners. Each registered listener is given an interger ID. + */ + static inline std::map> registeredListeners; + static inline std::mutex registerListenerMutex; +}; diff --git a/src/EventManager/Events/DebugServerThreadStateChanged.hpp b/src/EventManager/Events/DebugServerThreadStateChanged.hpp index 17b0d10a..0c4c6a70 100644 --- a/src/EventManager/Events/DebugServerThreadStateChanged.hpp +++ b/src/EventManager/Events/DebugServerThreadStateChanged.hpp @@ -5,7 +5,7 @@ #include "Event.hpp" #include "src/Helpers/Thread.hpp" -namespace Bloom::Events +namespace Events { class DebugServerThreadStateChanged: public Event { diff --git a/src/EventManager/Events/DebugSessionFinished.hpp b/src/EventManager/Events/DebugSessionFinished.hpp index b6d8c8f5..d7bacbe4 100644 --- a/src/EventManager/Events/DebugSessionFinished.hpp +++ b/src/EventManager/Events/DebugSessionFinished.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class DebugSessionFinished: public Event { diff --git a/src/EventManager/Events/DebugSessionStarted.hpp b/src/EventManager/Events/DebugSessionStarted.hpp index d2c8aa30..5555747f 100644 --- a/src/EventManager/Events/DebugSessionStarted.hpp +++ b/src/EventManager/Events/DebugSessionStarted.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class DebugSessionStarted: public Event { diff --git a/src/EventManager/Events/Event.hpp b/src/EventManager/Events/Event.hpp index ef182974..ecce1e20 100644 --- a/src/EventManager/Events/Event.hpp +++ b/src/EventManager/Events/Event.hpp @@ -8,7 +8,7 @@ #include "src/Services/DateTimeService.hpp" -namespace Bloom::Events +namespace Events { static_assert(std::atomic::is_always_lock_free); diff --git a/src/EventManager/Events/Events.hpp b/src/EventManager/Events/Events.hpp index 099a1ef1..7625b630 100644 --- a/src/EventManager/Events/Events.hpp +++ b/src/EventManager/Events/Events.hpp @@ -24,7 +24,7 @@ #include "InsightMainWindowClosed.hpp" #endif -namespace Bloom::Events +namespace Events { template using SharedEventPointer = std::shared_ptr; diff --git a/src/EventManager/Events/InsightActivationRequested.hpp b/src/EventManager/Events/InsightActivationRequested.hpp index 77b73d6b..76e5f058 100644 --- a/src/EventManager/Events/InsightActivationRequested.hpp +++ b/src/EventManager/Events/InsightActivationRequested.hpp @@ -5,7 +5,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class InsightActivationRequested: public Event { diff --git a/src/EventManager/Events/InsightMainWindowClosed.hpp b/src/EventManager/Events/InsightMainWindowClosed.hpp index 882c16ac..3a6da96c 100644 --- a/src/EventManager/Events/InsightMainWindowClosed.hpp +++ b/src/EventManager/Events/InsightMainWindowClosed.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class InsightMainWindowClosed: public Event { diff --git a/src/EventManager/Events/MemoryWrittenToTarget.hpp b/src/EventManager/Events/MemoryWrittenToTarget.hpp index bcd11da2..fba85194 100644 --- a/src/EventManager/Events/MemoryWrittenToTarget.hpp +++ b/src/EventManager/Events/MemoryWrittenToTarget.hpp @@ -5,7 +5,7 @@ #include "Event.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Events +namespace Events { class MemoryWrittenToTarget: public Event { diff --git a/src/EventManager/Events/ProgrammingModeDisabled.hpp b/src/EventManager/Events/ProgrammingModeDisabled.hpp index 624fa2c5..fbce1109 100644 --- a/src/EventManager/Events/ProgrammingModeDisabled.hpp +++ b/src/EventManager/Events/ProgrammingModeDisabled.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class ProgrammingModeDisabled: public Event { diff --git a/src/EventManager/Events/ProgrammingModeEnabled.hpp b/src/EventManager/Events/ProgrammingModeEnabled.hpp index 05bd544b..6f101539 100644 --- a/src/EventManager/Events/ProgrammingModeEnabled.hpp +++ b/src/EventManager/Events/ProgrammingModeEnabled.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class ProgrammingModeEnabled: public Event { diff --git a/src/EventManager/Events/RegistersWrittenToTarget.hpp b/src/EventManager/Events/RegistersWrittenToTarget.hpp index f4b4c54e..f2a76ebd 100644 --- a/src/EventManager/Events/RegistersWrittenToTarget.hpp +++ b/src/EventManager/Events/RegistersWrittenToTarget.hpp @@ -5,7 +5,7 @@ #include "Event.hpp" #include "src/Targets/TargetRegister.hpp" -namespace Bloom::Events +namespace Events { class RegistersWrittenToTarget: public Event { diff --git a/src/EventManager/Events/ShutdownApplication.hpp b/src/EventManager/Events/ShutdownApplication.hpp index e0a1d67c..f778cf58 100644 --- a/src/EventManager/Events/ShutdownApplication.hpp +++ b/src/EventManager/Events/ShutdownApplication.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class ShutdownApplication: public Event { diff --git a/src/EventManager/Events/ShutdownDebugServer.hpp b/src/EventManager/Events/ShutdownDebugServer.hpp index 1fe372d1..3c98fa78 100644 --- a/src/EventManager/Events/ShutdownDebugServer.hpp +++ b/src/EventManager/Events/ShutdownDebugServer.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class ShutdownDebugServer: public Event { diff --git a/src/EventManager/Events/ShutdownTargetController.hpp b/src/EventManager/Events/ShutdownTargetController.hpp index 0d7630d5..f45e546d 100644 --- a/src/EventManager/Events/ShutdownTargetController.hpp +++ b/src/EventManager/Events/ShutdownTargetController.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class ShutdownTargetController: public Event { diff --git a/src/EventManager/Events/TargetControllerErrorOccurred.hpp b/src/EventManager/Events/TargetControllerErrorOccurred.hpp index 9d514b6b..1d52d1a8 100644 --- a/src/EventManager/Events/TargetControllerErrorOccurred.hpp +++ b/src/EventManager/Events/TargetControllerErrorOccurred.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class TargetControllerErrorOccurred: public Event { diff --git a/src/EventManager/Events/TargetControllerThreadStateChanged.hpp b/src/EventManager/Events/TargetControllerThreadStateChanged.hpp index 760ece19..9e665b7c 100644 --- a/src/EventManager/Events/TargetControllerThreadStateChanged.hpp +++ b/src/EventManager/Events/TargetControllerThreadStateChanged.hpp @@ -5,7 +5,7 @@ #include "Event.hpp" #include "src/Helpers/Thread.hpp" -namespace Bloom::Events +namespace Events { class TargetControllerThreadStateChanged: public Event { diff --git a/src/EventManager/Events/TargetExecutionResumed.hpp b/src/EventManager/Events/TargetExecutionResumed.hpp index 7b4e1a1a..0a6b16ea 100644 --- a/src/EventManager/Events/TargetExecutionResumed.hpp +++ b/src/EventManager/Events/TargetExecutionResumed.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class TargetExecutionResumed: public Event { diff --git a/src/EventManager/Events/TargetExecutionStopped.hpp b/src/EventManager/Events/TargetExecutionStopped.hpp index 5db53307..3ae02311 100644 --- a/src/EventManager/Events/TargetExecutionStopped.hpp +++ b/src/EventManager/Events/TargetExecutionStopped.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetBreakpoint.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Events +namespace Events { class TargetExecutionStopped: public Event { diff --git a/src/EventManager/Events/TargetReset.hpp b/src/EventManager/Events/TargetReset.hpp index 6eb08a9b..58e8de3d 100644 --- a/src/EventManager/Events/TargetReset.hpp +++ b/src/EventManager/Events/TargetReset.hpp @@ -4,7 +4,7 @@ #include "Event.hpp" -namespace Bloom::Events +namespace Events { class TargetReset: public Event { diff --git a/src/Exceptions/Exception.hpp b/src/Exceptions/Exception.hpp index c6b3da5a..507d5bb4 100644 --- a/src/Exceptions/Exception.hpp +++ b/src/Exceptions/Exception.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Exceptions +namespace Exceptions { class Exception: public std::runtime_error { diff --git a/src/Exceptions/InvalidConfig.hpp b/src/Exceptions/InvalidConfig.hpp index a99e9f3f..1d5688c8 100644 --- a/src/Exceptions/InvalidConfig.hpp +++ b/src/Exceptions/InvalidConfig.hpp @@ -2,7 +2,7 @@ #include "Exception.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class InvalidConfig: public Exception { diff --git a/src/Exceptions/TargetControllerStartupFailure.hpp b/src/Exceptions/TargetControllerStartupFailure.hpp index 7c4c524c..49794ac1 100644 --- a/src/Exceptions/TargetControllerStartupFailure.hpp +++ b/src/Exceptions/TargetControllerStartupFailure.hpp @@ -2,7 +2,7 @@ #include "Exception.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class TargetControllerStartupFailure: public Exception { diff --git a/src/Helpers/BiMap.hpp b/src/Helpers/BiMap.hpp index 8f9011fc..a4912ca3 100644 --- a/src/Helpers/BiMap.hpp +++ b/src/Helpers/BiMap.hpp @@ -5,109 +5,106 @@ #include #include -namespace Bloom +/** + * Simple bidirectional map + * + * This should only be used for small maps, with small elements (enums, string literals, etc). + * + * TODO: This needs some work - was written as a quick implementation with minimal requirements. + * TODO: Add support for inserting/deleting elements (outside of construction). + * + * @tparam TypeA + * @tparam TypeB + */ +template +class BiMap { - /** - * Simple bidirectional map - * - * This should only be used for small maps, with small elements (enums, string literals, etc). - * - * TODO: This needs some work - was written as a quick implementation with minimal requirements. - * TODO: Add support for inserting/deleting elements (outside of construction). - * - * @tparam TypeA - * @tparam TypeB - */ - template - class BiMap - { - public: - BiMap(std::initializer_list> elements) { - for (auto it = elements.begin(); it != elements.end(); ++it) { - this->map.insert(std::pair{it->first, it->second}); - this->flippedMap.insert(std::pair(it->second, it->first)); - } +public: + BiMap(std::initializer_list> elements) { + for (auto it = elements.begin(); it != elements.end(); ++it) { + this->map.insert(std::pair{it->first, it->second}); + this->flippedMap.insert(std::pair(it->second, it->first)); + } + } + + bool contains(const TypeA& key) const { + return this->map.find(key) != this->map.end(); + } + + bool contains(const TypeB& key) const { + return this->flippedMap.find(key) != this->flippedMap.end(); + } + + auto find(const TypeA& key) const { + const auto valueIt = this->map.find(key); + return valueIt != this->map.end() ? std::optional(valueIt) : std::nullopt; + } + + auto find(const TypeB& key) const { + const auto valueIt = this->flippedMap.find(key); + return valueIt != this->flippedMap.end() ? std::optional(valueIt) : std::nullopt; + } + + std::optional valueAt(const TypeA& key) const { + std::optional output; + + const auto valueIt = this->map.find(key); + if (valueIt != this->map.end()) { + output = valueIt->second; } - bool contains(const TypeA& key) const { - return this->map.find(key) != this->map.end(); + return output; + } + + std::optional valueAt(const TypeB& key) const { + std::optional output; + + const auto valueIt = this->flippedMap.find(key); + if (valueIt != this->flippedMap.end()) { + output = valueIt->second; } - bool contains(const TypeB& key) const { - return this->flippedMap.find(key) != this->flippedMap.end(); + return output; + } + + const TypeB& at(const TypeA& key) const { + return this->map.at(key); + } + + const TypeA& at(const TypeB& key) const { + return this->flippedMap.at(key); + } + + [[nodiscard]] std::unordered_map getMap() const { + return this->map; + } + + [[nodiscard]] std::set getKeys() const { + auto keys = std::set(); + + for (const auto& [key, value] : this->map) { + keys.insert(key); } - auto find(const TypeA& key) const { - const auto valueIt = this->map.find(key); - return valueIt != this->map.end() ? std::optional(valueIt) : std::nullopt; + return keys; + } + + [[nodiscard]] std::set getValues() const { + auto values = std::set(); + + for (const auto& [key, value] : this->map) { + values.insert(value); } - auto find(const TypeB& key) const { - const auto valueIt = this->flippedMap.find(key); - return valueIt != this->flippedMap.end() ? std::optional(valueIt) : std::nullopt; - } + return values; + } - std::optional valueAt(const TypeA& key) const { - std::optional output; + void insert(const std::pair& pair) { + auto insertResultPair = this->map.insert(pair); + this->flippedMap.insert(std::pair(pair.second, pair.first)); + } - const auto valueIt = this->map.find(key); - if (valueIt != this->map.end()) { - output = valueIt->second; - } - - return output; - } - - std::optional valueAt(const TypeB& key) const { - std::optional output; - - const auto valueIt = this->flippedMap.find(key); - if (valueIt != this->flippedMap.end()) { - output = valueIt->second; - } - - return output; - } - - const TypeB& at(const TypeA& key) const { - return this->map.at(key); - } - - const TypeA& at(const TypeB& key) const { - return this->flippedMap.at(key); - } - - [[nodiscard]] std::unordered_map getMap() const { - return this->map; - } - - [[nodiscard]] std::set getKeys() const { - auto keys = std::set(); - - for (const auto& [key, value] : this->map) { - keys.insert(key); - } - - return keys; - } - - [[nodiscard]] std::set getValues() const { - auto values = std::set(); - - for (const auto& [key, value] : this->map) { - values.insert(value); - } - - return values; - } - - void insert(const std::pair& pair) { - auto insertResultPair = this->map.insert(pair); - this->flippedMap.insert(std::pair(pair.second, pair.first)); - } - - private: - std::unordered_map map = {}; - std::unordered_map flippedMap = {}; - }; -} +private: + std::unordered_map map = {}; + std::unordered_map flippedMap = {}; +}; diff --git a/src/Helpers/ConditionVariableNotifier.cpp b/src/Helpers/ConditionVariableNotifier.cpp index 3457ca2e..d3903976 100644 --- a/src/Helpers/ConditionVariableNotifier.cpp +++ b/src/Helpers/ConditionVariableNotifier.cpp @@ -1,26 +1,23 @@ #include "ConditionVariableNotifier.hpp" -namespace Bloom -{ - void ConditionVariableNotifier::notify() { - const auto lock = std::unique_lock(this->mutex); - this->notified = true; - this->conditionalVariable.notify_all(); - } - - void ConditionVariableNotifier::waitForNotification(std::optional timeout) { - const auto predicate = [this] { - return this->notified; - }; - auto lock = std::unique_lock(this->mutex); - - if (timeout.has_value()) { - this->conditionalVariable.wait_for(lock, timeout.value(), predicate); - - } else { - this->conditionalVariable.wait(lock, predicate); - } - - this->notified = false; - } +void ConditionVariableNotifier::notify() { + const auto lock = std::unique_lock(this->mutex); + this->notified = true; + this->conditionalVariable.notify_all(); +} + +void ConditionVariableNotifier::waitForNotification(std::optional timeout) { + const auto predicate = [this] { + return this->notified; + }; + auto lock = std::unique_lock(this->mutex); + + if (timeout.has_value()) { + this->conditionalVariable.wait_for(lock, timeout.value(), predicate); + + } else { + this->conditionalVariable.wait(lock, predicate); + } + + this->notified = false; } diff --git a/src/Helpers/ConditionVariableNotifier.hpp b/src/Helpers/ConditionVariableNotifier.hpp index 174a040d..be2d6bfe 100644 --- a/src/Helpers/ConditionVariableNotifier.hpp +++ b/src/Helpers/ConditionVariableNotifier.hpp @@ -7,40 +7,37 @@ #include "NotifierInterface.hpp" -namespace Bloom +/** + * The ConditionVariableNotifier class is an implementation of the NotifierInterface, using an + * std::condition_variable. + */ +class ConditionVariableNotifier: public NotifierInterface { - /** - * The ConditionVariableNotifier class is an implementation of the NotifierInterface, using an - * std::condition_variable. +public: + ConditionVariableNotifier() = default; + ~ConditionVariableNotifier() override = default; + + /* + * ConditionVariableNotifier objects should not be copied. */ - class ConditionVariableNotifier: public NotifierInterface - { - public: - ConditionVariableNotifier() = default; - ~ConditionVariableNotifier() override = default; + ConditionVariableNotifier(ConditionVariableNotifier& other) = delete; + ConditionVariableNotifier& operator = (ConditionVariableNotifier& other) = delete; - /* - * ConditionVariableNotifier objects should not be copied. - */ - ConditionVariableNotifier(ConditionVariableNotifier& other) = delete; - ConditionVariableNotifier& operator = (ConditionVariableNotifier& other) = delete; + /* + * TODO: Implement this. + */ + ConditionVariableNotifier(ConditionVariableNotifier&& other) noexcept = delete; + ConditionVariableNotifier& operator = (ConditionVariableNotifier&& other) = delete; - /* - * TODO: Implement this. - */ - ConditionVariableNotifier(ConditionVariableNotifier&& other) noexcept = delete; - ConditionVariableNotifier& operator = (ConditionVariableNotifier&& other) = delete; + void notify() override; - void notify() override; + /** + * Blocks until the contained std::conditional_variable is notified. + */ + void waitForNotification(std::optional timeout = std::nullopt); - /** - * Blocks until the contained std::conditional_variable is notified. - */ - void waitForNotification(std::optional timeout = std::nullopt); - - private: - std::mutex mutex; - std::condition_variable conditionalVariable; - bool notified = false; - }; -} +private: + std::mutex mutex; + std::condition_variable conditionalVariable; + bool notified = false; +}; diff --git a/src/Helpers/DereferenceLessComparator.hpp b/src/Helpers/DereferenceLessComparator.hpp index 083770aa..7a0c20bd 100644 --- a/src/Helpers/DereferenceLessComparator.hpp +++ b/src/Helpers/DereferenceLessComparator.hpp @@ -2,13 +2,11 @@ #include -namespace Bloom { - template - requires std::is_pointer::value - struct DereferenceLessComparator - { - constexpr bool operator () (const Type& lhs, const Type& rhs) const { - return *lhs < *rhs; - } - }; -} +template + requires std::is_pointer::value +struct DereferenceLessComparator +{ + constexpr bool operator () (const Type& lhs, const Type& rhs) const { + return *lhs < *rhs; + } +}; diff --git a/src/Helpers/EnumToStringMappings.hpp b/src/Helpers/EnumToStringMappings.hpp index 1a93e144..f1f15864 100644 --- a/src/Helpers/EnumToStringMappings.hpp +++ b/src/Helpers/EnumToStringMappings.hpp @@ -6,21 +6,18 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom +class EnumToStringMappings { - class EnumToStringMappings - { - public: - static const inline BiMap targetMemoryTypes = { - {Targets::TargetMemoryType::RAM, "ram"}, - {Targets::TargetMemoryType::EEPROM, "eeprom"}, - {Targets::TargetMemoryType::FLASH, "flash"}, - {Targets::TargetMemoryType::OTHER, "other"}, - }; - - static const inline BiMap targetMemoryEndianness = { - {Targets::TargetMemoryEndianness::LITTLE, "little"}, - {Targets::TargetMemoryEndianness::BIG, "big"}, - }; +public: + static const inline BiMap targetMemoryTypes = { + {Targets::TargetMemoryType::RAM, "ram"}, + {Targets::TargetMemoryType::EEPROM, "eeprom"}, + {Targets::TargetMemoryType::FLASH, "flash"}, + {Targets::TargetMemoryType::OTHER, "other"}, }; -} + + static const inline BiMap targetMemoryEndianness = { + {Targets::TargetMemoryEndianness::LITTLE, "little"}, + {Targets::TargetMemoryEndianness::BIG, "big"}, + }; +}; diff --git a/src/Helpers/EpollInstance.cpp b/src/Helpers/EpollInstance.cpp index 0d55102d..4bebcded 100644 --- a/src/Helpers/EpollInstance.cpp +++ b/src/Helpers/EpollInstance.cpp @@ -7,71 +7,68 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - using Exceptions::Exception; +using Exceptions::Exception; - EpollInstance::EpollInstance() { - this->fileDescriptor = ::epoll_create(1); +EpollInstance::EpollInstance() { + this->fileDescriptor = ::epoll_create(1); - if (this->fileDescriptor < 0) { - throw Exception( - "Failed to create epoll instance - error number " + std::to_string(errno) - + " returned." - ); - } - } - - void EpollInstance::addEntry(int fileDescriptor, std::uint16_t eventMask) { - struct ::epoll_event event = { - .events = eventMask, - .data = { - .fd = fileDescriptor - } - }; - - if (::epoll_ctl(this->fileDescriptor.value(), EPOLL_CTL_ADD, fileDescriptor, &event) != 0) { - throw Exception( - "Failed to add entry to epoll instance - error number " + std::to_string(errno) + " returned." - ); - } - } - - void EpollInstance::removeEntry(int fileDescriptor) { - if (::epoll_ctl(this->fileDescriptor.value(), EPOLL_CTL_DEL, fileDescriptor, NULL) != 0) { - throw Exception( - "Failed to remove entry from epoll instance - error number " + std::to_string(errno) - + " returned." - ); - } - } - - std::optional EpollInstance::waitForEvent(std::optional timeout) const { - std::array events = {}; - - const auto eventCount = ::epoll_wait( - this->fileDescriptor.value(), - events.data(), - 1, - timeout.has_value() ? static_cast(timeout->count()) : -1 + if (this->fileDescriptor < 0) { + throw Exception( + "Failed to create epoll instance - error number " + std::to_string(errno) + + " returned." ); - - if (eventCount < 1) { - return std::nullopt; - } - - return static_cast(events.at(0).data.fd); - } - - EpollInstance::EpollInstance(EpollInstance&& other) noexcept - : fileDescriptor(other.fileDescriptor) - { - other.fileDescriptor = std::nullopt; - } - - EpollInstance::~EpollInstance() noexcept { - if (this->fileDescriptor.value_or(-1) >= 0) { - ::close(this->fileDescriptor.value()); - } + } +} + +void EpollInstance::addEntry(int fileDescriptor, std::uint16_t eventMask) { + struct ::epoll_event event = { + .events = eventMask, + .data = { + .fd = fileDescriptor + } + }; + + if (::epoll_ctl(this->fileDescriptor.value(), EPOLL_CTL_ADD, fileDescriptor, &event) != 0) { + throw Exception( + "Failed to add entry to epoll instance - error number " + std::to_string(errno) + " returned." + ); + } +} + +void EpollInstance::removeEntry(int fileDescriptor) { + if (::epoll_ctl(this->fileDescriptor.value(), EPOLL_CTL_DEL, fileDescriptor, NULL) != 0) { + throw Exception( + "Failed to remove entry from epoll instance - error number " + std::to_string(errno) + + " returned." + ); + } +} + +std::optional EpollInstance::waitForEvent(std::optional timeout) const { + std::array events = {}; + + const auto eventCount = ::epoll_wait( + this->fileDescriptor.value(), + events.data(), + 1, + timeout.has_value() ? static_cast(timeout->count()) : -1 + ); + + if (eventCount < 1) { + return std::nullopt; + } + + return static_cast(events.at(0).data.fd); +} + +EpollInstance::EpollInstance(EpollInstance&& other) noexcept + : fileDescriptor(other.fileDescriptor) +{ + other.fileDescriptor = std::nullopt; +} + +EpollInstance::~EpollInstance() noexcept { + if (this->fileDescriptor.value_or(-1) >= 0) { + ::close(this->fileDescriptor.value()); } } diff --git a/src/Helpers/EpollInstance.hpp b/src/Helpers/EpollInstance.hpp index e8b3226f..deb37112 100644 --- a/src/Helpers/EpollInstance.hpp +++ b/src/Helpers/EpollInstance.hpp @@ -5,62 +5,59 @@ #include #include -namespace Bloom +/** + * RAII wrapper for an epoll instance. + * + * See https://man7.org/linux/man-pages/man7/epoll.7.html for more on the Linux epoll API. + */ +class EpollInstance { +public: + EpollInstance(); + /** - * RAII wrapper for an epoll instance. + * Adds an entry to the epoll instance. * - * See https://man7.org/linux/man-pages/man7/epoll.7.html for more on the Linux epoll API. + * @param fileDescriptor + * @param eventMask */ - class EpollInstance - { - public: - EpollInstance(); + void addEntry(int fileDescriptor, std::uint16_t eventMask); - /** - * Adds an entry to the epoll instance. - * - * @param fileDescriptor - * @param eventMask - */ - void addEntry(int fileDescriptor, std::uint16_t eventMask); + /** + * Removes an entry from the epoll instance. + * + * @param fileDescriptor + */ + void removeEntry(int fileDescriptor); - /** - * Removes an entry from the epoll instance. - * - * @param fileDescriptor - */ - void removeEntry(int fileDescriptor); + /** + * Waits on the epoll instance until an event occurs for any of the registered files. + * + * @param timeout + * Millisecond timeout. If not provided, no timeout will be applied and this function will block until an + * event occurs. + * + * @return + * The file descriptor of the file for which the event occurred, or std::nullopt if a timeout was reached. + */ + [[nodiscard]] std::optional waitForEvent( + std::optional timeout = std::nullopt + ) const; - /** - * Waits on the epoll instance until an event occurs for any of the registered files. - * - * @param timeout - * Millisecond timeout. If not provided, no timeout will be applied and this function will block until an - * event occurs. - * - * @return - * The file descriptor of the file for which the event occurred, or std::nullopt if a timeout was reached. - */ - [[nodiscard]] std::optional waitForEvent( - std::optional timeout = std::nullopt - ) const; + /* + * EpollInstance objects should not be copied. + */ + EpollInstance(EpollInstance& other) = delete; + EpollInstance& operator = (EpollInstance& other) = delete; - /* - * EpollInstance objects should not be copied. - */ - EpollInstance(EpollInstance& other) = delete; - EpollInstance& operator = (EpollInstance& other) = delete; + /* + * TODO: Implement this. For now, use the move constructor. + */ + EpollInstance& operator = (EpollInstance&& other) = delete; - /* - * TODO: Implement this. For now, use the move constructor. - */ - EpollInstance& operator = (EpollInstance&& other) = delete; + EpollInstance(EpollInstance&& other) noexcept; + ~EpollInstance() noexcept; - EpollInstance(EpollInstance&& other) noexcept; - ~EpollInstance() noexcept; - - private: - std::optional fileDescriptor; - }; -} +private: + std::optional fileDescriptor; +}; diff --git a/src/Helpers/EventFdNotifier.cpp b/src/Helpers/EventFdNotifier.cpp index e72e3b88..9bbb3531 100644 --- a/src/Helpers/EventFdNotifier.cpp +++ b/src/Helpers/EventFdNotifier.cpp @@ -7,49 +7,46 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - using Exceptions::Exception; +using Exceptions::Exception; - EventFdNotifier::EventFdNotifier() { - this->fileDescriptor = ::eventfd(0, ::EFD_NONBLOCK); +EventFdNotifier::EventFdNotifier() { + this->fileDescriptor = ::eventfd(0, ::EFD_NONBLOCK); - if (this->fileDescriptor < 0) { - throw Exception( - "Failed to create eventfd object - error number " + std::to_string(errno) - + " returned." - ); - } - } - - EventFdNotifier::EventFdNotifier(EventFdNotifier&& other) noexcept - : fileDescriptor(other.fileDescriptor) - { - other.fileDescriptor = std::nullopt; - } - - EventFdNotifier::~EventFdNotifier() noexcept { - this->close(); - } - - void EventFdNotifier::notify() { - if (::eventfd_write(this->fileDescriptor.value(), 1) < 0) { - throw Exceptions::Exception("Failed to increment eventfd counter - error number: " - + std::to_string(errno)); - } - } - - void EventFdNotifier::clear() { - ::eventfd_t counter = {}; - if (::eventfd_read(this->fileDescriptor.value(), &counter) < 0 && errno != EAGAIN) { - throw Exceptions::Exception("Failed to clear EventFdNotifier object - eventfd_read failed - " - "error number: " + std::to_string(errno)); - } - } - - void EventFdNotifier::close() { - if (this->fileDescriptor.value_or(-1) >= 0) { - ::close(this->fileDescriptor.value()); - } + if (this->fileDescriptor < 0) { + throw Exception( + "Failed to create eventfd object - error number " + std::to_string(errno) + + " returned." + ); + } +} + +EventFdNotifier::EventFdNotifier(EventFdNotifier&& other) noexcept + : fileDescriptor(other.fileDescriptor) +{ + other.fileDescriptor = std::nullopt; +} + +EventFdNotifier::~EventFdNotifier() noexcept { + this->close(); +} + +void EventFdNotifier::notify() { + if (::eventfd_write(this->fileDescriptor.value(), 1) < 0) { + throw Exceptions::Exception("Failed to increment eventfd counter - error number: " + + std::to_string(errno)); + } +} + +void EventFdNotifier::clear() { + ::eventfd_t counter = {}; + if (::eventfd_read(this->fileDescriptor.value(), &counter) < 0 && errno != EAGAIN) { + throw Exceptions::Exception("Failed to clear EventFdNotifier object - eventfd_read failed - " + "error number: " + std::to_string(errno)); + } +} + +void EventFdNotifier::close() { + if (this->fileDescriptor.value_or(-1) >= 0) { + ::close(this->fileDescriptor.value()); } } diff --git a/src/Helpers/EventFdNotifier.hpp b/src/Helpers/EventFdNotifier.hpp index f691cb76..09b72fdd 100644 --- a/src/Helpers/EventFdNotifier.hpp +++ b/src/Helpers/EventFdNotifier.hpp @@ -4,41 +4,38 @@ #include "NotifierInterface.hpp" -namespace Bloom +/** + * RAII wrapper for a Linux eventfd object, used to implement the NotifierInterface. + */ +class EventFdNotifier: public NotifierInterface { - /** - * RAII wrapper for a Linux eventfd object, used to implement the NotifierInterface. +public: + EventFdNotifier(); + + /* + * EventNotifier objects should not be copied. */ - class EventFdNotifier: public NotifierInterface - { - public: - EventFdNotifier(); + EventFdNotifier(EventFdNotifier& other) = delete; + EventFdNotifier& operator = (EventFdNotifier& other) = delete; - /* - * EventNotifier objects should not be copied. - */ - EventFdNotifier(EventFdNotifier& other) = delete; - EventFdNotifier& operator = (EventFdNotifier& other) = delete; + /* + * TODO: Implement this. For now, use the move constructor. + */ + EventFdNotifier& operator = (EventFdNotifier&& other) = delete; - /* - * TODO: Implement this. For now, use the move constructor. - */ - EventFdNotifier& operator = (EventFdNotifier&& other) = delete; + EventFdNotifier(EventFdNotifier&& other) noexcept; + ~EventFdNotifier() noexcept override; - EventFdNotifier(EventFdNotifier&& other) noexcept; - ~EventFdNotifier() noexcept override; + [[nodiscard]] int getFileDescriptor() const { + return this->fileDescriptor.value(); + } - [[nodiscard]] int getFileDescriptor() const { - return this->fileDescriptor.value(); - } + void notify() override; - void notify() override; + void clear(); - void clear(); +private: + std::optional fileDescriptor; - private: - std::optional fileDescriptor; - - void close(); - }; -} + void close(); +}; diff --git a/src/Helpers/NotifierInterface.hpp b/src/Helpers/NotifierInterface.hpp index 2e059ee3..0c6da2eb 100644 --- a/src/Helpers/NotifierInterface.hpp +++ b/src/Helpers/NotifierInterface.hpp @@ -1,37 +1,34 @@ #pragma once -namespace Bloom +/** + * The NotifierInterface class describes an interface for notifying different components, within Bloom, of something + * important that has just happened. + * + * It's important to note that this interface only describes the issuing of notifications. It *does not* describe + * the listening for notifications. The listening can be defined by the implementation. + * + * For example, consider the EventFdNotifier implementation. That class is just an RAII wrapper for a Linux eventfd + * object. Notifications are recorded by incrementing the eventfd counter. And they can be listened for, using + * Linux system functions like poll(), select(), and similar. + * + * The EventListener class can hold a pointer to a NotifierInterface, where it will invoke + * NotifierInterface::notify() everytime a new event is registered on the listener. + */ +class NotifierInterface { +public: + NotifierInterface() = default; + virtual ~NotifierInterface() noexcept = default; + + NotifierInterface(NotifierInterface& other) = delete; + + NotifierInterface& operator = (NotifierInterface& other) = delete; + NotifierInterface& operator = (NotifierInterface&& other) = delete; + + NotifierInterface(NotifierInterface&& other) noexcept = default; + /** - * The NotifierInterface class describes an interface for notifying different components, within Bloom, of something - * important that has just happened. - * - * It's important to note that this interface only describes the issuing of notifications. It *does not* describe - * the listening for notifications. The listening can be defined by the implementation. - * - * For example, consider the EventFdNotifier implementation. That class is just an RAII wrapper for a Linux eventfd - * object. Notifications are recorded by incrementing the eventfd counter. And they can be listened for, using - * Linux system functions like poll(), select(), and similar. - * - * The EventListener class can hold a pointer to a NotifierInterface, where it will invoke - * NotifierInterface::notify() everytime a new event is registered on the listener. + * Should record a notification. */ - class NotifierInterface - { - public: - NotifierInterface() = default; - virtual ~NotifierInterface() noexcept = default; - - NotifierInterface(NotifierInterface& other) = delete; - - NotifierInterface& operator = (NotifierInterface& other) = delete; - NotifierInterface& operator = (NotifierInterface&& other) = delete; - - NotifierInterface(NotifierInterface&& other) noexcept = default; - - /** - * Should record a notification. - */ - virtual void notify() = 0; - }; -} + virtual void notify() = 0; +}; diff --git a/src/Helpers/Synchronised.hpp b/src/Helpers/Synchronised.hpp index 45131f1a..15486f5c 100644 --- a/src/Helpers/Synchronised.hpp +++ b/src/Helpers/Synchronised.hpp @@ -3,76 +3,73 @@ #include #include -namespace Bloom +/** + * Wrapper for synchronised access to a resource. + * + * @tparam Type + */ +template +class Synchronised { - /** - * Wrapper for synchronised access to a resource. - * - * @tparam Type - */ - template - class Synchronised +public: + class Accessor { public: - class Accessor - { - public: - constexpr Accessor(std::mutex& mutex, Type& value) - : lock(std::unique_lock(mutex)) - , value(value) - {} - - constexpr Type* operator -> () noexcept { - return &(this->value); - } - - constexpr const Type* operator -> () const noexcept { - return &(this->value); - } - - constexpr Type& operator * () noexcept { - return this->value; - } - - constexpr const Type& operator * () const noexcept { - return this->value; - } - - private: - std::unique_lock lock; - Type& value; - }; - - Synchronised() = default; - - explicit Synchronised(Type value) - : value(std::move(value)) + constexpr Accessor(std::mutex& mutex, Type& value) + : lock(std::unique_lock(mutex)) + , value(value) {} - Accessor accessor() { - return Accessor(this->mutex, this->value); + constexpr Type* operator -> () noexcept { + return &(this->value); } - /** - * Don't use this unless you already hold a raw (not managed by an Accessor) lock to the contained value. - * - * This should only be used in instances where you need to hold a raw lock, like in the `stop_waiting` - * predicate function for a call to std::condition_variable::wait(). - * - * In all other instances, you should use Synchronised::accessor(). - * - * @return - */ - Type& unsafeReference() { + constexpr const Type* operator -> () const noexcept { + return &(this->value); + } + + constexpr Type& operator * () noexcept { return this->value; } - std::unique_lock lock() { - return std::unique_lock(this->mutex); + constexpr const Type& operator * () const noexcept { + return this->value; } private: - Type value; - std::mutex mutex; + std::unique_lock lock; + Type& value; }; -} + + Synchronised() = default; + + explicit Synchronised(Type value) + : value(std::move(value)) + {} + + Accessor accessor() { + return Accessor(this->mutex, this->value); + } + + /** + * Don't use this unless you already hold a raw (not managed by an Accessor) lock to the contained value. + * + * This should only be used in instances where you need to hold a raw lock, like in the `stop_waiting` + * predicate function for a call to std::condition_variable::wait(). + * + * In all other instances, you should use Synchronised::accessor(). + * + * @return + */ + Type& unsafeReference() { + return this->value; + } + + std::unique_lock lock() { + return std::unique_lock(this->mutex); + } + +private: + Type value; + std::mutex mutex; +}; diff --git a/src/Helpers/Thread.hpp b/src/Helpers/Thread.hpp index 24241753..da0fe90a 100644 --- a/src/Helpers/Thread.hpp +++ b/src/Helpers/Thread.hpp @@ -5,50 +5,47 @@ #include #include -namespace Bloom +enum class ThreadState: std::uint8_t { - enum class ThreadState: std::uint8_t - { - UNINITIALISED, - READY, - STOPPED, - STARTING, - SHUTDOWN_INITIATED, - }; + UNINITIALISED, + READY, + STOPPED, + STARTING, + SHUTDOWN_INITIATED, +}; - class Thread - { - public: - Thread() = default; - virtual ~Thread() = default; +class Thread +{ +public: + Thread() = default; + virtual ~Thread() = default; - Thread(const Thread& other) = delete; - Thread(Thread&& other) = delete; + Thread(const Thread& other) = delete; + Thread(Thread&& other) = delete; - Thread& operator = (const Thread& other) = delete; - Thread& operator = (Thread&& other) = delete; + Thread& operator = (const Thread& other) = delete; + Thread& operator = (Thread&& other) = delete; - ThreadState getThreadState() { - return this->threadState; - } + ThreadState getThreadState() { + return this->threadState; + } - protected: - std::atomic threadState = ThreadState::UNINITIALISED; +protected: + std::atomic threadState = ThreadState::UNINITIALISED; - /** - * Disables signal interrupts on current thread. - */ - static void blockAllSignals() { - sigset_t set = {}; - sigfillset(&set); - sigprocmask(SIG_SETMASK, &set, NULL); - } + /** + * Disables signal interrupts on current thread. + */ + static void blockAllSignals() { + sigset_t set = {}; + sigfillset(&set); + sigprocmask(SIG_SETMASK, &set, NULL); + } - void setName(const std::string& name) { - // POSIX thread names cannot exceed 16 characters, including the terminating null byte. - assert(name.size() <= 15); + void setName(const std::string& name) { + // POSIX thread names cannot exceed 16 characters, including the terminating null byte. + assert(name.size() <= 15); - pthread_setname_np(pthread_self(), name.c_str()); - } - }; -} + pthread_setname_np(pthread_self(), name.c_str()); + } +}; diff --git a/src/Helpers/YamlUtilities.hpp b/src/Helpers/YamlUtilities.hpp index 01dd414e..f771c268 100644 --- a/src/Helpers/YamlUtilities.hpp +++ b/src/Helpers/YamlUtilities.hpp @@ -2,20 +2,17 @@ #include -namespace Bloom +class YamlUtilities { - class YamlUtilities - { - public: - template - static bool isCastable(const YAML::Node& node) { - try { - node.as(); - return true; +public: + template + static bool isCastable(const YAML::Node& node) { + try { + node.as(); + return true; - } catch (YAML::BadConversion&) { - return false; - } + } catch (YAML::BadConversion&) { + return false; } - }; -} + } +}; diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index d5a32a3f..43499f54 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -14,271 +14,268 @@ #include "InsightWorker/Tasks/GetTargetState.hpp" #include "InsightWorker/Tasks/GetTargetDescriptor.hpp" -namespace Bloom +using namespace Exceptions; +using Targets::TargetState; + +Insight::Insight( + EventListener& eventListener, + const ProjectConfig& projectConfig, + const EnvironmentConfig& environmentConfig, + const InsightConfig& insightConfig, + InsightProjectSettings& insightProjectSettings, + QApplication* parent +) + : QObject(parent) + , eventListener(eventListener) + , projectConfig(projectConfig) + , environmentConfig(environmentConfig) + , insightConfig(insightConfig) + , insightProjectSettings(insightProjectSettings) { - using namespace Bloom::Exceptions; - using Bloom::Targets::TargetState; + Logger::info("Starting Insight"); - Insight::Insight( - EventListener& eventListener, - const ProjectConfig& projectConfig, - const EnvironmentConfig& environmentConfig, - const InsightConfig& insightConfig, - InsightProjectSettings& insightProjectSettings, - QApplication* parent - ) - : QObject(parent) - , eventListener(eventListener) - , projectConfig(projectConfig) - , environmentConfig(environmentConfig) - , insightConfig(insightConfig) - , insightProjectSettings(insightProjectSettings) - { - Logger::info("Starting Insight"); + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetStoppedEvent, this, std::placeholders::_1) + ); - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onTargetStoppedEvent, this, std::placeholders::_1) + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetResumedEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetResetEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetRegistersWrittenEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetMemoryWrittenEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onProgrammingModeEnabledEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onProgrammingModeDisabledEvent, this, std::placeholders::_1) + ); + + QApplication::setQuitOnLastWindowClosed(false); + QApplication::setStyle(new BloomProxyStyle()); + + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType>(); + + // Load Ubuntu fonts + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-B.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-BI.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-C.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-L.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-LI.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-M.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-MI.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-B.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-BI.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-R.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-RI.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-R.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-RI.ttf") + ); + QFontDatabase::addApplicationFont( + QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-Th.ttf") + ); + + auto globalStylesheet = QFile( + QString::fromStdString( + Services::PathService::compiledResourcesPath() + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/Global.qss" + ) + ); + + if (!globalStylesheet.open(QFile::ReadOnly)) { + throw Exception("Failed to open global stylesheet file"); + } + + this->globalStylesheet = globalStylesheet.readAll(); + + // Construct and start worker threads + for (std::uint8_t i = 0; i < Insight::INSIGHT_WORKER_COUNT; ++i) { + auto* insightWorker = new InsightWorker(); + auto* workerThread = new QThread(); + + workerThread->setObjectName("IW" + QString::number(insightWorker->id)); + insightWorker->moveToThread(workerThread); + QObject::connect(workerThread, &QThread::started, insightWorker, &InsightWorker::startup); + QObject::connect(workerThread, &QThread::finished, insightWorker, &QObject::deleteLater); + QObject::connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater); + + this->insightWorkersById[insightWorker->id] = std::pair(insightWorker, workerThread); + + Logger::debug("Starting InsightWorker" + std::to_string(insightWorker->id)); + workerThread->start(); + } + + this->activateMainWindow(); +} + +void Insight::activateMainWindow() { + if (this->mainWindow == nullptr) { + this->mainWindow = new InsightWindow( + this->environmentConfig, + this->insightConfig, + this->insightProjectSettings, + this->targetDescriptor ); - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onTargetResumedEvent, this, std::placeholders::_1) - ); + this->mainWindow->setStyleSheet(this->globalStylesheet); - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onTargetResetEvent, this, std::placeholders::_1) - ); + QObject::connect(this->mainWindow, &QObject::destroyed, this, &Insight::onInsightWindowDestroyed); - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onTargetRegistersWrittenEvent, this, std::placeholders::_1) - ); + this->refreshTargetState(); + } - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onTargetMemoryWrittenEvent, this, std::placeholders::_1) - ); + this->mainWindow->show(); + this->mainWindow->activateWindow(); +} - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onProgrammingModeEnabledEvent, this, std::placeholders::_1) - ); +void Insight::shutdown() { + Logger::info("Shutting down Insight"); - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onProgrammingModeDisabledEvent, this, std::placeholders::_1) - ); + if (this->mainWindow != nullptr) { + this->mainWindow->close(); + } - QApplication::setQuitOnLastWindowClosed(false); - QApplication::setStyle(new BloomProxyStyle()); + for (auto& [workerId, workerPair] : this->insightWorkersById) { + auto* workerThread = workerPair.second; - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType>(); - - // Load Ubuntu fonts - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-B.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-BI.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-C.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-L.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-LI.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-M.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-MI.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-B.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-BI.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-R.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/UbuntuMono-RI.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-R.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-RI.ttf") - ); - QFontDatabase::addApplicationFont( - QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-Th.ttf") - ); - - auto globalStylesheet = QFile( - QString::fromStdString( - Services::PathService::compiledResourcesPath() + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/Global.qss" - ) - ); - - if (!globalStylesheet.open(QFile::ReadOnly)) { - throw Exception("Failed to open global stylesheet file"); + if (workerThread != nullptr && workerThread->isRunning()) { + Logger::debug("Stopping InsightWorker" + std::to_string(workerId)); + workerThread->quit(); + Logger::debug("Waiting for InsightWorker" + std::to_string(workerId) + " to stop"); + workerThread->wait(); } - - this->globalStylesheet = globalStylesheet.readAll(); - - // Construct and start worker threads - for (std::uint8_t i = 0; i < Insight::INSIGHT_WORKER_COUNT; ++i) { - auto* insightWorker = new InsightWorker(); - auto* workerThread = new QThread(); - - workerThread->setObjectName("IW" + QString::number(insightWorker->id)); - insightWorker->moveToThread(workerThread); - QObject::connect(workerThread, &QThread::started, insightWorker, &InsightWorker::startup); - QObject::connect(workerThread, &QThread::finished, insightWorker, &QObject::deleteLater); - QObject::connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater); - - this->insightWorkersById[insightWorker->id] = std::pair(insightWorker, workerThread); - - Logger::debug("Starting InsightWorker" + std::to_string(insightWorker->id)); - workerThread->start(); - } - - this->activateMainWindow(); - } - - void Insight::activateMainWindow() { - if (this->mainWindow == nullptr) { - this->mainWindow = new InsightWindow( - this->environmentConfig, - this->insightConfig, - this->insightProjectSettings, - this->targetDescriptor - ); - - this->mainWindow->setStyleSheet(this->globalStylesheet); - - QObject::connect(this->mainWindow, &QObject::destroyed, this, &Insight::onInsightWindowDestroyed); - - this->refreshTargetState(); - } - - this->mainWindow->show(); - this->mainWindow->activateWindow(); - } - - void Insight::shutdown() { - Logger::info("Shutting down Insight"); - - if (this->mainWindow != nullptr) { - this->mainWindow->close(); - } - - for (auto& [workerId, workerPair] : this->insightWorkersById) { - auto* workerThread = workerPair.second; - - if (workerThread != nullptr && workerThread->isRunning()) { - Logger::debug("Stopping InsightWorker" + std::to_string(workerId)); - workerThread->quit(); - Logger::debug("Waiting for InsightWorker" + std::to_string(workerId) + " to stop"); - workerThread->wait(); - } - } - } - - void Insight::refreshTargetState() { - const auto getTargetStateTask = QSharedPointer(new GetTargetState(), &QObject::deleteLater); - QObject::connect( - getTargetStateTask.get(), - &GetTargetState::targetState, - this, - [this] (Targets::TargetState targetState) { - this->lastTargetState = targetState; - emit this->insightSignals->targetStateUpdated(this->lastTargetState); - } - ); - - InsightWorker::queueTask(getTargetStateTask); - } - - void Insight::onInsightWindowDestroyed() { - this->mainWindow = nullptr; - EventManager::triggerEvent(std::make_shared()); - } - - void Insight::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) { - if (this->lastTargetState == TargetState::STOPPED) { - return; - } - - this->lastTargetState = TargetState::STOPPED; - - if (this->targetStepping) { - if (this->targetResumeTimer == nullptr) { - this->targetResumeTimer = new QTimer(this); - this->targetResumeTimer->setSingleShot(true); - - this->targetResumeTimer->callOnTimeout(this, [this] { - if (this->lastTargetState != TargetState::STOPPED) { - return; - } - - emit this->insightSignals->targetStateUpdated(TargetState::STOPPED); - }); - } - - this->targetResumeTimer->start(1500); - return; - } - - if (this->targetResumeTimer != nullptr && this->targetResumeTimer->isActive()) { - this->targetResumeTimer->stop(); - } - - emit this->insightSignals->targetStateUpdated(TargetState::STOPPED); - } - - void Insight::onTargetResumedEvent(const Events::TargetExecutionResumed& event) { - this->targetStepping = event.stepping; - - if (this->lastTargetState != TargetState::RUNNING) { - this->lastTargetState = TargetState::RUNNING; - emit this->insightSignals->targetStateUpdated(TargetState::RUNNING); - } - } - - void Insight::onTargetResetEvent(const Events::TargetReset& event) { - try { - if (this->lastTargetState != TargetState::STOPPED) { - this->lastTargetState = TargetState::STOPPED; - emit this->insightSignals->targetStateUpdated(TargetState::STOPPED); - } - - emit this->insightSignals->targetReset(); - - } catch (const Exceptions::Exception& exception) { - Logger::debug("Error handling TargetReset event - " + exception.getMessage()); - } - } - - void Insight::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) { - emit this->insightSignals->targetRegistersWritten(event.registers, event.createdTimestamp); - } - - void Insight::onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& event) { - emit this->insightSignals->targetMemoryWritten( - event.memoryType, - Targets::TargetMemoryAddressRange(event.startAddress, event.startAddress + (event.size - 1)) - ); - } - - void Insight::onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event) { - emit this->insightSignals->programmingModeEnabled(); - } - - void Insight::onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event) { - emit this->insightSignals->programmingModeDisabled(); } } + +void Insight::refreshTargetState() { + const auto getTargetStateTask = QSharedPointer(new GetTargetState(), &QObject::deleteLater); + QObject::connect( + getTargetStateTask.get(), + &GetTargetState::targetState, + this, + [this] (Targets::TargetState targetState) { + this->lastTargetState = targetState; + emit this->insightSignals->targetStateUpdated(this->lastTargetState); + } + ); + + InsightWorker::queueTask(getTargetStateTask); +} + +void Insight::onInsightWindowDestroyed() { + this->mainWindow = nullptr; + EventManager::triggerEvent(std::make_shared()); +} + +void Insight::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) { + if (this->lastTargetState == TargetState::STOPPED) { + return; + } + + this->lastTargetState = TargetState::STOPPED; + + if (this->targetStepping) { + if (this->targetResumeTimer == nullptr) { + this->targetResumeTimer = new QTimer(this); + this->targetResumeTimer->setSingleShot(true); + + this->targetResumeTimer->callOnTimeout(this, [this] { + if (this->lastTargetState != TargetState::STOPPED) { + return; + } + + emit this->insightSignals->targetStateUpdated(TargetState::STOPPED); + }); + } + + this->targetResumeTimer->start(1500); + return; + } + + if (this->targetResumeTimer != nullptr && this->targetResumeTimer->isActive()) { + this->targetResumeTimer->stop(); + } + + emit this->insightSignals->targetStateUpdated(TargetState::STOPPED); +} + +void Insight::onTargetResumedEvent(const Events::TargetExecutionResumed& event) { + this->targetStepping = event.stepping; + + if (this->lastTargetState != TargetState::RUNNING) { + this->lastTargetState = TargetState::RUNNING; + emit this->insightSignals->targetStateUpdated(TargetState::RUNNING); + } +} + +void Insight::onTargetResetEvent(const Events::TargetReset& event) { + try { + if (this->lastTargetState != TargetState::STOPPED) { + this->lastTargetState = TargetState::STOPPED; + emit this->insightSignals->targetStateUpdated(TargetState::STOPPED); + } + + emit this->insightSignals->targetReset(); + + } catch (const Exceptions::Exception& exception) { + Logger::debug("Error handling TargetReset event - " + exception.getMessage()); + } +} + +void Insight::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) { + emit this->insightSignals->targetRegistersWritten(event.registers, event.createdTimestamp); +} + +void Insight::onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& event) { + emit this->insightSignals->targetMemoryWritten( + event.memoryType, + Targets::TargetMemoryAddressRange(event.startAddress, event.startAddress + (event.size - 1)) + ); +} + +void Insight::onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event) { + emit this->insightSignals->programmingModeEnabled(); +} + +void Insight::onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event) { + emit this->insightSignals->programmingModeDisabled(); +} diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index 01b49b38..cd3455bd 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -24,81 +24,78 @@ #include "InsightWorker/InsightWorker.hpp" #include "UserInterfaces/InsightWindow/InsightWindow.hpp" -namespace Bloom +/** + * The Insight component provides a GUI for insight into the target's GPIO state. + * Insight relies heavily on the Qt framework - it's practically a small Qt application. Each supported target + * package variant implements a custom Qt widget that presents the user with the current state of the target's GPIO + * pins, as well as the ability to manipulate the pin states of output pins by clicking on them. + * + * The Insight component occupies the Bloom's main thread. See Application::run() for more. + */ +class Insight: public QObject { + Q_OBJECT + +public: /** - * The Insight component provides a GUI for insight into the target's GPIO state. - * Insight relies heavily on the Qt framework - it's practically a small Qt application. Each supported target - * package variant implements a custom Qt widget that presents the user with the current state of the target's GPIO - * pins, as well as the ability to manipulate the pin states of output pins by clicking on them. + * Insight constructor. * - * The Insight component occupies the Bloom's main thread. See Application::run() for more. + * Note: We use the comma operator in the application() initializer to set the Qt::AA_ShareOpenGLContexts + * attribute, as this is required by Qt before creating a QCoreApplication instance. + * + * @param eventManager */ - class Insight: public QObject - { - Q_OBJECT + explicit Insight( + EventListener& eventListener, + const ProjectConfig& projectConfig, + const EnvironmentConfig& environmentConfig, + const InsightConfig& insightConfig, + InsightProjectSettings& insightProjectSettings, + QApplication* parent + ); - public: - /** - * Insight constructor. - * - * Note: We use the comma operator in the application() initializer to set the Qt::AA_ShareOpenGLContexts - * attribute, as this is required by Qt before creating a QCoreApplication instance. - * - * @param eventManager - */ - explicit Insight( - EventListener& eventListener, - const ProjectConfig& projectConfig, - const EnvironmentConfig& environmentConfig, - const InsightConfig& insightConfig, - InsightProjectSettings& insightProjectSettings, - QApplication* parent - ); + /** + * Opens main window and obtains focus. + */ + void activateMainWindow(); - /** - * Opens main window and obtains focus. - */ - void activateMainWindow(); + /** + * Shuts down Insight. Called when the user closes the Insight window or a ShutdownApplication event is fired. + */ + void shutdown(); - /** - * Shuts down Insight. Called when the user closes the Insight window or a ShutdownApplication event is fired. - */ - void shutdown(); +private: + static constexpr std::uint8_t INSIGHT_WORKER_COUNT = 3; - private: - static constexpr std::uint8_t INSIGHT_WORKER_COUNT = 3; + ProjectConfig projectConfig; + EnvironmentConfig environmentConfig; + InsightConfig insightConfig; - ProjectConfig projectConfig; - EnvironmentConfig environmentConfig; - InsightConfig insightConfig; + InsightProjectSettings& insightProjectSettings; - InsightProjectSettings& insightProjectSettings; + EventListener& eventListener; + Services::TargetControllerService targetControllerService = Services::TargetControllerService(); - EventListener& eventListener; - Services::TargetControllerService targetControllerService = Services::TargetControllerService(); + Targets::TargetDescriptor targetDescriptor = this->targetControllerService.getTargetDescriptor(); - Targets::TargetDescriptor targetDescriptor = this->targetControllerService.getTargetDescriptor(); + QString globalStylesheet; - QString globalStylesheet; + std::map> insightWorkersById; + InsightWindow* mainWindow = nullptr; - std::map> insightWorkersById; - InsightWindow* mainWindow = nullptr; + Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN; + bool targetStepping = false; + QTimer* targetResumeTimer = nullptr; - Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN; - bool targetStepping = false; - QTimer* targetResumeTimer = nullptr; + InsightSignals* insightSignals = InsightSignals::instance(); - InsightSignals* insightSignals = InsightSignals::instance(); - - void refreshTargetState(); - void onInsightWindowDestroyed(); - void onTargetStoppedEvent(const Events::TargetExecutionStopped& event); - void onTargetResumedEvent(const Events::TargetExecutionResumed& event); - void onTargetResetEvent(const Events::TargetReset& event); - void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event); - void onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& event); - void onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event); - void onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event); - }; -} + void refreshTargetState(); + void onInsightWindowDestroyed(); + void onTargetStoppedEvent(const Events::TargetExecutionStopped& event); + void onTargetResumedEvent(const Events::TargetExecutionResumed& event); + void onTargetResetEvent(const Events::TargetReset& event); + void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event); + void onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& event); + void onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event); + void onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event); +}; diff --git a/src/Insight/InsightSignals.hpp b/src/Insight/InsightSignals.hpp index 95b3ac1c..a97b68f1 100644 --- a/src/Insight/InsightSignals.hpp +++ b/src/Insight/InsightSignals.hpp @@ -10,37 +10,34 @@ #include "InsightWorker/Tasks/InsightWorkerTask.hpp" -namespace Bloom +/** + * Singleton class providing global signals to all Insight widgets that require them. The signals are emitted via + * the Insight class and InsightWorkerTasks. + */ +class InsightSignals: public QObject { - /** - * Singleton class providing global signals to all Insight widgets that require them. The signals are emitted via - * the Insight class and InsightWorkerTasks. - */ - class InsightSignals: public QObject - { - Q_OBJECT + Q_OBJECT - public: - static InsightSignals* instance() { - static auto instance = InsightSignals(); - return &instance; - } +public: + static InsightSignals* instance() { + static auto instance = InsightSignals(); + return &instance; + } - InsightSignals(const InsightSignals&) = delete; - void operator = (const InsightSignals&) = delete; + InsightSignals(const InsightSignals&) = delete; + void operator = (const InsightSignals&) = delete; - signals: - void taskQueued(QSharedPointer task); - void taskProcessed(QSharedPointer task); +signals: + void taskQueued(QSharedPointer task); + void taskProcessed(QSharedPointer task); - void targetStateUpdated(Bloom::Targets::TargetState newState); - void targetReset(); - void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp); - void targetMemoryWritten(Bloom::Targets::TargetMemoryType memoryType, Targets::TargetMemoryAddressRange addressRange); - void programmingModeEnabled(); - void programmingModeDisabled(); + void targetStateUpdated(Targets::TargetState newState); + void targetReset(); + void targetRegistersWritten(const Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp); + void targetMemoryWritten(Targets::TargetMemoryType memoryType, Targets::TargetMemoryAddressRange addressRange); + void programmingModeEnabled(); + void programmingModeDisabled(); - private: - InsightSignals() = default; - }; -} +private: + InsightSignals() = default; +}; diff --git a/src/Insight/InsightWorker/InsightWorker.cpp b/src/Insight/InsightWorker/InsightWorker.cpp index 596e32d3..6913c71c 100644 --- a/src/Insight/InsightWorker/InsightWorker.cpp +++ b/src/Insight/InsightWorker/InsightWorker.cpp @@ -5,88 +5,85 @@ #include "src/Insight/InsightSignals.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom -{ - using namespace Bloom::Exceptions; +using namespace Exceptions; - using Bloom::Targets::TargetState; +using Targets::TargetState; - void InsightWorker::startup() { - auto* insightSignals = InsightSignals::instance(); +void InsightWorker::startup() { + auto* insightSignals = InsightSignals::instance(); - QObject::connect( - insightSignals, - &InsightSignals::taskQueued, - this, - &InsightWorker::executeTasks, - Qt::ConnectionType::QueuedConnection - ); - QObject::connect( - insightSignals, - &InsightSignals::taskProcessed, - this, - &InsightWorker::executeTasks, - Qt::ConnectionType::QueuedConnection - ); + QObject::connect( + insightSignals, + &InsightSignals::taskQueued, + this, + &InsightWorker::executeTasks, + Qt::ConnectionType::QueuedConnection + ); + QObject::connect( + insightSignals, + &InsightSignals::taskProcessed, + this, + &InsightWorker::executeTasks, + Qt::ConnectionType::QueuedConnection + ); - Logger::debug("InsightWorker" + std::to_string(this->id) + " ready"); - emit this->ready(); - } + Logger::debug("InsightWorker" + std::to_string(this->id) + " ready"); + emit this->ready(); +} - void InsightWorker::queueTask(const QSharedPointer& task) { - task->moveToThread(nullptr); +void InsightWorker::queueTask(const QSharedPointer& task) { + task->moveToThread(nullptr); - InsightWorker::queuedTasksById.accessor()->emplace(task->id, task); + InsightWorker::queuedTasksById.accessor()->emplace(task->id, task); - emit InsightSignals::instance()->taskQueued(task); - } + emit InsightSignals::instance()->taskQueued(task); +} - void InsightWorker::executeTasks() { - static const auto getQueuedTask = [] () -> std::optional> { - auto queuedTasks = InsightWorker::queuedTasksById.accessor(); +void InsightWorker::executeTasks() { + static const auto getQueuedTask = [] () -> std::optional> { + auto queuedTasks = InsightWorker::queuedTasksById.accessor(); - if (!queuedTasks->empty()) { - auto taskGroupsInExecution = InsightWorker::taskGroupsInExecution.accessor(); + if (!queuedTasks->empty()) { + auto taskGroupsInExecution = InsightWorker::taskGroupsInExecution.accessor(); - const auto canExecuteTask = [&taskGroupsInExecution] (const QSharedPointer& task) { - for (const auto taskGroup : task->taskGroups()) { - if (taskGroupsInExecution->contains(taskGroup)) { - return false; - } - } - - return true; - }; - - for (auto [queuedTaskId, task] : *queuedTasks) { - if (canExecuteTask(task)) { - const auto taskGroups = task->taskGroups(); - taskGroupsInExecution->insert(taskGroups.begin(), taskGroups.end()); - queuedTasks->erase(queuedTaskId); - return task; + const auto canExecuteTask = [&taskGroupsInExecution] (const QSharedPointer& task) { + for (const auto taskGroup : task->taskGroups()) { + if (taskGroupsInExecution->contains(taskGroup)) { + return false; } } - } - return std::nullopt; - }; + return true; + }; - auto queuedTask = std::optional>(); - - while ((queuedTask = getQueuedTask())) { - auto& task = *queuedTask; - task->moveToThread(this->thread()); - task->execute(this->targetControllerService); - - { - auto taskGroupsInExecution = InsightWorker::taskGroupsInExecution.accessor(); - - for (const auto& taskGroup : task->taskGroups()) { - taskGroupsInExecution->erase(taskGroup); + for (auto [queuedTaskId, task] : *queuedTasks) { + if (canExecuteTask(task)) { + const auto taskGroups = task->taskGroups(); + taskGroupsInExecution->insert(taskGroups.begin(), taskGroups.end()); + queuedTasks->erase(queuedTaskId); + return task; } } - - emit InsightSignals::instance()->taskProcessed(task); } + + return std::nullopt; + }; + + auto queuedTask = std::optional>(); + + while ((queuedTask = getQueuedTask())) { + auto& task = *queuedTask; + task->moveToThread(this->thread()); + task->execute(this->targetControllerService); + + { + auto taskGroupsInExecution = InsightWorker::taskGroupsInExecution.accessor(); + + for (const auto& taskGroup : task->taskGroups()) { + taskGroupsInExecution->erase(taskGroup); + } + } + + emit InsightSignals::instance()->taskProcessed(task); } } diff --git a/src/Insight/InsightWorker/InsightWorker.hpp b/src/Insight/InsightWorker/InsightWorker.hpp index 43e2df7b..9bd846c0 100644 --- a/src/Insight/InsightWorker/InsightWorker.hpp +++ b/src/Insight/InsightWorker/InsightWorker.hpp @@ -12,35 +12,32 @@ #include "src/Helpers/Synchronised.hpp" #include "src/Services/TargetControllerService.hpp" -namespace Bloom +static_assert(std::atomic::is_always_lock_free); + +/** + * The InsightWorker runs on a separate thread to the main GUI thread. Its purpose is to handle any + * blocking/time-expensive operations. + */ +class InsightWorker: public QObject { - static_assert(std::atomic::is_always_lock_free); + Q_OBJECT - /** - * The InsightWorker runs on a separate thread to the main GUI thread. Its purpose is to handle any - * blocking/time-expensive operations. - */ - class InsightWorker: public QObject - { - Q_OBJECT +public: + const std::uint8_t id = ++(InsightWorker::lastWorkerId); - public: - const std::uint8_t id = ++(InsightWorker::lastWorkerId); + InsightWorker() = default; + void startup(); + static void queueTask(const QSharedPointer& task); - InsightWorker() = default; - void startup(); - static void queueTask(const QSharedPointer& task); +signals: + void ready(); - signals: - void ready(); +private: + static inline std::atomic lastWorkerId = 0; + static inline Synchronised>> queuedTasksById = {}; + static inline Synchronised taskGroupsInExecution = {}; - private: - static inline std::atomic lastWorkerId = 0; - static inline Synchronised>> queuedTasksById = {}; - static inline Synchronised taskGroupsInExecution = {}; + Services::TargetControllerService targetControllerService = Services::TargetControllerService(); - Services::TargetControllerService targetControllerService = Services::TargetControllerService(); - - void executeTasks(); - }; -} + void executeTasks(); +}; diff --git a/src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.cpp b/src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.cpp index 815b1bb4..926eb87f 100644 --- a/src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.cpp +++ b/src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.cpp @@ -8,104 +8,101 @@ #include "src/Helpers/EnumToStringMappings.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - CaptureMemorySnapshot::CaptureMemorySnapshot( - const QString& name, - const QString& description, - Targets::TargetMemoryType memoryType, - const std::vector& focusedRegions, - const std::vector& excludedRegions, - const std::optional& data - ) - : name(name) - , description(description) - , memoryType(memoryType) - , focusedRegions(focusedRegions) - , excludedRegions(excludedRegions) - , data(data) - {} +CaptureMemorySnapshot::CaptureMemorySnapshot( + const QString& name, + const QString& description, + Targets::TargetMemoryType memoryType, + const std::vector& focusedRegions, + const std::vector& excludedRegions, + const std::optional& data +) + : name(name) + , description(description) + , memoryType(memoryType) + , focusedRegions(focusedRegions) + , excludedRegions(excludedRegions) + , data(data) +{} - void CaptureMemorySnapshot::run(TargetControllerService& targetControllerService) { - using Targets::TargetMemorySize; +void CaptureMemorySnapshot::run(TargetControllerService& targetControllerService) { + using Targets::TargetMemorySize; - Logger::info("Capturing snapshot"); + Logger::info("Capturing snapshot"); - const auto& targetDescriptor = targetControllerService.getTargetDescriptor(); - const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType); + const auto& targetDescriptor = targetControllerService.getTargetDescriptor(); + const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType); - if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) { - throw Exceptions::Exception("Invalid memory type"); - } + if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) { + throw Exceptions::Exception("Invalid memory type"); + } - const auto& memoryDescriptor = memoryDescriptorIt->second; - const auto memorySize = memoryDescriptor.size(); + const auto& memoryDescriptor = memoryDescriptorIt->second; + const auto memorySize = memoryDescriptor.size(); - if (!this->data.has_value()) { - Logger::info("Reading data for snapshot capture"); + if (!this->data.has_value()) { + Logger::info("Reading data for snapshot capture"); - this->data = Targets::TargetMemoryBuffer(); - this->data->reserve(memorySize); + this->data = Targets::TargetMemoryBuffer(); + this->data->reserve(memorySize); - const auto readSize = std::max( - TargetMemorySize(256), - memoryDescriptor.pageSize.value_or(TargetMemorySize(0)) - ); - const auto readsRequired = static_cast( - std::ceil(static_cast(memorySize) / static_cast(readSize)) - ); - - for (std::uint32_t i = 0; i < readsRequired; i++) { - auto dataSegment = targetControllerService.readMemory( - this->memoryType, - memoryDescriptor.addressRange.startAddress + static_cast(readSize * i), - (memorySize - this->data->size()) >= readSize - ? readSize - : static_cast(memorySize - this->data->size()), - {} - ); - - std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(*this->data)); - this->setProgressPercentage(static_cast( - (static_cast(i) + 1) / (static_cast(readsRequired + 1) / 100) - )); - } - } - - assert(this->data->size() == memorySize); - - auto snapshot = MemorySnapshot( - std::move(this->name), - std::move(this->description), - this->memoryType, - std::move(*this->data), - targetControllerService.getProgramCounter(), - targetControllerService.getStackPointer(), - std::move(this->focusedRegions), - std::move(this->excludedRegions) + const auto readSize = std::max( + TargetMemorySize(256), + memoryDescriptor.pageSize.value_or(TargetMemorySize(0)) + ); + const auto readsRequired = static_cast( + std::ceil(static_cast(memorySize) / static_cast(readSize)) ); - const auto snapshotDirPath = QString::fromStdString(Services::PathService::projectSettingsDirPath()) - + "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(snapshot.memoryType); + for (std::uint32_t i = 0; i < readsRequired; i++) { + auto dataSegment = targetControllerService.readMemory( + this->memoryType, + memoryDescriptor.addressRange.startAddress + static_cast(readSize * i), + (memorySize - this->data->size()) >= readSize + ? readSize + : static_cast(memorySize - this->data->size()), + {} + ); - QDir().mkpath(snapshotDirPath); - - const auto snapshotFilePath = snapshotDirPath + "/" + snapshot.id + ".json"; - - auto outputFile = QFile(snapshotFilePath); - - if (!outputFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) { - Logger::error("Failed to save snapshot - cannot open " + snapshotFilePath.toStdString()); - return; + std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(*this->data)); + this->setProgressPercentage(static_cast( + (static_cast(i) + 1) / (static_cast(readsRequired + 1) / 100) + )); } - - outputFile.write(QJsonDocument(snapshot.toJson()).toJson(QJsonDocument::JsonFormat::Compact)); - outputFile.close(); - - Logger::info("Snapshot captured - UUID: " + snapshot.id.toStdString()); - - emit this->memorySnapshotCaptured(std::move(snapshot)); } + + assert(this->data->size() == memorySize); + + auto snapshot = MemorySnapshot( + std::move(this->name), + std::move(this->description), + this->memoryType, + std::move(*this->data), + targetControllerService.getProgramCounter(), + targetControllerService.getStackPointer(), + std::move(this->focusedRegions), + std::move(this->excludedRegions) + ); + + const auto snapshotDirPath = QString::fromStdString(Services::PathService::projectSettingsDirPath()) + + "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(snapshot.memoryType); + + QDir().mkpath(snapshotDirPath); + + const auto snapshotFilePath = snapshotDirPath + "/" + snapshot.id + ".json"; + + auto outputFile = QFile(snapshotFilePath); + + if (!outputFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) { + Logger::error("Failed to save snapshot - cannot open " + snapshotFilePath.toStdString()); + return; + } + + outputFile.write(QJsonDocument(snapshot.toJson()).toJson(QJsonDocument::JsonFormat::Compact)); + outputFile.close(); + + Logger::info("Snapshot captured - UUID: " + snapshot.id.toStdString()); + + emit this->memorySnapshotCaptured(std::move(snapshot)); } diff --git a/src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.hpp b/src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.hpp index 64b6efda..13f43d14 100644 --- a/src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.hpp +++ b/src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.hpp @@ -8,45 +8,42 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp" -namespace Bloom +class CaptureMemorySnapshot: public InsightWorkerTask { - class CaptureMemorySnapshot: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - CaptureMemorySnapshot( - const QString& name, - const QString& description, - Targets::TargetMemoryType memoryType, - const std::vector& focusedRegions, - const std::vector& excludedRegions, - const std::optional& data - ); +public: + CaptureMemorySnapshot( + const QString& name, + const QString& description, + Targets::TargetMemoryType memoryType, + const std::vector& focusedRegions, + const std::vector& excludedRegions, + const std::optional& data + ); - QString brief() const override { - return "Capturing memory snapshot"; - } + QString brief() const override { + return "Capturing memory snapshot"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - signals: - void memorySnapshotCaptured(MemorySnapshot snapshot); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; - - private: - QString name; - QString description; - Targets::TargetMemoryType memoryType; - std::vector focusedRegions; - std::vector excludedRegions; - - std::optional data; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +signals: + void memorySnapshotCaptured(MemorySnapshot snapshot); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; + +private: + QString name; + QString description; + Targets::TargetMemoryType memoryType; + std::vector focusedRegions; + std::vector excludedRegions; + + std::optional data; +}; diff --git a/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp b/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp index 5a308822..889c9339 100644 --- a/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp +++ b/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.cpp @@ -1,25 +1,22 @@ #include "ConstructHexViewerTopLevelGroupItem.hpp" -namespace Bloom -{ - ConstructHexViewerTopLevelGroupItem::ConstructHexViewerTopLevelGroupItem( - const std::vector& focusedMemoryRegions, - const std::vector& excludedMemoryRegions, - const Widgets::HexViewerSharedState& hexViewerState - ) - : focusedMemoryRegions(focusedMemoryRegions) - , excludedMemoryRegions(excludedMemoryRegions) - , hexViewerState(hexViewerState) - {} +ConstructHexViewerTopLevelGroupItem::ConstructHexViewerTopLevelGroupItem( + const std::vector& focusedMemoryRegions, + const std::vector& excludedMemoryRegions, + const Widgets::HexViewerSharedState& hexViewerState +) + : focusedMemoryRegions(focusedMemoryRegions) + , excludedMemoryRegions(excludedMemoryRegions) + , hexViewerState(hexViewerState) +{} - void ConstructHexViewerTopLevelGroupItem::run(Services::TargetControllerService&) { - auto* item = new Widgets::TopLevelGroupItem( - this->focusedMemoryRegions, - this->excludedMemoryRegions, - this->hexViewerState - ); - item->rebuildItemHierarchy(); +void ConstructHexViewerTopLevelGroupItem::run(Services::TargetControllerService&) { + auto* item = new Widgets::TopLevelGroupItem( + this->focusedMemoryRegions, + this->excludedMemoryRegions, + this->hexViewerState + ); + item->rebuildItemHierarchy(); - emit this->topLevelGroupItem(item); - } + emit this->topLevelGroupItem(item); } diff --git a/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp b/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp index 43c083e7..58dc559c 100644 --- a/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp +++ b/src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp @@ -8,36 +8,33 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp" -namespace Bloom +class ConstructHexViewerTopLevelGroupItem: public InsightWorkerTask { - class ConstructHexViewerTopLevelGroupItem: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - ConstructHexViewerTopLevelGroupItem( - const std::vector& focusedMemoryRegions, - const std::vector& excludedMemoryRegions, - const Widgets::HexViewerSharedState& hexViewerState - ); +public: + ConstructHexViewerTopLevelGroupItem( + const std::vector& focusedMemoryRegions, + const std::vector& excludedMemoryRegions, + const Widgets::HexViewerSharedState& hexViewerState + ); - QString brief() const override { - return "Preparing hex viewer"; - } + QString brief() const override { + return "Preparing hex viewer"; + } - TaskGroups taskGroups() const override { - return TaskGroups(); - }; - - signals: - void topLevelGroupItem(Widgets::TopLevelGroupItem* item); - - protected: - void run(Services::TargetControllerService&) override; - - private: - const Widgets::HexViewerSharedState& hexViewerState; - const std::vector& focusedMemoryRegions; - const std::vector& excludedMemoryRegions; + TaskGroups taskGroups() const override { + return TaskGroups(); }; -} + +signals: + void topLevelGroupItem(Widgets::TopLevelGroupItem* item); + +protected: + void run(Services::TargetControllerService&) override; + +private: + const Widgets::HexViewerSharedState& hexViewerState; + const std::vector& focusedMemoryRegions; + const std::vector& excludedMemoryRegions; +}; diff --git a/src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.cpp b/src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.cpp index 753b5c1b..5e248a55 100644 --- a/src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.cpp +++ b/src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.cpp @@ -6,37 +6,34 @@ #include "src/Helpers/EnumToStringMappings.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - DeleteMemorySnapshot::DeleteMemorySnapshot( - const QString& snapshotId, - Targets::TargetMemoryType memoryType - ) - : snapshotId(snapshotId) - , memoryType(memoryType) - {} +DeleteMemorySnapshot::DeleteMemorySnapshot( + const QString& snapshotId, + Targets::TargetMemoryType memoryType +) + : snapshotId(snapshotId) + , memoryType(memoryType) +{} - void DeleteMemorySnapshot::run(TargetControllerService&) { - using Targets::TargetMemorySize; +void DeleteMemorySnapshot::run(TargetControllerService&) { + using Targets::TargetMemorySize; - Logger::info("Deleting snapshot " + this->snapshotId.toStdString()); + Logger::info("Deleting snapshot " + this->snapshotId.toStdString()); - const auto snapshotFilePath = QString::fromStdString(Services::PathService::projectSettingsDirPath()) - + "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(this->memoryType) + "/" - + this->snapshotId + ".json"; + const auto snapshotFilePath = QString::fromStdString(Services::PathService::projectSettingsDirPath()) + + "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(this->memoryType) + "/" + + this->snapshotId + ".json"; - auto snapshotFile = QFile(snapshotFilePath); + auto snapshotFile = QFile(snapshotFilePath); - if (!snapshotFile.exists()) { - Logger::warning( - "Could not find snapshot file for " + this->snapshotId.toStdString() + " - expected path: " - + snapshotFilePath.toStdString() - ); - return; - } - - snapshotFile.remove(); + if (!snapshotFile.exists()) { + Logger::warning( + "Could not find snapshot file for " + this->snapshotId.toStdString() + " - expected path: " + + snapshotFilePath.toStdString() + ); + return; } + + snapshotFile.remove(); } diff --git a/src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.hpp b/src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.hpp index 3dd84ef7..62cb14be 100644 --- a/src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.hpp +++ b/src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.hpp @@ -6,24 +6,21 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom +class DeleteMemorySnapshot: public InsightWorkerTask { - class DeleteMemorySnapshot: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - DeleteMemorySnapshot(const QString& snapshotId, Targets::TargetMemoryType memoryType); +public: + DeleteMemorySnapshot(const QString& snapshotId, Targets::TargetMemoryType memoryType); - QString brief() const override { - return "Deleting memory snapshot " + this->snapshotId; - } + QString brief() const override { + return "Deleting memory snapshot " + this->snapshotId; + } - protected: - void run(Services::TargetControllerService& targetControllerService) override; +protected: + void run(Services::TargetControllerService& targetControllerService) override; - private: - QString snapshotId; - Targets::TargetMemoryType memoryType; - }; -} +private: + QString snapshotId; + Targets::TargetMemoryType memoryType; +}; diff --git a/src/Insight/InsightWorker/Tasks/GetTargetDescriptor.cpp b/src/Insight/InsightWorker/Tasks/GetTargetDescriptor.cpp index 30224dfc..2cb472bc 100644 --- a/src/Insight/InsightWorker/Tasks/GetTargetDescriptor.cpp +++ b/src/Insight/InsightWorker/Tasks/GetTargetDescriptor.cpp @@ -1,10 +1,7 @@ #include "GetTargetDescriptor.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void GetTargetDescriptor::run(TargetControllerService& targetControllerService) { - emit this->targetDescriptor(targetControllerService.getTargetDescriptor()); - } +void GetTargetDescriptor::run(TargetControllerService& targetControllerService) { + emit this->targetDescriptor(targetControllerService.getTargetDescriptor()); } diff --git a/src/Insight/InsightWorker/Tasks/GetTargetDescriptor.hpp b/src/Insight/InsightWorker/Tasks/GetTargetDescriptor.hpp index 5244227a..7364fe2e 100644 --- a/src/Insight/InsightWorker/Tasks/GetTargetDescriptor.hpp +++ b/src/Insight/InsightWorker/Tasks/GetTargetDescriptor.hpp @@ -4,29 +4,26 @@ #include "src/Targets/TargetDescriptor.hpp" -namespace Bloom +class GetTargetDescriptor: public InsightWorkerTask { - class GetTargetDescriptor: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - GetTargetDescriptor() = default; +public: + GetTargetDescriptor() = default; - QString brief() const override { - return "Obtaining target descriptor"; - } + QString brief() const override { + return "Obtaining target descriptor"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - signals: - void targetDescriptor(Targets::TargetDescriptor targetDescriptor); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +signals: + void targetDescriptor(Targets::TargetDescriptor targetDescriptor); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; +}; diff --git a/src/Insight/InsightWorker/Tasks/GetTargetState.cpp b/src/Insight/InsightWorker/Tasks/GetTargetState.cpp index cd874967..1713c6dc 100644 --- a/src/Insight/InsightWorker/Tasks/GetTargetState.cpp +++ b/src/Insight/InsightWorker/Tasks/GetTargetState.cpp @@ -1,10 +1,7 @@ #include "GetTargetState.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void GetTargetState::run(TargetControllerService& targetControllerService) { - emit this->targetState(targetControllerService.getTargetState()); - } +void GetTargetState::run(TargetControllerService& targetControllerService) { + emit this->targetState(targetControllerService.getTargetState()); } diff --git a/src/Insight/InsightWorker/Tasks/GetTargetState.hpp b/src/Insight/InsightWorker/Tasks/GetTargetState.hpp index e7b0ebe6..b56ce07a 100644 --- a/src/Insight/InsightWorker/Tasks/GetTargetState.hpp +++ b/src/Insight/InsightWorker/Tasks/GetTargetState.hpp @@ -4,29 +4,26 @@ #include "src/Targets/TargetState.hpp" -namespace Bloom +class GetTargetState: public InsightWorkerTask { - class GetTargetState: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - GetTargetState() = default; +public: + GetTargetState() = default; - QString brief() const override { - return "Obtaining target state"; - } + QString brief() const override { + return "Obtaining target state"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - signals: - void targetState(Targets::TargetState state); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +signals: + void targetState(Targets::TargetState state); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; +}; diff --git a/src/Insight/InsightWorker/Tasks/InsightWorkerTask.cpp b/src/Insight/InsightWorker/Tasks/InsightWorkerTask.cpp index 45712f95..b913dcc1 100644 --- a/src/Insight/InsightWorker/Tasks/InsightWorkerTask.cpp +++ b/src/Insight/InsightWorker/Tasks/InsightWorkerTask.cpp @@ -2,36 +2,33 @@ #include "src/Logger/Logger.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - InsightWorkerTask::InsightWorkerTask() - : QObject(nullptr) - {} +InsightWorkerTask::InsightWorkerTask() + : QObject(nullptr) +{} - void InsightWorkerTask::execute(TargetControllerService& targetControllerService) { - try { - this->state = InsightWorkerTaskState::STARTED; - emit this->started(); +void InsightWorkerTask::execute(TargetControllerService& targetControllerService) { + try { + this->state = InsightWorkerTaskState::STARTED; + emit this->started(); - this->run(targetControllerService); + this->run(targetControllerService); - this->state = InsightWorkerTaskState::COMPLETED; - this->setProgressPercentage(100); - emit this->completed(); + this->state = InsightWorkerTaskState::COMPLETED; + this->setProgressPercentage(100); + emit this->completed(); - } catch (std::exception& exception) { - this->state = InsightWorkerTaskState::FAILED; - Logger::debug("InsightWorker task failed - " + std::string(exception.what())); - emit this->failed(QString::fromStdString(exception.what())); - } - - emit this->finished(); + } catch (std::exception& exception) { + this->state = InsightWorkerTaskState::FAILED; + Logger::debug("InsightWorker task failed - " + std::string(exception.what())); + emit this->failed(QString::fromStdString(exception.what())); } - void InsightWorkerTask::setProgressPercentage(std::uint8_t percentage) { - this->progressPercentage = percentage; - emit this->progressUpdate(this->progressPercentage); - } + emit this->finished(); +} + +void InsightWorkerTask::setProgressPercentage(std::uint8_t percentage) { + this->progressPercentage = percentage; + emit this->progressUpdate(this->progressPercentage); } diff --git a/src/Insight/InsightWorker/Tasks/InsightWorkerTask.hpp b/src/Insight/InsightWorker/Tasks/InsightWorkerTask.hpp index c24679ae..f4e946c8 100644 --- a/src/Insight/InsightWorker/Tasks/InsightWorkerTask.hpp +++ b/src/Insight/InsightWorker/Tasks/InsightWorkerTask.hpp @@ -8,81 +8,78 @@ #include "TaskGroup.hpp" #include "src/Services/TargetControllerService.hpp" -namespace Bloom +enum class InsightWorkerTaskState: std::uint8_t { - enum class InsightWorkerTaskState: std::uint8_t - { - CREATED, - STARTED, - FAILED, - COMPLETED, + CREATED, + STARTED, + FAILED, + COMPLETED, +}; + +static_assert(std::atomic::is_always_lock_free); +static_assert(std::atomic::is_always_lock_free); + +class InsightWorkerTask: public QObject +{ + Q_OBJECT + +public: + using IdType = std::uint64_t; + const InsightWorkerTask::IdType id = ++(InsightWorkerTask::lastId); + std::atomic state = InsightWorkerTaskState::CREATED; + std::atomic progressPercentage = 0; + + InsightWorkerTask(); + + virtual QString brief() const = 0; + + virtual TaskGroups taskGroups() const { + return TaskGroups(); }; - static_assert(std::atomic::is_always_lock_free); - static_assert(std::atomic::is_always_lock_free); + void execute(Services::TargetControllerService& targetControllerService); - class InsightWorkerTask: public QObject - { - Q_OBJECT +signals: + /** + * The InsightWorkerTask::started() signal will be emitted once the task has started (InsightWorker::run() is + * called) + */ + void started(); - public: - using IdType = std::uint64_t; - const InsightWorkerTask::IdType id = ++(InsightWorkerTask::lastId); - std::atomic state = InsightWorkerTaskState::CREATED; - std::atomic progressPercentage = 0; + /** + * Some tasks will emit an InsightWorkerTask::progressUpdate() signal to provide an update on their progress. + * + * This is used for progress bar widgets. + * + * NOTE: A task doesn't have to emit this signal. Currently, the time-expensive tasks (like ReadTargetMemory) + * emit this signal. + * + * @param progressPercentage + * The task's current progress. + */ + void progressUpdate(std::uint8_t progressPercentage); - InsightWorkerTask(); + /** + * The InsightWorkerTask::completed() signal will be emitted once the task has successfully completed. + */ + void completed(); - virtual QString brief() const = 0; + /** + * The InsightWorkerTask::failed() signal will be emitted when the task fails (InsightWorkerTask::run() throws + * an exception). + */ + void failed(QString errorMessage); - virtual TaskGroups taskGroups() const { - return TaskGroups(); - }; + /** + * The InsightWorkerTask::finished() signal will be emitted at the end of the task, regardless to whether it + * completed successfully or failed. + */ + void finished(); - void execute(Services::TargetControllerService& targetControllerService); +protected: + virtual void run(Services::TargetControllerService& targetControllerService) = 0; + void setProgressPercentage(std::uint8_t percentage); - signals: - /** - * The InsightWorkerTask::started() signal will be emitted once the task has started (InsightWorker::run() is - * called) - */ - void started(); - - /** - * Some tasks will emit an InsightWorkerTask::progressUpdate() signal to provide an update on their progress. - * - * This is used for progress bar widgets. - * - * NOTE: A task doesn't have to emit this signal. Currently, the time-expensive tasks (like ReadTargetMemory) - * emit this signal. - * - * @param progressPercentage - * The task's current progress. - */ - void progressUpdate(std::uint8_t progressPercentage); - - /** - * The InsightWorkerTask::completed() signal will be emitted once the task has successfully completed. - */ - void completed(); - - /** - * The InsightWorkerTask::failed() signal will be emitted when the task fails (InsightWorkerTask::run() throws - * an exception). - */ - void failed(QString errorMessage); - - /** - * The InsightWorkerTask::finished() signal will be emitted at the end of the task, regardless to whether it - * completed successfully or failed. - */ - void finished(); - - protected: - virtual void run(Services::TargetControllerService& targetControllerService) = 0; - void setProgressPercentage(std::uint8_t percentage); - - private: - static inline std::atomic lastId = 0; - }; -} +private: + static inline std::atomic lastId = 0; +}; diff --git a/src/Insight/InsightWorker/Tasks/ReadProgramCounter.cpp b/src/Insight/InsightWorker/Tasks/ReadProgramCounter.cpp index 83a9db5c..7075fa3a 100644 --- a/src/Insight/InsightWorker/Tasks/ReadProgramCounter.cpp +++ b/src/Insight/InsightWorker/Tasks/ReadProgramCounter.cpp @@ -1,10 +1,7 @@ #include "ReadProgramCounter.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void ReadProgramCounter::run(TargetControllerService& targetControllerService) { - emit this->programCounterRead(targetControllerService.getProgramCounter()); - } +void ReadProgramCounter::run(TargetControllerService& targetControllerService) { + emit this->programCounterRead(targetControllerService.getProgramCounter()); } diff --git a/src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp b/src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp index 558b6d85..020ef3f2 100644 --- a/src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp +++ b/src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp @@ -4,29 +4,26 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom +class ReadProgramCounter: public InsightWorkerTask { - class ReadProgramCounter: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - ReadProgramCounter() = default; +public: + ReadProgramCounter() = default; - QString brief() const override { - return "Reading program counter"; - } + QString brief() const override { + return "Reading program counter"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - signals: - void programCounterRead(Targets::TargetProgramCounter programCounter); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +signals: + void programCounterRead(Targets::TargetProgramCounter programCounter); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; +}; diff --git a/src/Insight/InsightWorker/Tasks/ReadStackPointer.cpp b/src/Insight/InsightWorker/Tasks/ReadStackPointer.cpp index d8aeed04..8cc0308d 100644 --- a/src/Insight/InsightWorker/Tasks/ReadStackPointer.cpp +++ b/src/Insight/InsightWorker/Tasks/ReadStackPointer.cpp @@ -1,10 +1,7 @@ #include "ReadStackPointer.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void ReadStackPointer::run(TargetControllerService& targetControllerService) { - emit this->stackPointerRead(targetControllerService.getStackPointer()); - } +void ReadStackPointer::run(TargetControllerService& targetControllerService) { + emit this->stackPointerRead(targetControllerService.getStackPointer()); } diff --git a/src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp b/src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp index fb8cbe16..99fa3ecf 100644 --- a/src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp +++ b/src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp @@ -4,29 +4,26 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom +class ReadStackPointer: public InsightWorkerTask { - class ReadStackPointer: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - ReadStackPointer() = default; +public: + ReadStackPointer() = default; - QString brief() const override { - return "Reading stack pointer"; - } + QString brief() const override { + return "Reading stack pointer"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - signals: - void stackPointerRead(Targets::TargetStackPointer stackPointer); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +signals: + void stackPointerRead(Targets::TargetStackPointer stackPointer); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; +}; diff --git a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.cpp b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.cpp index 70a368dc..9580413b 100644 --- a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.cpp +++ b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.cpp @@ -6,54 +6,51 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void ReadTargetMemory::run(TargetControllerService& targetControllerService) { - using Targets::TargetMemorySize; +void ReadTargetMemory::run(TargetControllerService& targetControllerService) { + using Targets::TargetMemorySize; - const auto& targetDescriptor = targetControllerService.getTargetDescriptor(); - const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType); + const auto& targetDescriptor = targetControllerService.getTargetDescriptor(); + const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType); - if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) { - throw Exceptions::Exception("Invalid memory type"); - } - - const auto& memoryDescriptor = memoryDescriptorIt->second; - - /* - * To prevent locking up the TargetController for too long, we split the read into numerous reads. - * - * This allows the TargetController to service other commands in-between reads, reducing the likelihood of - * command timeouts when we're reading lots of data. - */ - const auto readSize = std::max( - TargetMemorySize(256), - memoryDescriptor.pageSize.value_or(TargetMemorySize(0)) - ); - const auto readsRequired = static_cast( - std::ceil(static_cast(this->size) / static_cast(readSize)) - ); - - Targets::TargetMemoryBuffer data; - - for (std::uint32_t i = 0; i < readsRequired; i++) { - auto dataSegment = targetControllerService.readMemory( - this->memoryType, - this->startAddress + static_cast(readSize * i), - (this->size - data.size()) >= readSize - ? readSize - : static_cast(this->size - data.size()), - this->excludedAddressRanges - ); - - std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(data)); - this->setProgressPercentage(static_cast( - (static_cast(i) + 1) / (static_cast(readsRequired) / 100) - )); - } - - emit this->targetMemoryRead(data); + if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) { + throw Exceptions::Exception("Invalid memory type"); } + + const auto& memoryDescriptor = memoryDescriptorIt->second; + + /* + * To prevent locking up the TargetController for too long, we split the read into numerous reads. + * + * This allows the TargetController to service other commands in-between reads, reducing the likelihood of + * command timeouts when we're reading lots of data. + */ + const auto readSize = std::max( + TargetMemorySize(256), + memoryDescriptor.pageSize.value_or(TargetMemorySize(0)) + ); + const auto readsRequired = static_cast( + std::ceil(static_cast(this->size) / static_cast(readSize)) + ); + + Targets::TargetMemoryBuffer data; + + for (std::uint32_t i = 0; i < readsRequired; i++) { + auto dataSegment = targetControllerService.readMemory( + this->memoryType, + this->startAddress + static_cast(readSize * i), + (this->size - data.size()) >= readSize + ? readSize + : static_cast(this->size - data.size()), + this->excludedAddressRanges + ); + + std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(data)); + this->setProgressPercentage(static_cast( + (static_cast(i) + 1) / (static_cast(readsRequired) / 100) + )); + } + + emit this->targetMemoryRead(data); } diff --git a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp index 7fcc895a..84867474 100644 --- a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp +++ b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp @@ -7,45 +7,42 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Helpers/EnumToStringMappings.hpp" -namespace Bloom +class ReadTargetMemory: public InsightWorkerTask { - class ReadTargetMemory: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - ReadTargetMemory( - Targets::TargetMemoryType memoryType, - Targets::TargetMemoryAddress startAddress, - Targets::TargetMemorySize size, - const std::set& excludedAddressRanges = {} - ) - : memoryType(memoryType) - , startAddress(startAddress) - , size(size) - , excludedAddressRanges(excludedAddressRanges) - {} +public: + ReadTargetMemory( + Targets::TargetMemoryType memoryType, + Targets::TargetMemoryAddress startAddress, + Targets::TargetMemorySize size, + const std::set& excludedAddressRanges = {} + ) + : memoryType(memoryType) + , startAddress(startAddress) + , size(size) + , excludedAddressRanges(excludedAddressRanges) + {} - QString brief() const override { - return "Reading target " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper(); - } + QString brief() const override { + return "Reading target " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper(); + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - signals: - void targetMemoryRead(Targets::TargetMemoryBuffer buffer); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; - - private: - Targets::TargetMemoryType memoryType; - Targets::TargetMemoryAddress startAddress; - Targets::TargetMemorySize size; - std::set excludedAddressRanges; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +signals: + void targetMemoryRead(Targets::TargetMemoryBuffer buffer); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; + +private: + Targets::TargetMemoryType memoryType; + Targets::TargetMemoryAddress startAddress; + Targets::TargetMemorySize size; + std::set excludedAddressRanges; +}; diff --git a/src/Insight/InsightWorker/Tasks/ReadTargetRegisters.cpp b/src/Insight/InsightWorker/Tasks/ReadTargetRegisters.cpp index f2858991..cce5dd2a 100644 --- a/src/Insight/InsightWorker/Tasks/ReadTargetRegisters.cpp +++ b/src/Insight/InsightWorker/Tasks/ReadTargetRegisters.cpp @@ -1,10 +1,7 @@ #include "ReadTargetRegisters.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void ReadTargetRegisters::run(TargetControllerService& targetControllerService) { - emit this->targetRegistersRead(targetControllerService.readRegisters(this->descriptorIds)); - } +void ReadTargetRegisters::run(TargetControllerService& targetControllerService) { + emit this->targetRegistersRead(targetControllerService.readRegisters(this->descriptorIds)); } diff --git a/src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp b/src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp index b84bac69..c1bdb132 100644 --- a/src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp +++ b/src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp @@ -3,34 +3,31 @@ #include "InsightWorkerTask.hpp" #include "src/Targets/TargetRegister.hpp" -namespace Bloom +class ReadTargetRegisters: public InsightWorkerTask { - class ReadTargetRegisters: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - explicit ReadTargetRegisters(const Targets::TargetRegisterDescriptorIds& descriptorIds) - : descriptorIds(descriptorIds) - {} +public: + explicit ReadTargetRegisters(const Targets::TargetRegisterDescriptorIds& descriptorIds) + : descriptorIds(descriptorIds) + {} - QString brief() const override { - return "Reading " + QString::number(this->descriptorIds.size()) + " target register(s)"; - } + QString brief() const override { + return "Reading " + QString::number(this->descriptorIds.size()) + " target register(s)"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - signals: - void targetRegistersRead(Targets::TargetRegisters registers); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; - - private: - Targets::TargetRegisterDescriptorIds descriptorIds; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +signals: + void targetRegistersRead(Targets::TargetRegisters registers); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; + +private: + Targets::TargetRegisterDescriptorIds descriptorIds; +}; diff --git a/src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.cpp b/src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.cpp index f3d00e7f..bfda2bcb 100644 --- a/src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.cpp +++ b/src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.cpp @@ -1,10 +1,7 @@ #include "RefreshTargetPinStates.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void RefreshTargetPinStates::run(TargetControllerService& targetControllerService) { - emit this->targetPinStatesRetrieved(targetControllerService.getPinStates(this->variantId)); - } +void RefreshTargetPinStates::run(TargetControllerService& targetControllerService) { + emit this->targetPinStatesRetrieved(targetControllerService.getPinStates(this->variantId)); } diff --git a/src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.hpp b/src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.hpp index 326de8fa..448eb3b7 100644 --- a/src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.hpp +++ b/src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.hpp @@ -4,34 +4,31 @@ #include "src/Targets/TargetVariant.hpp" #include "src/Targets/TargetPinDescriptor.hpp" -namespace Bloom +class RefreshTargetPinStates: public InsightWorkerTask { - class RefreshTargetPinStates: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - explicit RefreshTargetPinStates(int variantId) - : variantId(variantId) - {} +public: + explicit RefreshTargetPinStates(int variantId) + : variantId(variantId) + {} - QString brief() const override { - return "Reading target pin states"; - } + QString brief() const override { + return "Reading target pin states"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - signals: - void targetPinStatesRetrieved(Bloom::Targets::TargetPinStateMapping pinStatesByNumber); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; - - private: - int variantId; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +signals: + void targetPinStatesRetrieved(Targets::TargetPinStateMapping pinStatesByNumber); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; + +private: + int variantId; +}; diff --git a/src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.cpp b/src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.cpp index 2a4a1e5b..3a9d9522 100644 --- a/src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.cpp +++ b/src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.cpp @@ -10,64 +10,61 @@ #include "src/Exceptions/Exception.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - RetrieveMemorySnapshots::RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType) - : memoryType(memoryType) - {} +RetrieveMemorySnapshots::RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType) + : memoryType(memoryType) +{} - void RetrieveMemorySnapshots::run(TargetControllerService& targetControllerService) { - emit this->memorySnapshotsRetrieved(this->getSnapshots(this->memoryType)); - } - - std::vector RetrieveMemorySnapshots::getSnapshots(Targets::TargetMemoryType memoryType) { - constexpr auto MAX_SNAPSHOTS = 30; - auto snapshotDir = QDir(QString::fromStdString(Services::PathService::projectSettingsDirPath()) - + "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(memoryType)); - - if (!snapshotDir.exists()) { - return {}; - } - - auto snapshots = std::vector(); - - const auto snapshotFileEntries = snapshotDir.entryInfoList( - QStringList("*.json"), - QDir::Files, - QDir::SortFlag::Time - ); - - for (const auto& snapshotFileEntry : snapshotFileEntries) { - auto snapshotFile = QFile(snapshotFileEntry.absoluteFilePath()); - - if (snapshots.size() >= MAX_SNAPSHOTS) { - Logger::warning( - "The total number of " + EnumToStringMappings::targetMemoryTypes.at(memoryType).toUpper().toStdString() - + " snapshots exceeds the hard limit of " + std::to_string(MAX_SNAPSHOTS) - + ". Only the most recent " + std::to_string(MAX_SNAPSHOTS) + " snapshots will be loaded." - ); - break; - } - - try { - if (!snapshotFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - throw Exceptions::Exception("Failed to open snapshot file"); - } - - snapshots.emplace_back(QJsonDocument::fromJson(snapshotFile.readAll()).object()); - - } catch (const Exceptions::Exception& exception) { - Logger::error( - "Failed to load snapshot " + snapshotFileEntry.absoluteFilePath().toStdString() + " - " - + exception.getMessage() - ); - } - - snapshotFile.close(); - } - - return snapshots; - } +void RetrieveMemorySnapshots::run(TargetControllerService& targetControllerService) { + emit this->memorySnapshotsRetrieved(this->getSnapshots(this->memoryType)); +} + +std::vector RetrieveMemorySnapshots::getSnapshots(Targets::TargetMemoryType memoryType) { + constexpr auto MAX_SNAPSHOTS = 30; + auto snapshotDir = QDir(QString::fromStdString(Services::PathService::projectSettingsDirPath()) + + "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(memoryType)); + + if (!snapshotDir.exists()) { + return {}; + } + + auto snapshots = std::vector(); + + const auto snapshotFileEntries = snapshotDir.entryInfoList( + QStringList("*.json"), + QDir::Files, + QDir::SortFlag::Time + ); + + for (const auto& snapshotFileEntry : snapshotFileEntries) { + auto snapshotFile = QFile(snapshotFileEntry.absoluteFilePath()); + + if (snapshots.size() >= MAX_SNAPSHOTS) { + Logger::warning( + "The total number of " + EnumToStringMappings::targetMemoryTypes.at(memoryType).toUpper().toStdString() + + " snapshots exceeds the hard limit of " + std::to_string(MAX_SNAPSHOTS) + + ". Only the most recent " + std::to_string(MAX_SNAPSHOTS) + " snapshots will be loaded." + ); + break; + } + + try { + if (!snapshotFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + throw Exceptions::Exception("Failed to open snapshot file"); + } + + snapshots.emplace_back(QJsonDocument::fromJson(snapshotFile.readAll()).object()); + + } catch (const Exceptions::Exception& exception) { + Logger::error( + "Failed to load snapshot " + snapshotFileEntry.absoluteFilePath().toStdString() + " - " + + exception.getMessage() + ); + } + + snapshotFile.close(); + } + + return snapshots; } diff --git a/src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.hpp b/src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.hpp index ed374346..67e3813d 100644 --- a/src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.hpp +++ b/src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.hpp @@ -8,29 +8,26 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp" #include "src/Helpers/EnumToStringMappings.hpp" -namespace Bloom +class RetrieveMemorySnapshots: public InsightWorkerTask { - class RetrieveMemorySnapshots: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType); +public: + RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType); - QString brief() const override { - return "Loading saved " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper() - + " memory snapshots"; - } + QString brief() const override { + return "Loading saved " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper() + + " memory snapshots"; + } - signals: - void memorySnapshotsRetrieved(std::vector snapshots); +signals: + void memorySnapshotsRetrieved(std::vector snapshots); - protected: - void run(Services::TargetControllerService& targetControllerService) override; +protected: + void run(Services::TargetControllerService& targetControllerService) override; - private: - Targets::TargetMemoryType memoryType; +private: + Targets::TargetMemoryType memoryType; - std::vector getSnapshots(Targets::TargetMemoryType memoryType); - }; -} + std::vector getSnapshots(Targets::TargetMemoryType memoryType); +}; diff --git a/src/Insight/InsightWorker/Tasks/SetTargetPinState.cpp b/src/Insight/InsightWorker/Tasks/SetTargetPinState.cpp index 083e9899..9bee8418 100644 --- a/src/Insight/InsightWorker/Tasks/SetTargetPinState.cpp +++ b/src/Insight/InsightWorker/Tasks/SetTargetPinState.cpp @@ -1,10 +1,7 @@ #include "SetTargetPinState.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void SetTargetPinState::run(TargetControllerService& targetControllerService) { - targetControllerService.setPinState(this->pinDescriptor, this->pinState); - } +void SetTargetPinState::run(TargetControllerService& targetControllerService) { + targetControllerService.setPinState(this->pinDescriptor, this->pinState); } diff --git a/src/Insight/InsightWorker/Tasks/SetTargetPinState.hpp b/src/Insight/InsightWorker/Tasks/SetTargetPinState.hpp index ac727872..58407dc8 100644 --- a/src/Insight/InsightWorker/Tasks/SetTargetPinState.hpp +++ b/src/Insight/InsightWorker/Tasks/SetTargetPinState.hpp @@ -3,33 +3,30 @@ #include "InsightWorkerTask.hpp" #include "src/Targets/TargetPinDescriptor.hpp" -namespace Bloom +class SetTargetPinState: public InsightWorkerTask { - class SetTargetPinState: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - SetTargetPinState(const Targets::TargetPinDescriptor& pinDescriptor, const Targets::TargetPinState& pinState) - : pinDescriptor(pinDescriptor) - , pinState(pinState) - {} +public: + SetTargetPinState(const Targets::TargetPinDescriptor& pinDescriptor, const Targets::TargetPinState& pinState) + : pinDescriptor(pinDescriptor) + , pinState(pinState) + {} - QString brief() const override { - return "Updating target pin state"; - } + QString brief() const override { + return "Updating target pin state"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - protected: - void run(Services::TargetControllerService& targetControllerService) override; - - private: - Targets::TargetPinDescriptor pinDescriptor; - Targets::TargetPinState pinState; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +protected: + void run(Services::TargetControllerService& targetControllerService) override; + +private: + Targets::TargetPinDescriptor pinDescriptor; + Targets::TargetPinState pinState; +}; diff --git a/src/Insight/InsightWorker/Tasks/TaskGroup.hpp b/src/Insight/InsightWorker/Tasks/TaskGroup.hpp index bf6686c8..69a14b92 100644 --- a/src/Insight/InsightWorker/Tasks/TaskGroup.hpp +++ b/src/Insight/InsightWorker/Tasks/TaskGroup.hpp @@ -3,12 +3,9 @@ #include #include -namespace Bloom +enum class TaskGroup: std::uint16_t { - enum class TaskGroup: std::uint16_t - { - USES_TARGET_CONTROLLER, - }; + USES_TARGET_CONTROLLER, +}; - using TaskGroups = std::set; -} +using TaskGroups = std::set; diff --git a/src/Insight/InsightWorker/Tasks/WriteTargetMemory.cpp b/src/Insight/InsightWorker/Tasks/WriteTargetMemory.cpp index 54020854..02a03aa7 100644 --- a/src/Insight/InsightWorker/Tasks/WriteTargetMemory.cpp +++ b/src/Insight/InsightWorker/Tasks/WriteTargetMemory.cpp @@ -6,69 +6,66 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void WriteTargetMemory::run(TargetControllerService& targetControllerService) { - using Targets::TargetMemorySize; +void WriteTargetMemory::run(TargetControllerService& targetControllerService) { + using Targets::TargetMemorySize; - if (!this->memoryDescriptor.access.writeableDuringDebugSession) { - throw Exceptions::Exception("Invalid request - cannot write to this memory type during a debug session."); - } - - /* - * To prevent locking up the TargetController for too long, we split the write operation into numerous - * operations. - * - * This allows the TargetController to service other commands in-between reads, reducing the likelihood of - * command timeouts when we're writing lots of data. - */ - const auto maxBlockSize = std::max( - TargetMemorySize(256), - this->memoryDescriptor.pageSize.value_or(TargetMemorySize(0)) - ); - - const TargetMemorySize totalBytesToWrite = std::accumulate( - this->blocks.begin(), - this->blocks.end(), - TargetMemorySize{0}, - [] (TargetMemorySize bytes, const Block& block) { - return bytes + block.data.size(); - } - ); - - TargetMemorySize totalBytesWritten = 0; - - for (const auto& block : this->blocks) { - const auto totalBytes = block.data.size(); - - TargetMemorySize bytesWritten = 0; - - while (bytesWritten < totalBytes) { - const auto bytesToWrite = std::min( - maxBlockSize, - static_cast(totalBytes - bytesWritten) - ); - - targetControllerService.writeMemory( - this->memoryDescriptor.type, - block.startAddress + bytesWritten, - Targets::TargetMemoryBuffer( - block.data.begin() + bytesWritten, - block.data.begin() + bytesWritten + bytesToWrite - ) - ); - - bytesWritten += bytesToWrite; - totalBytesWritten += bytesToWrite; - - this->setProgressPercentage(static_cast( - (static_cast(totalBytesWritten) + 1) / (static_cast(totalBytesToWrite) / 100) - )); - } - } - - emit this->targetMemoryWritten(totalBytesWritten); + if (!this->memoryDescriptor.access.writeableDuringDebugSession) { + throw Exceptions::Exception("Invalid request - cannot write to this memory type during a debug session."); } + + /* + * To prevent locking up the TargetController for too long, we split the write operation into numerous + * operations. + * + * This allows the TargetController to service other commands in-between reads, reducing the likelihood of + * command timeouts when we're writing lots of data. + */ + const auto maxBlockSize = std::max( + TargetMemorySize(256), + this->memoryDescriptor.pageSize.value_or(TargetMemorySize(0)) + ); + + const TargetMemorySize totalBytesToWrite = std::accumulate( + this->blocks.begin(), + this->blocks.end(), + TargetMemorySize{0}, + [] (TargetMemorySize bytes, const Block& block) { + return bytes + block.data.size(); + } + ); + + TargetMemorySize totalBytesWritten = 0; + + for (const auto& block : this->blocks) { + const auto totalBytes = block.data.size(); + + TargetMemorySize bytesWritten = 0; + + while (bytesWritten < totalBytes) { + const auto bytesToWrite = std::min( + maxBlockSize, + static_cast(totalBytes - bytesWritten) + ); + + targetControllerService.writeMemory( + this->memoryDescriptor.type, + block.startAddress + bytesWritten, + Targets::TargetMemoryBuffer( + block.data.begin() + bytesWritten, + block.data.begin() + bytesWritten + bytesToWrite + ) + ); + + bytesWritten += bytesToWrite; + totalBytesWritten += bytesToWrite; + + this->setProgressPercentage(static_cast( + (static_cast(totalBytesWritten) + 1) / (static_cast(totalBytesToWrite) / 100) + )); + } + } + + emit this->targetMemoryWritten(totalBytesWritten); } diff --git a/src/Insight/InsightWorker/Tasks/WriteTargetMemory.hpp b/src/Insight/InsightWorker/Tasks/WriteTargetMemory.hpp index ea1ec246..8f1ddd5b 100644 --- a/src/Insight/InsightWorker/Tasks/WriteTargetMemory.hpp +++ b/src/Insight/InsightWorker/Tasks/WriteTargetMemory.hpp @@ -7,67 +7,64 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Helpers/EnumToStringMappings.hpp" -namespace Bloom +class WriteTargetMemory: public InsightWorkerTask { - class WriteTargetMemory: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - /* - * A Block is just a block of contiguous data to write. A single WriteTargetMemory task can write multiple - * blocks to a particular memory. - */ - struct Block { - Targets::TargetMemoryAddress startAddress; - const Targets::TargetMemoryBuffer data; +public: + /* + * A Block is just a block of contiguous data to write. A single WriteTargetMemory task can write multiple + * blocks to a particular memory. + */ + struct Block { + Targets::TargetMemoryAddress startAddress; + const Targets::TargetMemoryBuffer data; - Block( - Targets::TargetMemoryAddress startAddress, - const Targets::TargetMemoryBuffer& data - ) - : startAddress(startAddress) - , data(data) - {} - }; - - WriteTargetMemory( - const Targets::TargetMemoryDescriptor& memoryDescriptor, - std::vector&& blocks - ) - : memoryDescriptor(memoryDescriptor) - , blocks(std::move(blocks)) - {} - - WriteTargetMemory( - const Targets::TargetMemoryDescriptor& memoryDescriptor, + Block( Targets::TargetMemoryAddress startAddress, const Targets::TargetMemoryBuffer& data ) - : WriteTargetMemory(memoryDescriptor, std::vector({{startAddress, data}})) + : startAddress(startAddress) + , data(data) {} - - QString brief() const override { - return - "Writing to target " + EnumToStringMappings::targetMemoryTypes.at( - this->memoryDescriptor.type - ).toUpper(); - } - - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - } - - signals: - void targetMemoryWritten(Targets::TargetMemorySize bytesWritten); - - protected: - void run(Services::TargetControllerService& targetControllerService) override; - - private: - Targets::TargetMemoryDescriptor memoryDescriptor; - std::vector blocks; }; -} + + WriteTargetMemory( + const Targets::TargetMemoryDescriptor& memoryDescriptor, + std::vector&& blocks + ) + : memoryDescriptor(memoryDescriptor) + , blocks(std::move(blocks)) + {} + + WriteTargetMemory( + const Targets::TargetMemoryDescriptor& memoryDescriptor, + Targets::TargetMemoryAddress startAddress, + const Targets::TargetMemoryBuffer& data + ) + : WriteTargetMemory(memoryDescriptor, std::vector({{startAddress, data}})) + {} + + QString brief() const override { + return + "Writing to target " + EnumToStringMappings::targetMemoryTypes.at( + this->memoryDescriptor.type + ).toUpper(); + } + + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); + } + +signals: + void targetMemoryWritten(Targets::TargetMemorySize bytesWritten); + +protected: + void run(Services::TargetControllerService& targetControllerService) override; + +private: + Targets::TargetMemoryDescriptor memoryDescriptor; + std::vector blocks; +}; diff --git a/src/Insight/InsightWorker/Tasks/WriteTargetRegister.cpp b/src/Insight/InsightWorker/Tasks/WriteTargetRegister.cpp index 5e9ba9bb..bfd43266 100644 --- a/src/Insight/InsightWorker/Tasks/WriteTargetRegister.cpp +++ b/src/Insight/InsightWorker/Tasks/WriteTargetRegister.cpp @@ -1,10 +1,7 @@ #include "WriteTargetRegister.hpp" -namespace Bloom -{ - using Services::TargetControllerService; +using Services::TargetControllerService; - void WriteTargetRegister::run(TargetControllerService& targetControllerService) { - targetControllerService.writeRegisters({this->targetRegister}); - } +void WriteTargetRegister::run(TargetControllerService& targetControllerService) { + targetControllerService.writeRegisters({this->targetRegister}); } diff --git a/src/Insight/InsightWorker/Tasks/WriteTargetRegister.hpp b/src/Insight/InsightWorker/Tasks/WriteTargetRegister.hpp index a44e7101..0eb2d681 100644 --- a/src/Insight/InsightWorker/Tasks/WriteTargetRegister.hpp +++ b/src/Insight/InsightWorker/Tasks/WriteTargetRegister.hpp @@ -3,31 +3,28 @@ #include "InsightWorkerTask.hpp" #include "src/Targets/TargetRegister.hpp" -namespace Bloom +class WriteTargetRegister: public InsightWorkerTask { - class WriteTargetRegister: public InsightWorkerTask - { - Q_OBJECT + Q_OBJECT - public: - explicit WriteTargetRegister(const Targets::TargetRegister& targetRegister) - : targetRegister(targetRegister) - {} +public: + explicit WriteTargetRegister(const Targets::TargetRegister& targetRegister) + : targetRegister(targetRegister) + {} - QString brief() const override { - return "Writing target register"; - } + QString brief() const override { + return "Writing target register"; + } - TaskGroups taskGroups() const override { - return TaskGroups({ - TaskGroup::USES_TARGET_CONTROLLER, - }); - }; - - protected: - void run(Services::TargetControllerService& targetControllerService) override; - - private: - Targets::TargetRegister targetRegister; + TaskGroups taskGroups() const override { + return TaskGroups({ + TaskGroup::USES_TARGET_CONTROLLER, + }); }; -} + +protected: + void run(Services::TargetControllerService& targetControllerService) override; + +private: + Targets::TargetRegister targetRegister; +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/AboutWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/AboutWindow.cpp index ce445b78..8cc4ab07 100644 --- a/src/Insight/UserInterfaces/InsightWindow/AboutWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/AboutWindow.cpp @@ -8,39 +8,36 @@ #include "src/Services/PathService.hpp" #include "src/Application.hpp" -namespace Bloom -{ - using namespace Exceptions; +using namespace Exceptions; - AboutWindow::AboutWindow(QWidget* parent): QObject(parent) { - auto aboutWindowUiFile = QFile(QString::fromStdString( - Services::PathService::compiledResourcesPath() - + "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui" - ) - ); - auto aboutWindowStylesheet = QFile(QString::fromStdString( - Services::PathService::compiledResourcesPath() - + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss" - ) - ); +AboutWindow::AboutWindow(QWidget* parent): QObject(parent) { + auto aboutWindowUiFile = QFile(QString::fromStdString( + Services::PathService::compiledResourcesPath() + + "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui" + ) + ); + auto aboutWindowStylesheet = QFile(QString::fromStdString( + Services::PathService::compiledResourcesPath() + + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss" + ) + ); - if (!aboutWindowUiFile.open(QFile::ReadOnly)) { - throw Exception("Failed to open AboutWindow UI file"); - } + if (!aboutWindowUiFile.open(QFile::ReadOnly)) { + throw Exception("Failed to open AboutWindow UI file"); + } - if (!aboutWindowStylesheet.open(QFile::ReadOnly)) { - throw Exception("Failed to open AboutWindow QSS file"); - } + if (!aboutWindowStylesheet.open(QFile::ReadOnly)) { + throw Exception("Failed to open AboutWindow QSS file"); + } - auto uiLoader = UiLoader(this); - this->windowWidget = uiLoader.load(&aboutWindowUiFile, parent); - this->windowWidget->setStyleSheet(aboutWindowStylesheet.readAll()); - this->windowWidget->setFixedSize(400, 300); + auto uiLoader = UiLoader(this); + this->windowWidget = uiLoader.load(&aboutWindowUiFile, parent); + this->windowWidget->setStyleSheet(aboutWindowStylesheet.readAll()); + this->windowWidget->setFixedSize(400, 300); - auto versionLabel = this->windowWidget->findChild("version-label"); + auto versionLabel = this->windowWidget->findChild("version-label"); - if (versionLabel != nullptr) { - versionLabel->setText("Bloom v" + QString::fromStdString(Application::VERSION.toString())); - } + if (versionLabel != nullptr) { + versionLabel->setText("Bloom v" + QString::fromStdString(Application::VERSION.toString())); } } diff --git a/src/Insight/UserInterfaces/InsightWindow/AboutWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/AboutWindow.hpp index cf7d9152..38228592 100644 --- a/src/Insight/UserInterfaces/InsightWindow/AboutWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/AboutWindow.hpp @@ -5,25 +5,22 @@ #include #include -namespace Bloom +class AboutWindow: public QObject { - class AboutWindow: public QObject - { - Q_OBJECT + Q_OBJECT - public: - explicit AboutWindow(QWidget* parent); +public: + explicit AboutWindow(QWidget* parent); - void show() { - if (this->windowWidget != nullptr) { - this->windowWidget->move( - this->windowWidget->parentWidget()->geometry().center() - this->windowWidget->rect().center() - ); - this->windowWidget->show(); - } + void show() { + if (this->windowWidget != nullptr) { + this->windowWidget->move( + this->windowWidget->parentWidget()->geometry().center() - this->windowWidget->rect().center() + ); + this->windowWidget->show(); } + } - private: - QWidget* windowWidget = nullptr; - }; -} +private: + QWidget* windowWidget = nullptr; +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp b/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp index 71473081..f25e850c 100644 --- a/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp @@ -1,17 +1,14 @@ #include "BloomProxyStyle.hpp" -namespace Bloom -{ - int BloomProxyStyle::styleHint( - StyleHint hint, - const QStyleOption* option, - const QWidget* widget, - QStyleHintReturn* returnData - ) const { - if (hint == QStyle::SH_ComboBox_Popup) { - return 0; - } - - return QProxyStyle::styleHint(hint, option, widget, returnData); +int BloomProxyStyle::styleHint( + StyleHint hint, + const QStyleOption* option, + const QWidget* widget, + QStyleHintReturn* returnData +) const { + if (hint == QStyle::SH_ComboBox_Popup) { + return 0; } + + return QProxyStyle::styleHint(hint, option, widget, returnData); } diff --git a/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.hpp b/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.hpp index 409338d4..02f56e28 100644 --- a/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.hpp @@ -2,18 +2,15 @@ #include -namespace Bloom +class BloomProxyStyle: public QProxyStyle { - class BloomProxyStyle: public QProxyStyle - { - Q_OBJECT + Q_OBJECT - public: - int styleHint( - StyleHint hint, - const QStyleOption* option = nullptr, - const QWidget* widget = nullptr, - QStyleHintReturn* returnData = nullptr - ) const override; - }; -} +public: + int styleHint( + StyleHint hint, + const QStyleOption* option = nullptr, + const QWidget* widget = nullptr, + QStyleHintReturn* returnData = nullptr + ) const override; +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index f49b058b..b10d05a1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -18,1094 +18,1091 @@ #include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp" -namespace Bloom +using namespace Exceptions; +using namespace Widgets; + +using Targets::TargetDescriptor; +using Targets::TargetState; +using Targets::TargetPinState; +using Targets::TargetVariant; +using Targets::TargetPackage; +using Targets::TargetPinDescriptor; +using Targets::TargetMemoryType; + +InsightWindow::InsightWindow( + const EnvironmentConfig& environmentConfig, + const InsightConfig& insightConfig, + InsightProjectSettings& insightProjectSettings, + const Targets::TargetDescriptor& targetDescriptor +) + : QMainWindow(nullptr) + , environmentConfig(environmentConfig) + , targetConfig(environmentConfig.targetConfig) + , insightConfig(insightConfig) + , insightProjectSettings(insightProjectSettings) + , targetDescriptor(targetDescriptor) { - using namespace Bloom::Exceptions; - using namespace Bloom::Widgets; + this->setObjectName("main-window"); + this->setAttribute(Qt::WA_DeleteOnClose, true); + this->setWindowTitle("Bloom Insight"); - using Bloom::Targets::TargetDescriptor; - using Bloom::Targets::TargetState; - using Bloom::Targets::TargetPinState; - using Bloom::Targets::TargetVariant; - using Bloom::Targets::TargetPackage; - using Bloom::Targets::TargetPinDescriptor; - using Bloom::Targets::TargetMemoryType; + auto windowSize = QSize(1000, 500); - InsightWindow::InsightWindow( - const EnvironmentConfig& environmentConfig, - const InsightConfig& insightConfig, - InsightProjectSettings& insightProjectSettings, - const Targets::TargetDescriptor& targetDescriptor - ) - : QMainWindow(nullptr) - , environmentConfig(environmentConfig) - , targetConfig(environmentConfig.targetConfig) - , insightConfig(insightConfig) - , insightProjectSettings(insightProjectSettings) - , targetDescriptor(targetDescriptor) - { - this->setObjectName("main-window"); - this->setAttribute(Qt::WA_DeleteOnClose, true); - this->setWindowTitle("Bloom Insight"); + if (this->insightProjectSettings.mainWindowSize.has_value()) { + windowSize = QSize( + std::max(this->insightProjectSettings.mainWindowSize->width(), windowSize.width()), + std::max(this->insightProjectSettings.mainWindowSize->height(), windowSize.height()) + ); + } - auto windowSize = QSize(1000, 500); + this->setFixedSize(windowSize); + this->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); + this->setMinimumSize(0, 0); - if (this->insightProjectSettings.mainWindowSize.has_value()) { - windowSize = QSize( - std::max(this->insightProjectSettings.mainWindowSize->width(), windowSize.width()), - std::max(this->insightProjectSettings.mainWindowSize->height(), windowSize.height()) - ); + auto mainWindowUiFile = QFile( + QString::fromStdString(Services::PathService::compiledResourcesPath() + + "/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui" + ) + ); + auto mainWindowStylesheet = QFile( + QString::fromStdString(Services::PathService::compiledResourcesPath() + + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss" + ) + ); + + if (!mainWindowUiFile.open(QFile::ReadOnly)) { + throw Exception("Failed to open InsightWindow UI file"); + } + + if (!mainWindowStylesheet.open(QFile::ReadOnly)) { + throw Exception("Failed to open InsightWindow stylesheet file"); + } + + auto uiLoader = UiLoader(this); + this->windowContainer = uiLoader.load(&mainWindowUiFile, this); + this->windowContainer->setStyleSheet(mainWindowStylesheet.readAll()); + + mainWindowUiFile.close(); + mainWindowStylesheet.close(); + + QApplication::setWindowIcon(QIcon( + QString::fromStdString(Services::PathService::compiledResourcesPath() + + "/src/Insight/UserInterfaces/InsightWindow/Images/bloom-icon.svg" + ) + )); + + this->layoutContainer = this->windowContainer->findChild("layout-container"); + this->mainMenuBar = this->windowContainer->findChild("menu-bar"); + this->layoutContainer->layout()->setMenuBar(this->mainMenuBar); + this->container = this->layoutContainer->findChild("container"); + this->ioContainerWidget = this->windowContainer->findChild( + "io-container" + ); + this->ioUnavailableWidget = this->windowContainer->findChild("io-inspection-unavailable"); + + auto* horizontalContentLayout = this->container->findChild("horizontal-content-layout"); + auto* verticalContentLayout = this->container->findChild("vertical-content-layout"); + + auto* fileMenu = this->mainMenuBar->findChild("file-menu"); + auto* helpMenu = this->mainMenuBar->findChild("help-menu"); + auto* quitAction = fileMenu->findChild("close-insight"); + auto* openReportIssuesUrlAction = helpMenu->findChild("open-report-issues-url"); + auto* openGettingStartedUrlAction = helpMenu->findChild("open-getting-started-url"); + auto* openAboutWindowAction = helpMenu->findChild("open-about-dialogue"); + + this->header = this->windowContainer->findChild("header"); + this->refreshIoInspectionButton = this->header->findChild("refresh-io-inspection-btn"); + + // Create panel states + if (!this->insightProjectSettings.leftPanelState.has_value()) { + this->insightProjectSettings.leftPanelState = PanelState(); + } + + if (!this->insightProjectSettings.bottomPanelState.has_value()) { + this->insightProjectSettings.bottomPanelState = PanelState(); + } + + this->leftMenuBar = this->container->findChild("left-side-menu-bar"); + this->leftPanel = new PanelWidget( + PanelWidgetType::LEFT, + this->insightProjectSettings.leftPanelState.value(), + this->container + ); + this->leftPanel->setObjectName("left-panel"); + this->leftPanel->setHandleSize(6); + this->leftPanel->setMinimumResize(300); + horizontalContentLayout->insertWidget(0, this->leftPanel); + + this->targetRegistersButton = this->container->findChild("target-registers-btn"); + auto* targetRegisterButtonLayout = this->targetRegistersButton->findChild(); + auto* registersBtnLabel = new RotatableLabel(270, "Registers", this->targetRegistersButton); + registersBtnLabel->setObjectName("target-registers-btn-label"); + registersBtnLabel->setContentsMargins(4, 4, 10, 2); + targetRegisterButtonLayout->insertWidget(0, registersBtnLabel, 0, Qt::AlignTop); + + this->bottomMenuBar = this->container->findChild("bottom-menu-bar"); + this->bottomPanel = new PanelWidget( + PanelWidgetType::BOTTOM, + this->insightProjectSettings.bottomPanelState.value(), + this->container + ); + this->bottomPanel->setObjectName("bottom-panel"); + this->bottomPanel->setHandleSize(10); + verticalContentLayout->insertWidget(1, this->bottomPanel); + + this->ramInspectionButton = this->container->findChild("ram-inspection-btn"); + this->eepromInspectionButton = this->container->findChild("eeprom-inspection-btn"); + this->flashInspectionButton = this->container->findChild("flash-inspection-btn"); + + this->footer = this->windowContainer->findChild("footer"); + this->targetStatusLabel = this->footer->findChild("target-state"); + this->programCounterValueLabel = this->footer->findChild("target-program-counter-value"); + this->targetNameLabel = this->footer->findChild("target-name"); + this->targetIdLabel = this->footer->findChild("target-id"); + this->variantMenu = this->footer->findChild("target-variant-menu"); + + this->taskIndicator = new TaskIndicator(this); + auto* footerLayout = this->footer->findChild(); + footerLayout->insertWidget(2, this->taskIndicator); + + this->windowContainer->setFixedSize(windowSize); + this->layoutContainer->setFixedSize(windowSize); + + // InsightSignal connections + auto* insightSignals = InsightSignals::instance(); + + QObject::connect( + insightSignals, + &InsightSignals::targetStateUpdated, + this, + &InsightWindow::onTargetStateUpdate + ); + QObject::connect( + insightSignals, + &InsightSignals::targetReset, + this, + [this] { + this->refreshProgramCounter(); + } + ); + + QObject::connect( + insightSignals, + &InsightSignals::programmingModeEnabled, + this, + &InsightWindow::onProgrammingModeEnabled + ); + QObject::connect( + insightSignals, + &InsightSignals::programmingModeDisabled, + this, + &InsightWindow::onProgrammingModeDisabled + ); + + this->targetNameLabel->setText(QString::fromStdString(this->targetDescriptor.name)); + this->targetIdLabel->setText("0x" + QString::fromStdString(this->targetDescriptor.id).remove("0x").toUpper()); + + this->ioUnavailableWidget->hide(); + + this->populateVariantMenu(); + this->variantMenu->setEnabled(true); + + Logger::debug("Number of target variants supported by Insight: " + + std::to_string(supportedVariantsByName.size())); + + if (this->supportedVariantsByName.empty()) { + if (this->targetDescriptor.variants.empty()) { + this->variantMenu->parentWidget()->hide(); } - this->setFixedSize(windowSize); - this->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); - this->setMinimumSize(0, 0); - - auto mainWindowUiFile = QFile( - QString::fromStdString(Services::PathService::compiledResourcesPath() - + "/src/Insight/UserInterfaces/InsightWindow/UiFiles/InsightWindow.ui" - ) - ); - auto mainWindowStylesheet = QFile( - QString::fromStdString(Services::PathService::compiledResourcesPath() - + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss" - ) + this->ioUnavailableWidget->setText( + "GPIO inspection is not available for this target. " + "Please report this to Bloom developers by clicking Help -> Report An Issue" ); + this->ioUnavailableWidget->show(); - if (!mainWindowUiFile.open(QFile::ReadOnly)) { - throw Exception("Failed to open InsightWindow UI file"); - } + } else { + this->selectDefaultVariant(); + } - if (!mainWindowStylesheet.open(QFile::ReadOnly)) { - throw Exception("Failed to open InsightWindow stylesheet file"); - } + this->createPanes(); + this->setUiDisabled(true); - auto uiLoader = UiLoader(this); - this->windowContainer = uiLoader.load(&mainWindowUiFile, this); - this->windowContainer->setStyleSheet(mainWindowStylesheet.readAll()); + // Main menu connections + QObject::connect( + quitAction, + &QAction::triggered, + this, + &InsightWindow::close + ); + QObject::connect( + openReportIssuesUrlAction, + &QAction::triggered, + this, + &InsightWindow::openReportIssuesUrl + ); + QObject::connect( + openGettingStartedUrlAction, + &QAction::triggered, + this, + &InsightWindow::openGettingStartedUrl + ); + QObject::connect( + openAboutWindowAction, + &QAction::triggered, + this, + &InsightWindow::openAboutWindow + ); - mainWindowUiFile.close(); - mainWindowStylesheet.close(); + // Toolbar button connections + QObject::connect( + this->refreshIoInspectionButton, + &QToolButton::clicked, + this, + &InsightWindow::refresh + ); - QApplication::setWindowIcon(QIcon( - QString::fromStdString(Services::PathService::compiledResourcesPath() - + "/src/Insight/UserInterfaces/InsightWindow/Images/bloom-icon.svg" - ) - )); + // Panel connections + QObject::connect( + this->leftPanel, + &PanelWidget::opened, + this, + &InsightWindow::adjustMinimumSize + ); + QObject::connect( + this->leftPanel, + &PanelWidget::closed, + this, + &InsightWindow::adjustMinimumSize + ); + QObject::connect( + this->bottomPanel, + &PanelWidget::opened, + this, + &InsightWindow::adjustMinimumSize + ); + QObject::connect( + this->bottomPanel, + &PanelWidget::closed, + this, + &InsightWindow::adjustMinimumSize + ); - this->layoutContainer = this->windowContainer->findChild("layout-container"); - this->mainMenuBar = this->windowContainer->findChild("menu-bar"); - this->layoutContainer->layout()->setMenuBar(this->mainMenuBar); - this->container = this->layoutContainer->findChild("container"); - this->ioContainerWidget = this->windowContainer->findChild( - "io-container" - ); - this->ioUnavailableWidget = this->windowContainer->findChild("io-inspection-unavailable"); + // Panel button connections + QObject::connect( + this->targetRegistersButton, + &QToolButton::clicked, + this, + &InsightWindow::toggleTargetRegistersPane + ); + QObject::connect( + this->ramInspectionButton, + &QToolButton::clicked, + this, + &InsightWindow::toggleRamInspectionPane + ); + QObject::connect( + this->eepromInspectionButton, + &QToolButton::clicked, + this, + &InsightWindow::toggleEepromInspectionPane + ); + QObject::connect( + this->flashInspectionButton, + &QToolButton::clicked, + this, + &InsightWindow::toggleFlashInspectionPane + ); +} - auto* horizontalContentLayout = this->container->findChild("horizontal-content-layout"); - auto* verticalContentLayout = this->container->findChild("vertical-content-layout"); +void InsightWindow::resizeEvent(QResizeEvent* event) { + const auto windowSize = this->size(); - auto* fileMenu = this->mainMenuBar->findChild("file-menu"); - auto* helpMenu = this->mainMenuBar->findChild("help-menu"); - auto* quitAction = fileMenu->findChild("close-insight"); - auto* openReportIssuesUrlAction = helpMenu->findChild("open-report-issues-url"); - auto* openGettingStartedUrlAction = helpMenu->findChild("open-getting-started-url"); - auto* openAboutWindowAction = helpMenu->findChild("open-about-dialogue"); + this->windowContainer->setFixedSize(windowSize); + this->layoutContainer->setFixedSize(windowSize); - this->header = this->windowContainer->findChild("header"); - this->refreshIoInspectionButton = this->header->findChild("refresh-io-inspection-btn"); + this->adjustPanels(); - // Create panel states - if (!this->insightProjectSettings.leftPanelState.has_value()) { - this->insightProjectSettings.leftPanelState = PanelState(); - } + this->insightProjectSettings.mainWindowSize = windowSize; +} - if (!this->insightProjectSettings.bottomPanelState.has_value()) { - this->insightProjectSettings.bottomPanelState = PanelState(); - } +void InsightWindow::showEvent(QShowEvent* event) { + this->adjustPanels(); + this->adjustMinimumSize(); +} - this->leftMenuBar = this->container->findChild("left-side-menu-bar"); - this->leftPanel = new PanelWidget( - PanelWidgetType::LEFT, - this->insightProjectSettings.leftPanelState.value(), - this->container - ); - this->leftPanel->setObjectName("left-panel"); - this->leftPanel->setHandleSize(6); - this->leftPanel->setMinimumResize(300); - horizontalContentLayout->insertWidget(0, this->leftPanel); +void InsightWindow::closeEvent(QCloseEvent* event) { + return QMainWindow::closeEvent(event); +} - this->targetRegistersButton = this->container->findChild("target-registers-btn"); - auto* targetRegisterButtonLayout = this->targetRegistersButton->findChild(); - auto* registersBtnLabel = new RotatableLabel(270, "Registers", this->targetRegistersButton); - registersBtnLabel->setObjectName("target-registers-btn-label"); - registersBtnLabel->setContentsMargins(4, 4, 10, 2); - targetRegisterButtonLayout->insertWidget(0, registersBtnLabel, 0, Qt::AlignTop); +bool InsightWindow::isVariantSupported(const TargetVariant& variant) { + const auto pinCount = variant.pinDescriptorsByNumber.size(); - this->bottomMenuBar = this->container->findChild("bottom-menu-bar"); - this->bottomPanel = new PanelWidget( - PanelWidgetType::BOTTOM, - this->insightProjectSettings.bottomPanelState.value(), - this->container - ); - this->bottomPanel->setObjectName("bottom-panel"); - this->bottomPanel->setHandleSize(10); - verticalContentLayout->insertWidget(1, this->bottomPanel); + /* + * Because the size of the pin body widget is fixed, for all of our target package widgets, we run out of screen + * estate for target variants with more than 100 pins. + * + * This will be addressed at some point, but for now, we just won't support variants with more than 100 pins. + * + * I don't think there are any AVR targets with variants with more than 100 pins, so this isn't a problem anyway. + */ + if (pinCount > 100) { + return false; + } - this->ramInspectionButton = this->container->findChild("ram-inspection-btn"); - this->eepromInspectionButton = this->container->findChild("eeprom-inspection-btn"); - this->flashInspectionButton = this->container->findChild("flash-inspection-btn"); + if ( + variant.package != TargetPackage::DIP + && variant.package != TargetPackage::SOIC + && variant.package != TargetPackage::SSOP + && variant.package != TargetPackage::QFP + && variant.package != TargetPackage::QFN + ) { + return false; + } - this->footer = this->windowContainer->findChild("footer"); - this->targetStatusLabel = this->footer->findChild("target-state"); - this->programCounterValueLabel = this->footer->findChild("target-program-counter-value"); - this->targetNameLabel = this->footer->findChild("target-name"); - this->targetIdLabel = this->footer->findChild("target-id"); - this->variantMenu = this->footer->findChild("target-variant-menu"); + if ( + ( + variant.package == TargetPackage::DIP + || variant.package == TargetPackage::SOIC + || variant.package == TargetPackage::SSOP + ) + && pinCount % 2 != 0 + ) { + // All DIP, SOIC and SSOP variants must have a pin count that is a multiple of two + return false; + } - this->taskIndicator = new TaskIndicator(this); - auto* footerLayout = this->footer->findChild(); - footerLayout->insertWidget(2, this->taskIndicator); + if ( + (variant.package == TargetPackage::QFP || variant.package == TargetPackage::QFN) + && (pinCount % 4 != 0 || pinCount <= 4) + ) { + /* + * All QFP and QFN variants must have a pin count that is a multiple of four. And there must be + * more than one pin per side. + */ + return false; + } - this->windowContainer->setFixedSize(windowSize); - this->layoutContainer->setFixedSize(windowSize); + return true; +} - // InsightSignal connections - auto* insightSignals = InsightSignals::instance(); +void InsightWindow::setUiDisabled(bool disable) { + this->uiDisabled = disable; - QObject::connect( - insightSignals, - &InsightSignals::targetStateUpdated, - this, - &InsightWindow::onTargetStateUpdate - ); - QObject::connect( - insightSignals, - &InsightSignals::targetReset, - this, - [this] { - this->refreshProgramCounter(); + if (this->refreshIoInspectionButton != nullptr) { + this->refreshIoInspectionButton->setDisabled(disable); + this->refreshIoInspectionButton->repaint(); + } +} + +void InsightWindow::populateVariantMenu() { + /* + * We don't want to present the user with duplicate target variants. + * + * In the context of the Insight window, two variants are considered to be duplicates if they do not differ in + * package type and pinout configuration. + */ + auto processedVariants = std::vector(); + const auto isDuplicateVariant = [&processedVariants] (const TargetVariant& variantA) { + return std::ranges::any_of( + processedVariants.begin(), + processedVariants.end(), + [&variantA, &processedVariants] (const TargetVariant& variantB) { + if (variantA.package != variantB.package) { + return false; + } + + if (variantA.pinDescriptorsByNumber.size() != variantB.pinDescriptorsByNumber.size()) { + return false; + } + + if (variantA.pinDescriptorsByNumber != variantB.pinDescriptorsByNumber) { + return false; + } + + return true; } ); + }; - QObject::connect( - insightSignals, - &InsightSignals::programmingModeEnabled, - this, - &InsightWindow::onProgrammingModeEnabled - ); - QObject::connect( - insightSignals, - &InsightSignals::programmingModeDisabled, - this, - &InsightWindow::onProgrammingModeDisabled - ); - - this->targetNameLabel->setText(QString::fromStdString(this->targetDescriptor.name)); - this->targetIdLabel->setText("0x" + QString::fromStdString(this->targetDescriptor.id).remove("0x").toUpper()); - - this->ioUnavailableWidget->hide(); - - this->populateVariantMenu(); - this->variantMenu->setEnabled(true); - - Logger::debug("Number of target variants supported by Insight: " - + std::to_string(supportedVariantsByName.size())); - - if (this->supportedVariantsByName.empty()) { - if (this->targetDescriptor.variants.empty()) { - this->variantMenu->parentWidget()->hide(); - } - - this->ioUnavailableWidget->setText( - "GPIO inspection is not available for this target. " - "Please report this to Bloom developers by clicking Help -> Report An Issue" - ); - this->ioUnavailableWidget->show(); - - } else { - this->selectDefaultVariant(); + for (const auto& targetVariant: this->targetDescriptor.variants) { + if (isDuplicateVariant(targetVariant)) { + continue; } - this->createPanes(); - this->setUiDisabled(true); - - // Main menu connections - QObject::connect( - quitAction, - &QAction::triggered, - this, - &InsightWindow::close - ); - QObject::connect( - openReportIssuesUrlAction, - &QAction::triggered, - this, - &InsightWindow::openReportIssuesUrl - ); - QObject::connect( - openGettingStartedUrlAction, - &QAction::triggered, - this, - &InsightWindow::openGettingStartedUrl - ); - QObject::connect( - openAboutWindowAction, - &QAction::triggered, - this, - &InsightWindow::openAboutWindow + auto* variantAction = new QAction(this->variantMenu); + variantAction->setText( + QString::fromStdString(targetVariant.name + " (" + targetVariant.packageName + ")") ); - // Toolbar button connections - QObject::connect( - this->refreshIoInspectionButton, - &QToolButton::clicked, - this, - &InsightWindow::refresh - ); + if (InsightWindow::isVariantSupported(targetVariant)) { + auto* supportedVariantPtr = &(this->supportedVariantsByName.insert( + std::pair(QString::fromStdString(targetVariant.name).toLower(), targetVariant) + ).first->second); - // Panel connections - QObject::connect( - this->leftPanel, - &PanelWidget::opened, - this, - &InsightWindow::adjustMinimumSize - ); - QObject::connect( - this->leftPanel, - &PanelWidget::closed, - this, - &InsightWindow::adjustMinimumSize - ); - QObject::connect( - this->bottomPanel, - &PanelWidget::opened, - this, - &InsightWindow::adjustMinimumSize - ); - QObject::connect( - this->bottomPanel, - &PanelWidget::closed, - this, - &InsightWindow::adjustMinimumSize - ); - - // Panel button connections - QObject::connect( - this->targetRegistersButton, - &QToolButton::clicked, - this, - &InsightWindow::toggleTargetRegistersPane - ); - QObject::connect( - this->ramInspectionButton, - &QToolButton::clicked, - this, - &InsightWindow::toggleRamInspectionPane - ); - QObject::connect( - this->eepromInspectionButton, - &QToolButton::clicked, - this, - &InsightWindow::toggleEepromInspectionPane - ); - QObject::connect( - this->flashInspectionButton, - &QToolButton::clicked, - this, - &InsightWindow::toggleFlashInspectionPane - ); - } - - void InsightWindow::resizeEvent(QResizeEvent* event) { - const auto windowSize = this->size(); - - this->windowContainer->setFixedSize(windowSize); - this->layoutContainer->setFixedSize(windowSize); - - this->adjustPanels(); - - this->insightProjectSettings.mainWindowSize = windowSize; - } - - void InsightWindow::showEvent(QShowEvent* event) { - this->adjustPanels(); - this->adjustMinimumSize(); - } - - void InsightWindow::closeEvent(QCloseEvent* event) { - return QMainWindow::closeEvent(event); - } - - bool InsightWindow::isVariantSupported(const TargetVariant& variant) { - const auto pinCount = variant.pinDescriptorsByNumber.size(); - - /* - * Because the size of the pin body widget is fixed, for all of our target package widgets, we run out of screen - * estate for target variants with more than 100 pins. - * - * This will be addressed at some point, but for now, we just won't support variants with more than 100 pins. - * - * I don't think there are any AVR targets with variants with more than 100 pins, so this isn't a problem anyway. - */ - if (pinCount > 100) { - return false; - } - - if ( - variant.package != TargetPackage::DIP - && variant.package != TargetPackage::SOIC - && variant.package != TargetPackage::SSOP - && variant.package != TargetPackage::QFP - && variant.package != TargetPackage::QFN - ) { - return false; - } - - if ( - ( - variant.package == TargetPackage::DIP - || variant.package == TargetPackage::SOIC - || variant.package == TargetPackage::SSOP - ) - && pinCount % 2 != 0 - ) { - // All DIP, SOIC and SSOP variants must have a pin count that is a multiple of two - return false; - } - - if ( - (variant.package == TargetPackage::QFP || variant.package == TargetPackage::QFN) - && (pinCount % 4 != 0 || pinCount <= 4) - ) { - /* - * All QFP and QFN variants must have a pin count that is a multiple of four. And there must be - * more than one pin per side. - */ - return false; - } - - return true; - } - - void InsightWindow::setUiDisabled(bool disable) { - this->uiDisabled = disable; - - if (this->refreshIoInspectionButton != nullptr) { - this->refreshIoInspectionButton->setDisabled(disable); - this->refreshIoInspectionButton->repaint(); - } - } - - void InsightWindow::populateVariantMenu() { - /* - * We don't want to present the user with duplicate target variants. - * - * In the context of the Insight window, two variants are considered to be duplicates if they do not differ in - * package type and pinout configuration. - */ - auto processedVariants = std::vector(); - const auto isDuplicateVariant = [&processedVariants] (const TargetVariant& variantA) { - return std::ranges::any_of( - processedVariants.begin(), - processedVariants.end(), - [&variantA, &processedVariants] (const TargetVariant& variantB) { - if (variantA.package != variantB.package) { - return false; - } - - if (variantA.pinDescriptorsByNumber.size() != variantB.pinDescriptorsByNumber.size()) { - return false; - } - - if (variantA.pinDescriptorsByNumber != variantB.pinDescriptorsByNumber) { - return false; - } - - return true; + QObject::connect( + variantAction, + &QAction::triggered, + this, + [this, supportedVariantPtr] { + this->selectVariant(supportedVariantPtr); } ); - }; - - for (const auto& targetVariant: this->targetDescriptor.variants) { - if (isDuplicateVariant(targetVariant)) { - continue; - } - - auto* variantAction = new QAction(this->variantMenu); - variantAction->setText( - QString::fromStdString(targetVariant.name + " (" + targetVariant.packageName + ")") - ); - - if (InsightWindow::isVariantSupported(targetVariant)) { - auto* supportedVariantPtr = &(this->supportedVariantsByName.insert( - std::pair(QString::fromStdString(targetVariant.name).toLower(), targetVariant) - ).first->second); - - QObject::connect( - variantAction, - &QAction::triggered, - this, - [this, supportedVariantPtr] { - this->selectVariant(supportedVariantPtr); - } - ); - - } else { - variantAction->setEnabled(false); - variantAction->setText(variantAction->text() + " (unsupported)"); - } - - this->variantMenu->addAction(variantAction); - processedVariants.push_back(targetVariant); - } - } - - void InsightWindow::selectDefaultVariant() { - if (this->supportedVariantsByName.empty()) { - return; - } - - std::optional previouslySelectedVariantName = (this->previouslySelectedVariant.has_value()) - ? std::optional(QString::fromStdString(this->previouslySelectedVariant->name).toLower()) - : std::nullopt; - - if (previouslySelectedVariantName.has_value()) { - const auto previouslySelectedVariantIt = this->supportedVariantsByName.find(*previouslySelectedVariantName); - - if (previouslySelectedVariantIt != this->supportedVariantsByName.end()) { - this->selectVariant(&(previouslySelectedVariantIt->second)); - return; - } - } - - if (this->targetConfig.variantName.has_value()) { - const auto variantIt = this->supportedVariantsByName.find( - QString::fromStdString(*this->targetConfig.variantName) - ); - - if (variantIt != this->supportedVariantsByName.end()) { - // The user has specified a valid variant name in their config file, so use that as the default - this->selectVariant(&(variantIt->second)); - - } else { - Logger::error( - "Invalid target variant name \"" + this->targetConfig.variantName.value() - + "\" - no such variant with the given name was found." - ); - } - } - - /* - * Given that we haven't been able to select a variant at this point, we will just fall back to the first - * one that is available. - */ - this->selectVariant(&(this->supportedVariantsByName.begin()->second)); - } - - void InsightWindow::selectVariant(const TargetVariant* variant) { - if (!this->isVariantSupported(*variant)) { - Logger::error("Attempted to select unsupported target variant."); - return; - } - - if (this->selectedVariant != nullptr && this->selectedVariant->id == variant->id) { - // The variant is already selected. - return; - } - - if (this->targetPackageWidget != nullptr) { - this->targetPackageWidget->hide(); - this->targetPackageWidget->deleteLater(); - this->targetPackageWidget = nullptr; - this->ioContainerWidget->setPackageWidget(this->targetPackageWidget); - } - - this->selectedVariant = variant; - this->variantMenu->setTitle(QString::fromStdString(variant->name + " (" + variant->packageName + ")")); - - if ( - variant->package == TargetPackage::DIP - || variant->package == TargetPackage::SOIC - || variant->package == TargetPackage::SSOP - ) { - this->targetPackageWidget = new InsightTargetWidgets::Dip::DualInlinePackageWidget( - *variant, - this->ioContainerWidget - ); - - } else if (variant->package == TargetPackage::QFP || variant->package == TargetPackage::QFN) { - this->targetPackageWidget = new InsightTargetWidgets::Qfp::QuadFlatPackageWidget( - *variant, - this->ioContainerWidget - ); - } - - if (this->targetPackageWidget != nullptr) { - this->ioContainerWidget->setPackageWidget(this->targetPackageWidget); - this->targetPackageWidget->setTargetState(this->targetState); - - if (this->targetState == TargetState::STOPPED) { - this->refreshPinStates(); - } - - this->adjustPanels(); - this->adjustMinimumSize(); - this->targetPackageWidget->show(); - } - } - - void InsightWindow::createPanes() { - // Target registers pane - if (!this->insightProjectSettings.registersPaneState.has_value()) { - this->insightProjectSettings.registersPaneState = PaneState(false, true, std::nullopt); - } - - auto* leftPanelLayout = this->leftPanel->layout(); - this->targetRegistersSidePane = new TargetRegistersPaneWidget( - this->targetDescriptor, - *(this->insightProjectSettings.registersPaneState), - this->leftPanel - ); - leftPanelLayout->addWidget(this->targetRegistersSidePane); - - QObject::connect( - this->targetRegistersSidePane, - &PaneWidget::paneActivated, - this, - &InsightWindow::onRegistersPaneStateChanged - ); - QObject::connect( - this->targetRegistersSidePane, - &PaneWidget::paneDeactivated, - this, - &InsightWindow::onRegistersPaneStateChanged - ); - - this->targetRegistersButton->setDisabled(false); - this->onRegistersPaneStateChanged(); - - auto& memoryInspectionPaneSettingsByMemoryType = - this->insightProjectSettings.memoryInspectionPaneSettingsByMemoryType; - - // Target memory inspection panes - auto* bottomPanelLayout = this->bottomPanel->layout(); - - const auto ramDescriptorIt = this->targetDescriptor.memoryDescriptorsByType.find(TargetMemoryType::RAM); - const auto eepromDescriptorIt = this->targetDescriptor.memoryDescriptorsByType.find(TargetMemoryType::EEPROM); - const auto flashDescriptorIt = this->targetDescriptor.memoryDescriptorsByType.find(TargetMemoryType::FLASH); - - if (ramDescriptorIt != this->targetDescriptor.memoryDescriptorsByType.end()) { - if (!this->insightProjectSettings.ramInspectionPaneState.has_value()) { - this->insightProjectSettings.ramInspectionPaneState = PaneState(false, true, std::nullopt); - } - - if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::RAM)) { - memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM] = TargetMemoryInspectionPaneSettings(); - } - - this->ramInspectionPane = new TargetMemoryInspectionPane( - ramDescriptorIt->second, - memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM], - *(this->insightProjectSettings.ramInspectionPaneState), - this->bottomPanel - ); - - bottomPanelLayout->addWidget(this->ramInspectionPane); - - QObject::connect( - this->ramInspectionPane, - &PaneWidget::paneActivated, - this, - &InsightWindow::onRamInspectionPaneStateChanged - ); - QObject::connect( - this->ramInspectionPane, - &PaneWidget::paneDeactivated, - this, - &InsightWindow::onRamInspectionPaneStateChanged - ); - QObject::connect( - this->ramInspectionPane, - &PaneWidget::paneAttached, - this, - &InsightWindow::onRamInspectionPaneStateChanged - ); - - this->ramInspectionButton->setDisabled(false); - this->onRamInspectionPaneStateChanged(); - } - - if (eepromDescriptorIt != this->targetDescriptor.memoryDescriptorsByType.end()) { - if (!this->insightProjectSettings.eepromInspectionPaneState.has_value()) { - this->insightProjectSettings.eepromInspectionPaneState = PaneState(false, true, std::nullopt); - } - - if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::EEPROM)) { - memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM] = TargetMemoryInspectionPaneSettings(); - } - - this->eepromInspectionPane = new TargetMemoryInspectionPane( - eepromDescriptorIt->second, - memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM], - *(this->insightProjectSettings.eepromInspectionPaneState), - this->bottomPanel - ); - - bottomPanelLayout->addWidget(this->eepromInspectionPane); - - QObject::connect( - this->eepromInspectionPane, - &PaneWidget::paneActivated, - this, - &InsightWindow::onEepromInspectionPaneStateChanged - ); - QObject::connect( - this->eepromInspectionPane, - &PaneWidget::paneDeactivated, - this, - &InsightWindow::onEepromInspectionPaneStateChanged - ); - QObject::connect( - this->eepromInspectionPane, - &PaneWidget::paneAttached, - this, - &InsightWindow::onEepromInspectionPaneStateChanged - ); - - this->eepromInspectionButton->setDisabled(false); - this->onEepromInspectionPaneStateChanged(); - } - - if (flashDescriptorIt != this->targetDescriptor.memoryDescriptorsByType.end()) { - if (!this->insightProjectSettings.flashInspectionPaneState.has_value()) { - this->insightProjectSettings.flashInspectionPaneState = PaneState(false, true, std::nullopt); - } - - if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::FLASH)) { - memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::FLASH] = TargetMemoryInspectionPaneSettings(); - } - - this->flashInspectionPane = new TargetMemoryInspectionPane( - flashDescriptorIt->second, - memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::FLASH], - *(this->insightProjectSettings.flashInspectionPaneState), - this->bottomPanel - ); - - bottomPanelLayout->addWidget(this->flashInspectionPane); - - QObject::connect( - this->flashInspectionPane, - &PaneWidget::paneActivated, - this, - &InsightWindow::onFlashInspectionPaneStateChanged - ); - QObject::connect( - this->flashInspectionPane, - &PaneWidget::paneDeactivated, - this, - &InsightWindow::onFlashInspectionPaneStateChanged - ); - QObject::connect( - this->flashInspectionPane, - &PaneWidget::paneAttached, - this, - &InsightWindow::onFlashInspectionPaneStateChanged - ); - - this->flashInspectionButton->setDisabled(false); - this->onFlashInspectionPaneStateChanged(); - } - } - - void InsightWindow::adjustPanels() { - const auto targetPackageWidgetSize = (this->targetPackageWidget != nullptr) - ? this->targetPackageWidget->size() : QSize(); - const auto containerSize = this->size(); - - if (!this->isVisible()) { - return; - } - - /* - * The purpose of the -20 is to ensure there is some padding between the panel borders and the - * target package widget. Looks nicer with the padding. - */ - this->leftPanel->setMaximumResize( - std::max( - this->leftPanel->getMinimumResize(), - containerSize.width() - targetPackageWidgetSize.width() - this->leftMenuBar->width() - 20 - ) - ); - - /* - * Allow the bottom panel to overlap the target package widget (because the target package widget can - * occupy a lot of space and become an annoyance if the bottom panel is restricted too much). - */ - this->bottomPanel->setMaximumResize( - std::max( - this->bottomPanel->getMinimumResize(), - (containerSize.height() / 2) - this->mainMenuBar->height() - this->bottomMenuBar->height() - 20 - ) - ); - - this->bottomPanel->setMinimumResize(static_cast(containerSize.height() * 0.25)); - } - - void InsightWindow::adjustMinimumSize() { - static const auto absoluteMinimum = QSize(900, 400); - - /* - * On X11, the QScreen::availableGeometry() function may return the full geometry of the screen, without - * accounting for reserved areas for window managers and other decorations. - * - * Because of this, we always use QScreen::geometry() and account for reserved areas ourselves. It's near - * impossible to do this accurately, so we just subtract 200 from the width and height, and hope that it's - * enough. - */ - const auto screenSize = this->screen()->availableGeometry().size(); - const auto absoluteMaximum = QSize(screenSize.width() - 200, screenSize.height() - 200); - - auto minSize = QSize(); - - if (this->targetPackageWidget != nullptr) { - minSize.setWidth(this->targetPackageWidget->width() + 250); - minSize.setHeight(this->targetPackageWidget->height() + 150); - } - - if (this->leftPanel->isVisible()) { - minSize.setWidth(minSize.width() + this->leftPanel->getMinimumResize()); - } - - if (this->bottomPanel->isVisible()) { - minSize.setHeight(minSize.height() + this->bottomPanel->getMinimumResize()); - } - - this->setMinimumSize( - std::min(std::max(minSize.width(), absoluteMinimum.width()), absoluteMaximum.width()), - std::min(std::max(minSize.height(), absoluteMinimum.height()), absoluteMaximum.height()) - ); - } - - void InsightWindow::onTargetStateUpdate(TargetState newState) { - this->targetState = newState; - - if (newState == TargetState::RUNNING) { - this->targetStatusLabel->setText("Running"); - this->programCounterValueLabel->setText("-"); - this->setUiDisabled(true); - - if (this->targetPackageWidget != nullptr) { - this->targetPackageWidget->setDisabled(true); - } - - } else if (newState == TargetState::STOPPED) { - this->targetStatusLabel->setText("Stopped"); - this->refresh(); } else { - this->targetStatusLabel->setText("Unknown"); - this->programCounterValueLabel->setText("-"); + variantAction->setEnabled(false); + variantAction->setText(variantAction->text() + " (unsupported)"); + } + + this->variantMenu->addAction(variantAction); + processedVariants.push_back(targetVariant); + } +} + +void InsightWindow::selectDefaultVariant() { + if (this->supportedVariantsByName.empty()) { + return; + } + + std::optional previouslySelectedVariantName = (this->previouslySelectedVariant.has_value()) + ? std::optional(QString::fromStdString(this->previouslySelectedVariant->name).toLower()) + : std::nullopt; + + if (previouslySelectedVariantName.has_value()) { + const auto previouslySelectedVariantIt = this->supportedVariantsByName.find(*previouslySelectedVariantName); + + if (previouslySelectedVariantIt != this->supportedVariantsByName.end()) { + this->selectVariant(&(previouslySelectedVariantIt->second)); + return; } } + if (this->targetConfig.variantName.has_value()) { + const auto variantIt = this->supportedVariantsByName.find( + QString::fromStdString(*this->targetConfig.variantName) + ); - void InsightWindow::refresh() { - if (this->targetState != TargetState::STOPPED || this->selectedVariant == nullptr) { - return; + if (variantIt != this->supportedVariantsByName.end()) { + // The user has specified a valid variant name in their config file, so use that as the default + this->selectVariant(&(variantIt->second)); + + } else { + Logger::error( + "Invalid target variant name \"" + this->targetConfig.variantName.value() + + "\" - no such variant with the given name was found." + ); } + } - this->refreshIoInspectionButton->startSpin(); - this->refreshIoInspectionButton->setDisabled(true); + /* + * Given that we haven't been able to select a variant at this point, we will just fall back to the first + * one that is available. + */ + this->selectVariant(&(this->supportedVariantsByName.begin()->second)); +} - if (this->targetPackageWidget != nullptr) { +void InsightWindow::selectVariant(const TargetVariant* variant) { + if (!this->isVariantSupported(*variant)) { + Logger::error("Attempted to select unsupported target variant."); + return; + } + + if (this->selectedVariant != nullptr && this->selectedVariant->id == variant->id) { + // The variant is already selected. + return; + } + + if (this->targetPackageWidget != nullptr) { + this->targetPackageWidget->hide(); + this->targetPackageWidget->deleteLater(); + this->targetPackageWidget = nullptr; + this->ioContainerWidget->setPackageWidget(this->targetPackageWidget); + } + + this->selectedVariant = variant; + this->variantMenu->setTitle(QString::fromStdString(variant->name + " (" + variant->packageName + ")")); + + if ( + variant->package == TargetPackage::DIP + || variant->package == TargetPackage::SOIC + || variant->package == TargetPackage::SSOP + ) { + this->targetPackageWidget = new InsightTargetWidgets::Dip::DualInlinePackageWidget( + *variant, + this->ioContainerWidget + ); + + } else if (variant->package == TargetPackage::QFP || variant->package == TargetPackage::QFN) { + this->targetPackageWidget = new InsightTargetWidgets::Qfp::QuadFlatPackageWidget( + *variant, + this->ioContainerWidget + ); + } + + if (this->targetPackageWidget != nullptr) { + this->ioContainerWidget->setPackageWidget(this->targetPackageWidget); + this->targetPackageWidget->setTargetState(this->targetState); + + if (this->targetState == TargetState::STOPPED) { this->refreshPinStates(); } - if (this->targetRegistersSidePane != nullptr && this->targetRegistersSidePane->state.activated) { - this->targetRegistersSidePane->refreshRegisterValues(); - } - - this->refreshProgramCounter([this] { - this->refreshIoInspectionButton->stopSpin(); - - if (this->targetState == TargetState::STOPPED) { - this->refreshIoInspectionButton->setDisabled(false); - } - }); - } - - void InsightWindow::refreshPinStates() { - this->targetPackageWidget->setDisabled(true); - - this->targetPackageWidget->refreshPinStates([this] { - if (this->targetState == TargetState::STOPPED) { - this->targetPackageWidget->setDisabled(false); - } - }); - } - - void InsightWindow::refreshProgramCounter(std::optional> callback) { - const auto readProgramCounterTask = QSharedPointer( - new ReadProgramCounter(), - &QObject::deleteLater - ); - - QObject::connect( - readProgramCounterTask.get(), - &ReadProgramCounter::programCounterRead, - this, - [this] (Targets::TargetProgramCounter programCounter) { - this->programCounterValueLabel->setText( - "0x" + QString::number(programCounter, 16).toUpper() + " (" + QString::number(programCounter) + ")" - ); - } - ); - - if (callback.has_value()) { - QObject::connect( - readProgramCounterTask.get(), - &ReadProgramCounter::finished, - this, - callback.value() - ); - } - - InsightWorker::queueTask(readProgramCounterTask); - } - - void InsightWindow::openReportIssuesUrl() { - auto url = QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/report-issue")); - /* - * The https://bloom.oscillate.io/report-issue URL just redirects to the Bloom GitHub issue page. - * - * We can use query parameters in the URL to pre-fill the body of the issue. We use this to include some - * target information. - */ - auto urlQuery = QUrlQuery(); - auto issueBody = QString("Issue reported via Bloom Insight.\nTarget name: " - + QString::fromStdString(this->targetDescriptor.name) + "\n" - + "Target ID: " + QString::fromStdString(this->targetDescriptor.id) + "\n" - ); - - if (this->selectedVariant != nullptr) { - issueBody += "Target variant: " + QString::fromStdString(this->selectedVariant->name) + "\n"; - } - - issueBody += "\nPlease describe your issue below. Include as much detail as possible."; - urlQuery.addQueryItem("body", issueBody); - url.setQuery(urlQuery); - - QDesktopServices::openUrl(url); - } - - void InsightWindow::openGettingStartedUrl() { - QDesktopServices::openUrl( - QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/docs/getting-started")) - ); - } - - void InsightWindow::openAboutWindow() { - if (this->aboutWindowWidget == nullptr) { - this->aboutWindowWidget = new AboutWindow(this); - } - - this->aboutWindowWidget->show(); - } - - void InsightWindow::toggleTargetRegistersPane() { - if (this->targetRegistersSidePane->state.activated) { - this->targetRegistersSidePane->deactivate(); - - } else { - this->targetRegistersSidePane->activate(); - } - } - - void InsightWindow::toggleRamInspectionPane() { - if (this->ramInspectionPane->state.activated) { - if (!this->ramInspectionPane->state.attached) { - this->ramInspectionPane->activateWindow(); - this->ramInspectionButton->setChecked(true); - - return; - } - - this->ramInspectionPane->deactivate(); - return; - } - - if (this->ramInspectionPane->state.attached) { - if ( - this->eepromInspectionPane != nullptr - && this->eepromInspectionPane->state.activated - && this->eepromInspectionPane->state.attached - ) { - this->eepromInspectionPane->deactivate(); - } - - if ( - this->flashInspectionPane != nullptr - && this->flashInspectionPane->state.activated - && this->flashInspectionPane->state.attached - ) { - this->flashInspectionPane->deactivate(); - } - } - - this->ramInspectionPane->activate(); - } - - void InsightWindow::toggleEepromInspectionPane() { - if (this->eepromInspectionPane->state.activated) { - if (!this->eepromInspectionPane->state.attached) { - this->eepromInspectionPane->activateWindow(); - this->eepromInspectionButton->setChecked(true); - - return; - } - - this->eepromInspectionPane->deactivate(); - return; - } - - if (this->eepromInspectionPane->state.attached) { - if ( - this->ramInspectionPane != nullptr - && this->ramInspectionPane->state.activated - && this->ramInspectionPane->state.attached - ) { - this->ramInspectionPane->deactivate(); - } - - if ( - this->flashInspectionPane != nullptr - && this->flashInspectionPane->state.activated - && this->flashInspectionPane->state.attached - ) { - this->flashInspectionPane->deactivate(); - } - } - - this->eepromInspectionPane->activate(); - } - - void InsightWindow::toggleFlashInspectionPane() { - if (this->flashInspectionPane->state.activated) { - if (!this->flashInspectionPane->state.attached) { - this->flashInspectionPane->activateWindow(); - this->flashInspectionButton->setChecked(true); - - return; - } - - this->flashInspectionPane->deactivate(); - return; - } - - if (this->flashInspectionPane->state.attached) { - if ( - this->ramInspectionPane != nullptr - && this->ramInspectionPane->state.activated - && this->ramInspectionPane->state.attached - ) { - this->ramInspectionPane->deactivate(); - } - - if ( - this->eepromInspectionPane != nullptr - && this->eepromInspectionPane->state.activated - && this->eepromInspectionPane->state.attached - ) { - this->eepromInspectionPane->deactivate(); - } - } - - this->flashInspectionPane->activate(); - } - - void InsightWindow::onRegistersPaneStateChanged() { - this->targetRegistersButton->setChecked(this->targetRegistersSidePane->state.activated); - - if (this->targetState == Targets::TargetState::STOPPED && this->targetRegistersSidePane->state.activated) { - this->targetRegistersSidePane->refreshRegisterValues(); - } - } - - void InsightWindow::onRamInspectionPaneStateChanged() { - this->ramInspectionButton->setChecked(this->ramInspectionPane->state.activated); - - if (this->ramInspectionPane->state.activated && this->ramInspectionPane->state.attached) { - if ( - this->eepromInspectionPane != nullptr - && this->eepromInspectionPane->state.activated - && this->eepromInspectionPane->state.attached - ) { - this->eepromInspectionPane->deactivate(); - } - - if ( - this->flashInspectionPane != nullptr - && this->flashInspectionPane->state.activated - && this->flashInspectionPane->state.attached - ) { - this->flashInspectionPane->deactivate(); - } - } - } - - void InsightWindow::onEepromInspectionPaneStateChanged() { - this->eepromInspectionButton->setChecked(this->eepromInspectionPane->state.activated); - - if (this->eepromInspectionPane->state.activated && this->eepromInspectionPane->state.attached) { - if ( - this->ramInspectionPane != nullptr - && this->ramInspectionPane->state.activated - && this->ramInspectionPane->state.attached - ) { - this->ramInspectionPane->deactivate(); - } - - if ( - this->flashInspectionPane != nullptr - && this->flashInspectionPane->state.activated - && this->flashInspectionPane->state.attached - ) { - this->flashInspectionPane->deactivate(); - } - } - } - - void InsightWindow::onFlashInspectionPaneStateChanged() { - this->flashInspectionButton->setChecked(this->flashInspectionPane->state.activated); - - if (this->flashInspectionPane->state.activated && this->flashInspectionPane->state.attached) { - if ( - this->ramInspectionPane != nullptr - && this->ramInspectionPane->state.activated - && this->ramInspectionPane->state.attached - ) { - this->ramInspectionPane->deactivate(); - } - - if ( - this->eepromInspectionPane != nullptr - && this->eepromInspectionPane->state.activated - && this->eepromInspectionPane->state.attached - ) { - this->eepromInspectionPane->deactivate(); - } - - } - } - - void InsightWindow::onProgrammingModeEnabled() { - this->targetStatusLabel->setText("Programming Mode Enabled"); - this->programCounterValueLabel->setText("-"); - } - - void InsightWindow::onProgrammingModeDisabled() { - this->onTargetStateUpdate(this->targetState); + this->adjustPanels(); + this->adjustMinimumSize(); + this->targetPackageWidget->show(); } } + +void InsightWindow::createPanes() { + // Target registers pane + if (!this->insightProjectSettings.registersPaneState.has_value()) { + this->insightProjectSettings.registersPaneState = PaneState(false, true, std::nullopt); + } + + auto* leftPanelLayout = this->leftPanel->layout(); + this->targetRegistersSidePane = new TargetRegistersPaneWidget( + this->targetDescriptor, + *(this->insightProjectSettings.registersPaneState), + this->leftPanel + ); + leftPanelLayout->addWidget(this->targetRegistersSidePane); + + QObject::connect( + this->targetRegistersSidePane, + &PaneWidget::paneActivated, + this, + &InsightWindow::onRegistersPaneStateChanged + ); + QObject::connect( + this->targetRegistersSidePane, + &PaneWidget::paneDeactivated, + this, + &InsightWindow::onRegistersPaneStateChanged + ); + + this->targetRegistersButton->setDisabled(false); + this->onRegistersPaneStateChanged(); + + auto& memoryInspectionPaneSettingsByMemoryType = + this->insightProjectSettings.memoryInspectionPaneSettingsByMemoryType; + + // Target memory inspection panes + auto* bottomPanelLayout = this->bottomPanel->layout(); + + const auto ramDescriptorIt = this->targetDescriptor.memoryDescriptorsByType.find(TargetMemoryType::RAM); + const auto eepromDescriptorIt = this->targetDescriptor.memoryDescriptorsByType.find(TargetMemoryType::EEPROM); + const auto flashDescriptorIt = this->targetDescriptor.memoryDescriptorsByType.find(TargetMemoryType::FLASH); + + if (ramDescriptorIt != this->targetDescriptor.memoryDescriptorsByType.end()) { + if (!this->insightProjectSettings.ramInspectionPaneState.has_value()) { + this->insightProjectSettings.ramInspectionPaneState = PaneState(false, true, std::nullopt); + } + + if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::RAM)) { + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM] = TargetMemoryInspectionPaneSettings(); + } + + this->ramInspectionPane = new TargetMemoryInspectionPane( + ramDescriptorIt->second, + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM], + *(this->insightProjectSettings.ramInspectionPaneState), + this->bottomPanel + ); + + bottomPanelLayout->addWidget(this->ramInspectionPane); + + QObject::connect( + this->ramInspectionPane, + &PaneWidget::paneActivated, + this, + &InsightWindow::onRamInspectionPaneStateChanged + ); + QObject::connect( + this->ramInspectionPane, + &PaneWidget::paneDeactivated, + this, + &InsightWindow::onRamInspectionPaneStateChanged + ); + QObject::connect( + this->ramInspectionPane, + &PaneWidget::paneAttached, + this, + &InsightWindow::onRamInspectionPaneStateChanged + ); + + this->ramInspectionButton->setDisabled(false); + this->onRamInspectionPaneStateChanged(); + } + + if (eepromDescriptorIt != this->targetDescriptor.memoryDescriptorsByType.end()) { + if (!this->insightProjectSettings.eepromInspectionPaneState.has_value()) { + this->insightProjectSettings.eepromInspectionPaneState = PaneState(false, true, std::nullopt); + } + + if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::EEPROM)) { + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM] = TargetMemoryInspectionPaneSettings(); + } + + this->eepromInspectionPane = new TargetMemoryInspectionPane( + eepromDescriptorIt->second, + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM], + *(this->insightProjectSettings.eepromInspectionPaneState), + this->bottomPanel + ); + + bottomPanelLayout->addWidget(this->eepromInspectionPane); + + QObject::connect( + this->eepromInspectionPane, + &PaneWidget::paneActivated, + this, + &InsightWindow::onEepromInspectionPaneStateChanged + ); + QObject::connect( + this->eepromInspectionPane, + &PaneWidget::paneDeactivated, + this, + &InsightWindow::onEepromInspectionPaneStateChanged + ); + QObject::connect( + this->eepromInspectionPane, + &PaneWidget::paneAttached, + this, + &InsightWindow::onEepromInspectionPaneStateChanged + ); + + this->eepromInspectionButton->setDisabled(false); + this->onEepromInspectionPaneStateChanged(); + } + + if (flashDescriptorIt != this->targetDescriptor.memoryDescriptorsByType.end()) { + if (!this->insightProjectSettings.flashInspectionPaneState.has_value()) { + this->insightProjectSettings.flashInspectionPaneState = PaneState(false, true, std::nullopt); + } + + if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::FLASH)) { + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::FLASH] = TargetMemoryInspectionPaneSettings(); + } + + this->flashInspectionPane = new TargetMemoryInspectionPane( + flashDescriptorIt->second, + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::FLASH], + *(this->insightProjectSettings.flashInspectionPaneState), + this->bottomPanel + ); + + bottomPanelLayout->addWidget(this->flashInspectionPane); + + QObject::connect( + this->flashInspectionPane, + &PaneWidget::paneActivated, + this, + &InsightWindow::onFlashInspectionPaneStateChanged + ); + QObject::connect( + this->flashInspectionPane, + &PaneWidget::paneDeactivated, + this, + &InsightWindow::onFlashInspectionPaneStateChanged + ); + QObject::connect( + this->flashInspectionPane, + &PaneWidget::paneAttached, + this, + &InsightWindow::onFlashInspectionPaneStateChanged + ); + + this->flashInspectionButton->setDisabled(false); + this->onFlashInspectionPaneStateChanged(); + } +} + +void InsightWindow::adjustPanels() { + const auto targetPackageWidgetSize = (this->targetPackageWidget != nullptr) + ? this->targetPackageWidget->size() : QSize(); + const auto containerSize = this->size(); + + if (!this->isVisible()) { + return; + } + + /* + * The purpose of the -20 is to ensure there is some padding between the panel borders and the + * target package widget. Looks nicer with the padding. + */ + this->leftPanel->setMaximumResize( + std::max( + this->leftPanel->getMinimumResize(), + containerSize.width() - targetPackageWidgetSize.width() - this->leftMenuBar->width() - 20 + ) + ); + + /* + * Allow the bottom panel to overlap the target package widget (because the target package widget can + * occupy a lot of space and become an annoyance if the bottom panel is restricted too much). + */ + this->bottomPanel->setMaximumResize( + std::max( + this->bottomPanel->getMinimumResize(), + (containerSize.height() / 2) - this->mainMenuBar->height() - this->bottomMenuBar->height() - 20 + ) + ); + + this->bottomPanel->setMinimumResize(static_cast(containerSize.height() * 0.25)); +} + +void InsightWindow::adjustMinimumSize() { + static const auto absoluteMinimum = QSize(900, 400); + + /* + * On X11, the QScreen::availableGeometry() function may return the full geometry of the screen, without + * accounting for reserved areas for window managers and other decorations. + * + * Because of this, we always use QScreen::geometry() and account for reserved areas ourselves. It's near + * impossible to do this accurately, so we just subtract 200 from the width and height, and hope that it's + * enough. + */ + const auto screenSize = this->screen()->availableGeometry().size(); + const auto absoluteMaximum = QSize(screenSize.width() - 200, screenSize.height() - 200); + + auto minSize = QSize(); + + if (this->targetPackageWidget != nullptr) { + minSize.setWidth(this->targetPackageWidget->width() + 250); + minSize.setHeight(this->targetPackageWidget->height() + 150); + } + + if (this->leftPanel->isVisible()) { + minSize.setWidth(minSize.width() + this->leftPanel->getMinimumResize()); + } + + if (this->bottomPanel->isVisible()) { + minSize.setHeight(minSize.height() + this->bottomPanel->getMinimumResize()); + } + + this->setMinimumSize( + std::min(std::max(minSize.width(), absoluteMinimum.width()), absoluteMaximum.width()), + std::min(std::max(minSize.height(), absoluteMinimum.height()), absoluteMaximum.height()) + ); +} + +void InsightWindow::onTargetStateUpdate(TargetState newState) { + this->targetState = newState; + + if (newState == TargetState::RUNNING) { + this->targetStatusLabel->setText("Running"); + this->programCounterValueLabel->setText("-"); + this->setUiDisabled(true); + + if (this->targetPackageWidget != nullptr) { + this->targetPackageWidget->setDisabled(true); + } + + } else if (newState == TargetState::STOPPED) { + this->targetStatusLabel->setText("Stopped"); + this->refresh(); + + } else { + this->targetStatusLabel->setText("Unknown"); + this->programCounterValueLabel->setText("-"); + } +} + + +void InsightWindow::refresh() { + if (this->targetState != TargetState::STOPPED || this->selectedVariant == nullptr) { + return; + } + + this->refreshIoInspectionButton->startSpin(); + this->refreshIoInspectionButton->setDisabled(true); + + if (this->targetPackageWidget != nullptr) { + this->refreshPinStates(); + } + + if (this->targetRegistersSidePane != nullptr && this->targetRegistersSidePane->state.activated) { + this->targetRegistersSidePane->refreshRegisterValues(); + } + + this->refreshProgramCounter([this] { + this->refreshIoInspectionButton->stopSpin(); + + if (this->targetState == TargetState::STOPPED) { + this->refreshIoInspectionButton->setDisabled(false); + } + }); +} + +void InsightWindow::refreshPinStates() { + this->targetPackageWidget->setDisabled(true); + + this->targetPackageWidget->refreshPinStates([this] { + if (this->targetState == TargetState::STOPPED) { + this->targetPackageWidget->setDisabled(false); + } + }); +} + +void InsightWindow::refreshProgramCounter(std::optional> callback) { + const auto readProgramCounterTask = QSharedPointer( + new ReadProgramCounter(), + &QObject::deleteLater + ); + + QObject::connect( + readProgramCounterTask.get(), + &ReadProgramCounter::programCounterRead, + this, + [this] (Targets::TargetProgramCounter programCounter) { + this->programCounterValueLabel->setText( + "0x" + QString::number(programCounter, 16).toUpper() + " (" + QString::number(programCounter) + ")" + ); + } + ); + + if (callback.has_value()) { + QObject::connect( + readProgramCounterTask.get(), + &ReadProgramCounter::finished, + this, + callback.value() + ); + } + + InsightWorker::queueTask(readProgramCounterTask); +} + +void InsightWindow::openReportIssuesUrl() { + auto url = QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/report-issue")); + /* + * The https://bloom.oscillate.io/report-issue URL just redirects to the Bloom GitHub issue page. + * + * We can use query parameters in the URL to pre-fill the body of the issue. We use this to include some + * target information. + */ + auto urlQuery = QUrlQuery(); + auto issueBody = QString("Issue reported via Bloom Insight.\nTarget name: " + + QString::fromStdString(this->targetDescriptor.name) + "\n" + + "Target ID: " + QString::fromStdString(this->targetDescriptor.id) + "\n" + ); + + if (this->selectedVariant != nullptr) { + issueBody += "Target variant: " + QString::fromStdString(this->selectedVariant->name) + "\n"; + } + + issueBody += "\nPlease describe your issue below. Include as much detail as possible."; + urlQuery.addQueryItem("body", issueBody); + url.setQuery(urlQuery); + + QDesktopServices::openUrl(url); +} + +void InsightWindow::openGettingStartedUrl() { + QDesktopServices::openUrl( + QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/docs/getting-started")) + ); +} + +void InsightWindow::openAboutWindow() { + if (this->aboutWindowWidget == nullptr) { + this->aboutWindowWidget = new AboutWindow(this); + } + + this->aboutWindowWidget->show(); +} + +void InsightWindow::toggleTargetRegistersPane() { + if (this->targetRegistersSidePane->state.activated) { + this->targetRegistersSidePane->deactivate(); + + } else { + this->targetRegistersSidePane->activate(); + } +} + +void InsightWindow::toggleRamInspectionPane() { + if (this->ramInspectionPane->state.activated) { + if (!this->ramInspectionPane->state.attached) { + this->ramInspectionPane->activateWindow(); + this->ramInspectionButton->setChecked(true); + + return; + } + + this->ramInspectionPane->deactivate(); + return; + } + + if (this->ramInspectionPane->state.attached) { + if ( + this->eepromInspectionPane != nullptr + && this->eepromInspectionPane->state.activated + && this->eepromInspectionPane->state.attached + ) { + this->eepromInspectionPane->deactivate(); + } + + if ( + this->flashInspectionPane != nullptr + && this->flashInspectionPane->state.activated + && this->flashInspectionPane->state.attached + ) { + this->flashInspectionPane->deactivate(); + } + } + + this->ramInspectionPane->activate(); +} + +void InsightWindow::toggleEepromInspectionPane() { + if (this->eepromInspectionPane->state.activated) { + if (!this->eepromInspectionPane->state.attached) { + this->eepromInspectionPane->activateWindow(); + this->eepromInspectionButton->setChecked(true); + + return; + } + + this->eepromInspectionPane->deactivate(); + return; + } + + if (this->eepromInspectionPane->state.attached) { + if ( + this->ramInspectionPane != nullptr + && this->ramInspectionPane->state.activated + && this->ramInspectionPane->state.attached + ) { + this->ramInspectionPane->deactivate(); + } + + if ( + this->flashInspectionPane != nullptr + && this->flashInspectionPane->state.activated + && this->flashInspectionPane->state.attached + ) { + this->flashInspectionPane->deactivate(); + } + } + + this->eepromInspectionPane->activate(); +} + +void InsightWindow::toggleFlashInspectionPane() { + if (this->flashInspectionPane->state.activated) { + if (!this->flashInspectionPane->state.attached) { + this->flashInspectionPane->activateWindow(); + this->flashInspectionButton->setChecked(true); + + return; + } + + this->flashInspectionPane->deactivate(); + return; + } + + if (this->flashInspectionPane->state.attached) { + if ( + this->ramInspectionPane != nullptr + && this->ramInspectionPane->state.activated + && this->ramInspectionPane->state.attached + ) { + this->ramInspectionPane->deactivate(); + } + + if ( + this->eepromInspectionPane != nullptr + && this->eepromInspectionPane->state.activated + && this->eepromInspectionPane->state.attached + ) { + this->eepromInspectionPane->deactivate(); + } + } + + this->flashInspectionPane->activate(); +} + +void InsightWindow::onRegistersPaneStateChanged() { + this->targetRegistersButton->setChecked(this->targetRegistersSidePane->state.activated); + + if (this->targetState == Targets::TargetState::STOPPED && this->targetRegistersSidePane->state.activated) { + this->targetRegistersSidePane->refreshRegisterValues(); + } +} + +void InsightWindow::onRamInspectionPaneStateChanged() { + this->ramInspectionButton->setChecked(this->ramInspectionPane->state.activated); + + if (this->ramInspectionPane->state.activated && this->ramInspectionPane->state.attached) { + if ( + this->eepromInspectionPane != nullptr + && this->eepromInspectionPane->state.activated + && this->eepromInspectionPane->state.attached + ) { + this->eepromInspectionPane->deactivate(); + } + + if ( + this->flashInspectionPane != nullptr + && this->flashInspectionPane->state.activated + && this->flashInspectionPane->state.attached + ) { + this->flashInspectionPane->deactivate(); + } + } +} + +void InsightWindow::onEepromInspectionPaneStateChanged() { + this->eepromInspectionButton->setChecked(this->eepromInspectionPane->state.activated); + + if (this->eepromInspectionPane->state.activated && this->eepromInspectionPane->state.attached) { + if ( + this->ramInspectionPane != nullptr + && this->ramInspectionPane->state.activated + && this->ramInspectionPane->state.attached + ) { + this->ramInspectionPane->deactivate(); + } + + if ( + this->flashInspectionPane != nullptr + && this->flashInspectionPane->state.activated + && this->flashInspectionPane->state.attached + ) { + this->flashInspectionPane->deactivate(); + } + } +} + +void InsightWindow::onFlashInspectionPaneStateChanged() { + this->flashInspectionButton->setChecked(this->flashInspectionPane->state.activated); + + if (this->flashInspectionPane->state.activated && this->flashInspectionPane->state.attached) { + if ( + this->ramInspectionPane != nullptr + && this->ramInspectionPane->state.activated + && this->ramInspectionPane->state.attached + ) { + this->ramInspectionPane->deactivate(); + } + + if ( + this->eepromInspectionPane != nullptr + && this->eepromInspectionPane->state.activated + && this->eepromInspectionPane->state.attached + ) { + this->eepromInspectionPane->deactivate(); + } + + } +} + +void InsightWindow::onProgrammingModeEnabled() { + this->targetStatusLabel->setText("Programming Mode Enabled"); + this->programCounterValueLabel->setText("-"); +} + +void InsightWindow::onProgrammingModeDisabled() { + this->onTargetStateUpdate(this->targetState); +} diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp index 45655dd2..c8b2fea7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp @@ -25,107 +25,104 @@ #include "Widgets/TaskIndicator/TaskIndicator.hpp" #include "AboutWindow.hpp" -namespace Bloom +class InsightWindow: public QMainWindow { - class InsightWindow: public QMainWindow - { - Q_OBJECT + Q_OBJECT - public: - InsightWindow( - const EnvironmentConfig& environmentConfig, - const InsightConfig& insightConfig, - InsightProjectSettings& insightProjectSettings, - const Targets::TargetDescriptor& targetDescriptor - ); +public: + InsightWindow( + const EnvironmentConfig& environmentConfig, + const InsightConfig& insightConfig, + InsightProjectSettings& insightProjectSettings, + const Targets::TargetDescriptor& targetDescriptor + ); - protected: - void resizeEvent(QResizeEvent* event) override; - void showEvent(QShowEvent* event) override; - void closeEvent(QCloseEvent* event) override; +protected: + void resizeEvent(QResizeEvent* event) override; + void showEvent(QShowEvent* event) override; + void closeEvent(QCloseEvent* event) override; - private: - InsightProjectSettings& insightProjectSettings; +private: + InsightProjectSettings& insightProjectSettings; - InsightConfig insightConfig; - EnvironmentConfig environmentConfig; - TargetConfig targetConfig; + InsightConfig insightConfig; + EnvironmentConfig environmentConfig; + TargetConfig targetConfig; - const Targets::TargetDescriptor& targetDescriptor; - Targets::TargetState targetState = Targets::TargetState::UNKNOWN; + const Targets::TargetDescriptor& targetDescriptor; + Targets::TargetState targetState = Targets::TargetState::UNKNOWN; - QWidget* windowContainer = nullptr; - QMenuBar* mainMenuBar = nullptr; - QWidget* layoutContainer = nullptr; - QWidget* container = nullptr; - QMenu* variantMenu = nullptr; - Widgets::Label* targetNameLabel = nullptr; - Widgets::Label* targetIdLabel = nullptr; - AboutWindow* aboutWindowWidget = nullptr; + QWidget* windowContainer = nullptr; + QMenuBar* mainMenuBar = nullptr; + QWidget* layoutContainer = nullptr; + QWidget* container = nullptr; + QMenu* variantMenu = nullptr; + Widgets::Label* targetNameLabel = nullptr; + Widgets::Label* targetIdLabel = nullptr; + AboutWindow* aboutWindowWidget = nullptr; - QWidget* header = nullptr; - Widgets::SvgToolButton* refreshIoInspectionButton = nullptr; + QWidget* header = nullptr; + Widgets::SvgToolButton* refreshIoInspectionButton = nullptr; - QWidget* leftMenuBar = nullptr; - Widgets::PanelWidget* leftPanel = nullptr; - Widgets::TargetRegistersPaneWidget* targetRegistersSidePane = nullptr; - QToolButton* targetRegistersButton = nullptr; + QWidget* leftMenuBar = nullptr; + Widgets::PanelWidget* leftPanel = nullptr; + Widgets::TargetRegistersPaneWidget* targetRegistersSidePane = nullptr; + QToolButton* targetRegistersButton = nullptr; - Widgets::Label* ioUnavailableWidget = nullptr; - Widgets::InsightTargetWidgets::TargetPackageWidgetContainer* ioContainerWidget = nullptr; - Widgets::InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr; + Widgets::Label* ioUnavailableWidget = nullptr; + Widgets::InsightTargetWidgets::TargetPackageWidgetContainer* ioContainerWidget = nullptr; + Widgets::InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr; - QWidget* bottomMenuBar = nullptr; - Widgets::PanelWidget* bottomPanel = nullptr; - Widgets::TargetMemoryInspectionPane* ramInspectionPane = nullptr; - Widgets::TargetMemoryInspectionPane* eepromInspectionPane = nullptr; - Widgets::TargetMemoryInspectionPane* flashInspectionPane = nullptr; - std::map< - Targets::TargetMemoryType, - Widgets::TargetMemoryInspectionPaneSettings - > memoryInspectionPaneSettingsByMemoryType; - QToolButton* ramInspectionButton = nullptr; - QToolButton* eepromInspectionButton = nullptr; - QToolButton* flashInspectionButton = nullptr; + QWidget* bottomMenuBar = nullptr; + Widgets::PanelWidget* bottomPanel = nullptr; + Widgets::TargetMemoryInspectionPane* ramInspectionPane = nullptr; + Widgets::TargetMemoryInspectionPane* eepromInspectionPane = nullptr; + Widgets::TargetMemoryInspectionPane* flashInspectionPane = nullptr; + std::map< + Targets::TargetMemoryType, + Widgets::TargetMemoryInspectionPaneSettings + > memoryInspectionPaneSettingsByMemoryType; + QToolButton* ramInspectionButton = nullptr; + QToolButton* eepromInspectionButton = nullptr; + QToolButton* flashInspectionButton = nullptr; - QWidget* footer = nullptr; - Widgets::Label* targetStatusLabel = nullptr; - Widgets::Label* programCounterValueLabel = nullptr; - Widgets::TaskIndicator* taskIndicator = nullptr; + QWidget* footer = nullptr; + Widgets::Label* targetStatusLabel = nullptr; + Widgets::Label* programCounterValueLabel = nullptr; + Widgets::TaskIndicator* taskIndicator = nullptr; - std::map supportedVariantsByName; - const Targets::TargetVariant* selectedVariant = nullptr; - std::optional previouslySelectedVariant; - bool uiDisabled = false; + std::map supportedVariantsByName; + const Targets::TargetVariant* selectedVariant = nullptr; + std::optional previouslySelectedVariant; + bool uiDisabled = false; - static bool isVariantSupported(const Targets::TargetVariant& variant); + static bool isVariantSupported(const Targets::TargetVariant& variant); - void setUiDisabled(bool disable); + void setUiDisabled(bool disable); - void populateVariantMenu(); - void selectDefaultVariant(); - void selectVariant(const Targets::TargetVariant* variant); - void createPanes(); + void populateVariantMenu(); + void selectDefaultVariant(); + void selectVariant(const Targets::TargetVariant* variant); + void createPanes(); - void adjustPanels(); - void adjustMinimumSize(); + void adjustPanels(); + void adjustMinimumSize(); - void onTargetStateUpdate(Targets::TargetState newState); - void refresh(); - void refreshPinStates(); - void refreshProgramCounter(std::optional> callback = std::nullopt); - void openReportIssuesUrl(); - void openGettingStartedUrl(); - void openAboutWindow(); - void toggleTargetRegistersPane(); - void toggleRamInspectionPane(); - void toggleEepromInspectionPane(); - void toggleFlashInspectionPane(); - void onRegistersPaneStateChanged(); - void onRamInspectionPaneStateChanged(); - void onEepromInspectionPaneStateChanged(); - void onFlashInspectionPaneStateChanged(); - void onProgrammingModeEnabled(); - void onProgrammingModeDisabled(); - }; -} + void onTargetStateUpdate(Targets::TargetState newState); + void refresh(); + void refreshPinStates(); + void refreshProgramCounter(std::optional> callback = std::nullopt); + void openReportIssuesUrl(); + void openGettingStartedUrl(); + void openAboutWindow(); + void toggleTargetRegistersPane(); + void toggleRamInspectionPane(); + void toggleEepromInspectionPane(); + void toggleFlashInspectionPane(); + void onRegistersPaneStateChanged(); + void onRamInspectionPaneStateChanged(); + void onEepromInspectionPaneStateChanged(); + void onFlashInspectionPaneStateChanged(); + void onProgrammingModeEnabled(); + void onProgrammingModeDisabled(); +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp b/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp index 1031a288..edf6b799 100644 --- a/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp @@ -14,113 +14,110 @@ #include "Widgets/ExpandingHeightScrollAreaWidget.hpp" #include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp" -namespace Bloom -{ - using namespace Bloom::Widgets; +using namespace Widgets; - UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { - this->customWidgetConstructorsByWidgetName = { - { - "Label", - [this] (QWidget* parent, const QString& name) { - auto* widget = new Label(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "RotatableLabel", - [this] (QWidget* parent, const QString& name) { - auto* widget = new RotatableLabel("", parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "LabeledSeparator", - [this] (QWidget* parent, const QString& name) { - auto* widget = new LabeledSeparator(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "TextInput", - [this] (QWidget* parent, const QString& name) { - auto* widget = new TextInput(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "PlainTextEdit", - [this] (QWidget* parent, const QString& name) { - auto* widget = new PlainTextEdit(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "PushButton", - [this] (QWidget* parent, const QString& name) { - auto* widget = new PushButton(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "ExpandingHeightScrollAreaWidget", - [this] (QWidget* parent, const QString& name) { - auto* widget = new ExpandingHeightScrollAreaWidget(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "SvgWidget", - [this] (QWidget* parent, const QString& name) { - auto* widget = new SvgWidget(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "SvgToolButton", - [this] (QWidget* parent, const QString& name) { - auto* widget = new SvgToolButton(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - { - "TargetPackageWidgetContainer", - [this] (QWidget* parent, const QString& name) { - auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent); - widget->setObjectName(name); - widget->setStyleSheet(parent->styleSheet()); - return widget; - } - }, - }; - } - - QWidget* UiLoader::createWidget(const QString& className, QWidget* parent, const QString& name) { - const auto widgetConstructorIt = this->customWidgetConstructorsByWidgetName.find(className); - - if (widgetConstructorIt != this->customWidgetConstructorsByWidgetName.end()) { - // This is a custom widget - call the mapped constructor - return widgetConstructorIt->second(parent, name); - } - - return QUiLoader::createWidget(className, parent, name); - } +UiLoader::UiLoader(QObject* parent): QUiLoader(parent) { + this->customWidgetConstructorsByWidgetName = { + { + "Label", + [this] (QWidget* parent, const QString& name) { + auto* widget = new Label(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "RotatableLabel", + [this] (QWidget* parent, const QString& name) { + auto* widget = new RotatableLabel("", parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "LabeledSeparator", + [this] (QWidget* parent, const QString& name) { + auto* widget = new LabeledSeparator(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "TextInput", + [this] (QWidget* parent, const QString& name) { + auto* widget = new TextInput(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "PlainTextEdit", + [this] (QWidget* parent, const QString& name) { + auto* widget = new PlainTextEdit(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "PushButton", + [this] (QWidget* parent, const QString& name) { + auto* widget = new PushButton(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "ExpandingHeightScrollAreaWidget", + [this] (QWidget* parent, const QString& name) { + auto* widget = new ExpandingHeightScrollAreaWidget(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "SvgWidget", + [this] (QWidget* parent, const QString& name) { + auto* widget = new SvgWidget(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "SvgToolButton", + [this] (QWidget* parent, const QString& name) { + auto* widget = new SvgToolButton(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + { + "TargetPackageWidgetContainer", + [this] (QWidget* parent, const QString& name) { + auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent); + widget->setObjectName(name); + widget->setStyleSheet(parent->styleSheet()); + return widget; + } + }, + }; +} + +QWidget* UiLoader::createWidget(const QString& className, QWidget* parent, const QString& name) { + const auto widgetConstructorIt = this->customWidgetConstructorsByWidgetName.find(className); + + if (widgetConstructorIt != this->customWidgetConstructorsByWidgetName.end()) { + // This is a custom widget - call the mapped constructor + return widgetConstructorIt->second(parent, name); + } + + return QUiLoader::createWidget(className, parent, name); } diff --git a/src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp b/src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp index edfd5bc2..0980acaa 100644 --- a/src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp @@ -3,21 +3,18 @@ #include #include -namespace Bloom +class UiLoader: public QUiLoader { - class UiLoader: public QUiLoader - { - Q_OBJECT + Q_OBJECT - public: - explicit UiLoader(QObject* parent); +public: + explicit UiLoader(QObject* parent); - QWidget* createWidget(const QString& className, QWidget* parent, const QString& name) override; + QWidget* createWidget(const QString& className, QWidget* parent, const QString& name) override; - private: - std::map< - QString, - std::function - > customWidgetConstructorsByWidgetName = {}; - }; -} +private: + std::map< + QString, + std::function + > customWidgetConstructorsByWidgetName = {}; +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp index 43be5e14..70d8cb4e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp @@ -1,6 +1,6 @@ #include "ClickableWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { void ClickableWidget::mouseReleaseEvent(QMouseEvent* event) { if (event->button() == Qt::MouseButton::LeftButton) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp index 00fa7e85..ed3b1ba9 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { class ClickableWidget: public QFrame { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.cpp index b6a0db88..1d7a020a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.cpp @@ -1,6 +1,6 @@ #include "ConfirmationDialog.hpp" -namespace Bloom::Widgets +namespace Widgets { ConfirmationDialog::ConfirmationDialog( const QString& windowTitle, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.hpp index da006edc..388a0ff8 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.hpp @@ -6,7 +6,7 @@ #include "Dialog/Dialog.hpp" #include "PushButton.hpp" -namespace Bloom::Widgets +namespace Widgets { class ConfirmationDialog: public Dialog { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Dialog.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Dialog.cpp index 3796095b..cd1b77eb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Dialog.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Dialog.cpp @@ -6,9 +6,9 @@ #include "src/Services/PathService.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Exceptions::Exception; + using Exceptions::Exception; Dialog::Dialog( const QString& windowTitle, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Dialog.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Dialog.hpp index dcbc9ac0..9f8fd45c 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Dialog.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Dialog.hpp @@ -7,7 +7,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp" -namespace Bloom::Widgets +namespace Widgets { class Dialog: public QDialog { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp index fe5dfd59..ea0cd345 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp @@ -7,9 +7,9 @@ #include "src/Services/PathService.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Exceptions::Exception; + using Exceptions::Exception; ErrorDialogue::ErrorDialogue( const QString& windowTitle, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp index e4bc000f..ee3d2c80 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp @@ -6,11 +6,11 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp" -namespace Bloom::Widgets +namespace Widgets { /** * @deprecated - * TODO: Bin this. Replace all usages with Bloom::Widgets::Dialog. + * TODO: Bin this. Replace all usages with Widgets::Dialog. */ class ErrorDialogue: public QDialog { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp index ba70ad3f..eb202bf3 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { class ExpandingHeightScrollAreaWidget: public QScrollArea { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp index 3361ab90..dd04a1f9 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets +namespace Widgets { class Label: public QLabel { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.cpp index 9d77539d..ae071a97 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.cpp @@ -1,6 +1,6 @@ #include "LabeledSeparator.hpp" -namespace Bloom::Widgets +namespace Widgets { LabeledSeparator::LabeledSeparator(QString title, QWidget* parent): title(std::move(title)), QWidget(parent) { this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.hpp index 086540ff..14a57f6a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.hpp @@ -6,7 +6,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { class LabeledSeparator: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListItem.hpp index 387b6d44..ea4ed82d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListItem.hpp @@ -8,7 +8,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { class ListItem: public QGraphicsItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.cpp index 7c82080e..2867777e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.cpp @@ -6,7 +6,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { ListScene::ListScene( ListScene::ListItemSetType&& items, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.hpp index 65b368b5..403a4d37 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.hpp @@ -15,7 +15,7 @@ #include "ListItem.hpp" #include "src/Helpers/DereferenceLessComparator.hpp" -namespace Bloom::Widgets +namespace Widgets { class ListScene: public QGraphicsScene { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.cpp index 20d2b359..3ce34ec4 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.cpp @@ -1,6 +1,6 @@ #include "ListView.hpp" -namespace Bloom::Widgets +namespace Widgets { ListView::ListView( ListScene::ListItemSetType&& items, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.hpp index 6567ab9e..a7a6bd29 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.hpp @@ -7,7 +7,7 @@ #include "ListScene.hpp" #include "ListItem.hpp" -namespace Bloom::Widgets +namespace Widgets { class ListView: public QGraphicsView { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneState.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneState.hpp index a6fd8ed8..e39600b3 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneState.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneState.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { struct DetachedWindowState { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.cpp index 99acd2a6..ed71cc04 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.cpp @@ -1,6 +1,6 @@ #include "PaneWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { PaneWidget::PaneWidget(PaneState& state, PanelWidget* parent) : state(state) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.hpp index b2fe5d6b..2665c63d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.hpp @@ -7,7 +7,7 @@ #include "PanelWidget.hpp" #include "PaneState.hpp" -namespace Bloom::Widgets +namespace Widgets { class PaneWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelState.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelState.hpp index 6d194f70..bb9f41ba 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelState.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelState.hpp @@ -1,6 +1,6 @@ #pragma once -namespace Bloom::Widgets +namespace Widgets { struct PanelState { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp index 59aaaa14..1eff1adf 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp @@ -5,7 +5,7 @@ #include "PaneWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { PanelWidget::PanelWidget(PanelWidgetType type, PanelState& state, QWidget* parent) : panelType(type) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.hpp index 9766b7a7..d3c2c715 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.hpp @@ -9,7 +9,7 @@ #include "PanelState.hpp" -namespace Bloom::Widgets +namespace Widgets { Q_NAMESPACE diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PlainTextEdit.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PlainTextEdit.cpp index 8e40df50..eef9c9e7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PlainTextEdit.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PlainTextEdit.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { PlainTextEdit::PlainTextEdit(QWidget* parent) : QPlainTextEdit(parent) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PlainTextEdit.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PlainTextEdit.hpp index 14327832..9965f600 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PlainTextEdit.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PlainTextEdit.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { class PlainTextEdit: public QPlainTextEdit { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.cpp index 2a90720d..2c227f96 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.cpp @@ -1,6 +1,6 @@ #include "PushButton.hpp" -namespace Bloom::Widgets +namespace Widgets { PushButton::PushButton(QWidget* parent) : QPushButton(parent) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.hpp index 9b0ab138..3018ef08 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { class PushButton: public QPushButton { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp index 6eb276a6..afa905a6 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets +namespace Widgets { void RotatableLabel::paintEvent(QPaintEvent* event) { auto painter = QPainter(this); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.hpp index fbf4f573..8d2e5fdc 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.hpp @@ -4,7 +4,7 @@ #include "Label.hpp" -namespace Bloom::Widgets +namespace Widgets { class RotatableLabel: public Label { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.cpp index 05e9ad0f..4349e891 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.cpp @@ -1,6 +1,6 @@ #include "SvgToolButton.hpp" -namespace Bloom::Widgets +namespace Widgets { SvgToolButton::SvgToolButton(QWidget* parent): QToolButton(parent) { this->setButtonWidth(10); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp index c3bd8a13..25d612e7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp @@ -8,7 +8,7 @@ #include "SvgWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { class SvgToolButton: public QToolButton { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp index 2a0806e2..bcf423cc 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { SvgWidget::SvgWidget(QWidget* parent): QFrame(parent) { this->renderer.setAspectRatioMode(Qt::AspectRatioMode::KeepAspectRatioByExpanding); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp index 5a96b43f..71c390af 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp @@ -7,7 +7,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { class SvgWidget: public QFrame { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp index f850b8ba..85371a66 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp @@ -2,11 +2,8 @@ #include -namespace Bloom +enum class AddressType: std::uint8_t { - enum class AddressType: std::uint8_t - { - ABSOLUTE, - RELATIVE, - }; -} + ABSOLUTE, + RELATIVE, +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.cpp index b39b43cd..870a386d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.cpp @@ -2,21 +2,18 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - ExcludedMemoryRegion::ExcludedMemoryRegion( - const QString& name, - Targets::TargetMemoryType memoryType, - const Targets::TargetMemoryAddressRange& addressRange - ) - : MemoryRegion(name, memoryType, MemoryRegionType::EXCLUDED, addressRange) - {} +ExcludedMemoryRegion::ExcludedMemoryRegion( + const QString& name, + Targets::TargetMemoryType memoryType, + const Targets::TargetMemoryAddressRange& addressRange +) + : MemoryRegion(name, memoryType, MemoryRegionType::EXCLUDED, addressRange) +{} - ExcludedMemoryRegion::ExcludedMemoryRegion(const QJsonObject& jsonObject) - : MemoryRegion(jsonObject) - { - if (this->type != MemoryRegionType::EXCLUDED) { - throw Exceptions::Exception("Invalid memory region type"); - } +ExcludedMemoryRegion::ExcludedMemoryRegion(const QJsonObject& jsonObject) + : MemoryRegion(jsonObject) +{ + if (this->type != MemoryRegionType::EXCLUDED) { + throw Exceptions::Exception("Invalid memory region type"); } } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp index ca6c09a7..ebf8f5a0 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp @@ -2,17 +2,14 @@ #include "MemoryRegion.hpp" -namespace Bloom +class ExcludedMemoryRegion: public MemoryRegion { - class ExcludedMemoryRegion: public MemoryRegion - { - public: - ExcludedMemoryRegion( - const QString& name, - Targets::TargetMemoryType memoryType, - const Targets::TargetMemoryAddressRange& addressRange - ); +public: + ExcludedMemoryRegion( + const QString& name, + Targets::TargetMemoryType memoryType, + const Targets::TargetMemoryAddressRange& addressRange + ); - ExcludedMemoryRegion(const QJsonObject& jsonObject); - }; -} + ExcludedMemoryRegion(const QJsonObject& jsonObject); +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.cpp index 24501013..d7494903 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.cpp @@ -2,38 +2,35 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom +FocusedMemoryRegion::FocusedMemoryRegion( + const QString& name, + Targets::TargetMemoryType memoryType, + const Targets::TargetMemoryAddressRange& addressRange +) + : MemoryRegion(name, memoryType, MemoryRegionType::FOCUSED, addressRange) +{} + +FocusedMemoryRegion::FocusedMemoryRegion(const QJsonObject& jsonObject) + : MemoryRegion(jsonObject) { - FocusedMemoryRegion::FocusedMemoryRegion( - const QString& name, - Targets::TargetMemoryType memoryType, - const Targets::TargetMemoryAddressRange& addressRange - ) - : MemoryRegion(name, memoryType, MemoryRegionType::FOCUSED, addressRange) - {} + using Exceptions::Exception; - FocusedMemoryRegion::FocusedMemoryRegion(const QJsonObject& jsonObject) - : MemoryRegion(jsonObject) - { - using Exceptions::Exception; - - if (this->type != MemoryRegionType::FOCUSED) { - throw Exception("Invalid memory region type"); - } - - if (!jsonObject.contains("dataType") || !jsonObject.contains("endianness")) { - throw Exception("Missing data"); - } - - this->dataType = FocusedMemoryRegion::regionDataTypesByName.at(jsonObject.find("dataType")->toString()); - this->endianness = FocusedMemoryRegion::regionEndiannessByName.at(jsonObject.find("endianness")->toString()); + if (this->type != MemoryRegionType::FOCUSED) { + throw Exception("Invalid memory region type"); } - QJsonObject FocusedMemoryRegion::toJson() const { - auto jsonObject = MemoryRegion::toJson(); - jsonObject.insert("dataType", FocusedMemoryRegion::regionDataTypesByName.at(this->dataType)); - jsonObject.insert("endianness", FocusedMemoryRegion::regionEndiannessByName.at(this->endianness)); - - return jsonObject; + if (!jsonObject.contains("dataType") || !jsonObject.contains("endianness")) { + throw Exception("Missing data"); } + + this->dataType = FocusedMemoryRegion::regionDataTypesByName.at(jsonObject.find("dataType")->toString()); + this->endianness = FocusedMemoryRegion::regionEndiannessByName.at(jsonObject.find("endianness")->toString()); +} + +QJsonObject FocusedMemoryRegion::toJson() const { + auto jsonObject = MemoryRegion::toJson(); + jsonObject.insert("dataType", FocusedMemoryRegion::regionDataTypesByName.at(this->dataType)); + jsonObject.insert("endianness", FocusedMemoryRegion::regionEndiannessByName.at(this->endianness)); + + return jsonObject; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp index c89fd513..a7699ad9 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp @@ -6,43 +6,40 @@ #include "src/Helpers/BiMap.hpp" -namespace Bloom +enum class MemoryRegionDataType: std::uint8_t { - enum class MemoryRegionDataType: std::uint8_t - { - UNKNOWN, - UNSIGNED_INTEGER, - SIGNED_INTEGER, - ASCII_STRING, + UNKNOWN, + UNSIGNED_INTEGER, + SIGNED_INTEGER, + ASCII_STRING, +}; + +class FocusedMemoryRegion: public MemoryRegion +{ +public: + MemoryRegionDataType dataType = MemoryRegionDataType::UNKNOWN; + Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE; + + FocusedMemoryRegion( + const QString& name, + Targets::TargetMemoryType memoryType, + const Targets::TargetMemoryAddressRange& addressRange + ); + + FocusedMemoryRegion(const QJsonObject& jsonObject); + + QJsonObject toJson() const override; + +private: + static const inline BiMap regionDataTypesByName = { + {MemoryRegionDataType::UNKNOWN, "other"}, + {MemoryRegionDataType::UNSIGNED_INTEGER, "unsigned_int"}, + {MemoryRegionDataType::SIGNED_INTEGER, "signed_int"}, + {MemoryRegionDataType::ASCII_STRING, "ascii_string"}, }; - class FocusedMemoryRegion: public MemoryRegion - { - public: - MemoryRegionDataType dataType = MemoryRegionDataType::UNKNOWN; - Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE; - - FocusedMemoryRegion( - const QString& name, - Targets::TargetMemoryType memoryType, - const Targets::TargetMemoryAddressRange& addressRange - ); - - FocusedMemoryRegion(const QJsonObject& jsonObject); - - QJsonObject toJson() const override; - - private: - static const inline BiMap regionDataTypesByName = { - {MemoryRegionDataType::UNKNOWN, "other"}, - {MemoryRegionDataType::UNSIGNED_INTEGER, "unsigned_int"}, - {MemoryRegionDataType::SIGNED_INTEGER, "signed_int"}, - {MemoryRegionDataType::ASCII_STRING, "ascii_string"}, - }; - - static const inline BiMap regionEndiannessByName = { - {Targets::TargetMemoryEndianness::LITTLE, "little"}, - {Targets::TargetMemoryEndianness::BIG, "big"}, - }; + static const inline BiMap regionEndiannessByName = { + {Targets::TargetMemoryEndianness::LITTLE, "little"}, + {Targets::TargetMemoryEndianness::BIG, "big"}, }; -} +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.cpp index 6d39c6a9..5dc00334 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.cpp @@ -1,6 +1,6 @@ #include "ByteAddressContainer.hpp" -namespace Bloom::Widgets +namespace Widgets { ByteAddressContainer::ByteAddressContainer(const HexViewerSharedState& hexViewerState) : hexViewerState(hexViewerState) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp index ed07d3cc..be7acce3 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp @@ -8,7 +8,7 @@ #include "HexViewerSharedState.hpp" #include "ByteAddressItem.hpp" -namespace Bloom::Widgets +namespace Widgets { class ByteAddressContainer: public QGraphicsItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.cpp index e29b7970..9a2df5f8 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.cpp @@ -1,6 +1,6 @@ #include "ByteAddressItem.hpp" -namespace Bloom::Widgets +namespace Widgets { ByteAddressItem::ByteAddressItem(const HexViewerSharedState& hexViewerState, QGraphicsItem* parent) : hexViewerState(hexViewerState) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.hpp index c3826767..da7ffaac 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressItem.hpp @@ -6,7 +6,7 @@ #include "ByteItem.hpp" #include "HexViewerSharedState.hpp" -namespace Bloom::Widgets +namespace Widgets { class ByteAddressItem: public QGraphicsItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp index 2a6aef7d..fd3e2dfd 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp @@ -1,6 +1,6 @@ #include "ByteItem.hpp" -namespace Bloom::Widgets +namespace Widgets { ByteItem::ByteItem(Targets::TargetMemoryAddress address) : HexViewerItem(address) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp index d8043822..006180bc 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp @@ -8,7 +8,7 @@ #include "HexViewerItem.hpp" -namespace Bloom::Widgets +namespace Widgets { #pragma pack(push, 1) class ByteItem: public HexViewerItem diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.cpp index 39e3cce7..b943dea2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.cpp @@ -1,6 +1,6 @@ #include "ContextMenuAction.hpp" -namespace Bloom::Widgets +namespace Widgets { ContextMenuAction::ContextMenuAction( const QString& text, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.hpp index 609f8a41..ca7c9783 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.hpp @@ -9,7 +9,7 @@ #include "src/Targets/TargetMemory.hpp" #include "ByteItem.hpp" -namespace Bloom::Widgets +namespace Widgets { class ContextMenuAction: public QAction { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/FocusedRegionGroupItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/FocusedRegionGroupItem.cpp index b0ecfc70..82a61635 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/FocusedRegionGroupItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/FocusedRegionGroupItem.cpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets +namespace Widgets { FocusedRegionGroupItem::FocusedRegionGroupItem( const FocusedMemoryRegion& focusedRegion, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/FocusedRegionGroupItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/FocusedRegionGroupItem.hpp index 0be15d27..04a5889a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/FocusedRegionGroupItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/FocusedRegionGroupItem.hpp @@ -9,7 +9,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Widgets +namespace Widgets { class FocusedRegionGroupItem: public GroupItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.cpp index 63a7cf27..030d2e56 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.cpp @@ -1,6 +1,6 @@ #include "GroupItem.hpp" -namespace Bloom::Widgets +namespace Widgets { GroupItem::~GroupItem() { for (auto& byteItem : this->items) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.hpp index db95059e..008ce1f3 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/GroupItem.hpp @@ -11,7 +11,7 @@ #include "src/Targets/TargetMemory.hpp" #include "HexViewerSharedState.hpp" -namespace Bloom::Widgets +namespace Widgets { class GroupItem: public HexViewerItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.cpp index 1ea53d60..a5af7e50 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.cpp @@ -1,6 +1,6 @@ #include "HexViewerItem.hpp" -namespace Bloom::Widgets +namespace Widgets { HexViewerItem::HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent) : startAddress(startAddress) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.hpp index 82e3440d..cb3907da 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItem.hpp @@ -7,7 +7,7 @@ #include "src/Targets/TargetMemory.hpp" #include "HexViewerSharedState.hpp" -namespace Bloom::Widgets +namespace Widgets { class GraphicsItem; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemIndex.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemIndex.cpp index 438a4d2e..0883788e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemIndex.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemIndex.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { HexViewerItemIndex::HexViewerItemIndex( const TopLevelGroupItem* topLevelGroupItem, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemIndex.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemIndex.hpp index 62d41d7b..c0b7ca9b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemIndex.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemIndex.hpp @@ -10,7 +10,7 @@ #include "TopLevelGroupItem.hpp" #include "ByteItem.hpp" -namespace Bloom::Widgets +namespace Widgets { /** * This class maintains indices of hex viewer item positions and provides fast lookups for items within certain diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.cpp index 240109bf..c39ac3bf 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { HexViewerItemRenderer::HexViewerItemRenderer( const HexViewerSharedState& hexViewerState, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.hpp index e0ccb71f..56a7559d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.hpp @@ -19,7 +19,7 @@ #include "FocusedRegionGroupItem.hpp" #include "StackMemoryGroupItem.hpp" -namespace Bloom::Widgets +namespace Widgets { /** * Renders hex viewer items in a QGraphicsScene. diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp index de3d966e..19b96295 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp @@ -5,7 +5,7 @@ #include "src/Targets/TargetMemory.hpp" #include "HexViewerWidgetSettings.hpp" -namespace Bloom::Widgets +namespace Widgets { class ByteItem; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp index b531621f..98aa869f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp @@ -10,11 +10,11 @@ #include "src/Services/PathService.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::Widgets +namespace Widgets { - using namespace Bloom::Exceptions; + using namespace Exceptions; - using Bloom::Targets::TargetMemoryDescriptor; + using Targets::TargetMemoryDescriptor; HexViewerWidget::HexViewerWidget( const TargetMemoryDescriptor& targetMemoryDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp index 022ce49f..580358c4 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp @@ -21,7 +21,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp" -namespace Bloom::Widgets +namespace Widgets { class HexViewerWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp index 44fb456f..99a41f14 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidgetSettings.hpp @@ -2,7 +2,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp" -namespace Bloom::Widgets +namespace Widgets { struct HexViewerWidgetSettings { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp index 1475b714..bda747c4 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.cpp @@ -15,7 +15,7 @@ #include "src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp" -namespace Bloom::Widgets +namespace Widgets { ItemGraphicsScene::ItemGraphicsScene( const Targets::TargetMemoryDescriptor& targetMemoryDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.hpp index 6e39ff2a..b73a6a53 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.hpp @@ -37,7 +37,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp" -namespace Bloom::Widgets +namespace Widgets { class ItemGraphicsScene: public QGraphicsScene { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp index 547bb4bf..6ad113aa 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.cpp @@ -4,9 +4,9 @@ #include "ByteItem.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Targets::TargetMemoryDescriptor; + using Targets::TargetMemoryDescriptor; ItemGraphicsView::ItemGraphicsView( const TargetMemoryDescriptor& targetMemoryDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.hpp index 89b9cf33..375142ac 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsView.hpp @@ -10,7 +10,7 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp" -namespace Bloom::Widgets +namespace Widgets { class ItemGraphicsView: public QGraphicsView { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/StackMemoryGroupItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/StackMemoryGroupItem.cpp index 83949e7d..b61d6751 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/StackMemoryGroupItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/StackMemoryGroupItem.cpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets +namespace Widgets { StackMemoryGroupItem::StackMemoryGroupItem( Targets::TargetStackPointer stackPointer, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/StackMemoryGroupItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/StackMemoryGroupItem.hpp index 56929751..af72ba3c 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/StackMemoryGroupItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/StackMemoryGroupItem.hpp @@ -9,7 +9,7 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp" -namespace Bloom::Widgets +namespace Widgets { class StackMemoryGroupItem: public GroupItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp index f8b21cfc..1d8c30eb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.cpp @@ -1,6 +1,6 @@ #include "TopLevelGroupItem.hpp" -namespace Bloom::Widgets +namespace Widgets { TopLevelGroupItem::TopLevelGroupItem( const std::vector& focusedMemoryRegions, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp index df4a35f8..e3953c86 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp @@ -15,7 +15,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp" -namespace Bloom::Widgets +namespace Widgets { class TopLevelGroupItem: public GroupItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.cpp index 310f1e7a..3c7bf7a9 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.cpp @@ -3,65 +3,62 @@ #include "src/Helpers/EnumToStringMappings.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - MemoryRegion::MemoryRegion( - const QString& name, - Targets::TargetMemoryType memoryType, - MemoryRegionType type, - const Targets::TargetMemoryAddressRange& addressRange - ) - : name(name) - , memoryType(memoryType) - , type(type) - , addressRange(addressRange) - {} +MemoryRegion::MemoryRegion( + const QString& name, + Targets::TargetMemoryType memoryType, + MemoryRegionType type, + const Targets::TargetMemoryAddressRange& addressRange +) + : name(name) + , memoryType(memoryType) + , type(type) + , addressRange(addressRange) +{} - MemoryRegion::MemoryRegion(const QJsonObject& jsonObject) { - using Exceptions::Exception; +MemoryRegion::MemoryRegion(const QJsonObject& jsonObject) { + using Exceptions::Exception; - if ( - !jsonObject.contains("name") - || !jsonObject.contains("memoryType") - || !jsonObject.contains("type") - || !jsonObject.contains("createdTimestamp") - || !jsonObject.contains("addressInputType") - || !jsonObject.contains("addressRange") - ) { - throw Exception("Missing data"); - } - - const auto addressRangeObj = jsonObject.find("addressRange")->toObject(); - if ( - !addressRangeObj.contains("startAddress") - || !addressRangeObj.contains("endAddress") - ) { - throw Exception("Missing address range data"); - } - - this->name = jsonObject.find("name")->toString(); - this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString()); - this->type = MemoryRegion::memoryRegionTypesByName.at(jsonObject.find("type")->toString()); - this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger()); - this->addressRangeInputType = MemoryRegion::addressTypesByName.at(jsonObject.find("addressInputType")->toString()); - - this->addressRange = { - static_cast(addressRangeObj.find("startAddress")->toInteger()), - static_cast(addressRangeObj.find("endAddress")->toInteger()), - }; + if ( + !jsonObject.contains("name") + || !jsonObject.contains("memoryType") + || !jsonObject.contains("type") + || !jsonObject.contains("createdTimestamp") + || !jsonObject.contains("addressInputType") + || !jsonObject.contains("addressRange") + ) { + throw Exception("Missing data"); } - QJsonObject MemoryRegion::toJson() const { - return QJsonObject({ - {"name", this->name}, - {"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)}, - {"type", MemoryRegion::memoryRegionTypesByName.at(this->type)}, - {"createdTimestamp", this->createdDate.toSecsSinceEpoch()}, - {"addressInputType", MemoryRegion::addressTypesByName.at(this->addressRangeInputType)}, - {"addressRange", QJsonObject({ - {"startAddress", static_cast(this->addressRange.startAddress)}, - {"endAddress", static_cast(this->addressRange.endAddress)}, - })}, - }); + const auto addressRangeObj = jsonObject.find("addressRange")->toObject(); + if ( + !addressRangeObj.contains("startAddress") + || !addressRangeObj.contains("endAddress") + ) { + throw Exception("Missing address range data"); } + + this->name = jsonObject.find("name")->toString(); + this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString()); + this->type = MemoryRegion::memoryRegionTypesByName.at(jsonObject.find("type")->toString()); + this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger()); + this->addressRangeInputType = MemoryRegion::addressTypesByName.at(jsonObject.find("addressInputType")->toString()); + + this->addressRange = { + static_cast(addressRangeObj.find("startAddress")->toInteger()), + static_cast(addressRangeObj.find("endAddress")->toInteger()), + }; +} + +QJsonObject MemoryRegion::toJson() const { + return QJsonObject({ + {"name", this->name}, + {"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)}, + {"type", MemoryRegion::memoryRegionTypesByName.at(this->type)}, + {"createdTimestamp", this->createdDate.toSecsSinceEpoch()}, + {"addressInputType", MemoryRegion::addressTypesByName.at(this->addressRangeInputType)}, + {"addressRange", QJsonObject({ + {"startAddress", static_cast(this->addressRange.startAddress)}, + {"endAddress", static_cast(this->addressRange.endAddress)}, + })}, + }); } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp index b9ba35eb..2da37099 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp @@ -13,79 +13,76 @@ #include "src/Helpers/BiMap.hpp" -namespace Bloom +enum class MemoryRegionType: std::uint8_t { - enum class MemoryRegionType: std::uint8_t - { - FOCUSED, - EXCLUDED, + FOCUSED, + EXCLUDED, +}; + +enum class MemoryRegionAddressInputType: std::uint8_t +{ + ABSOLUTE, + RELATIVE, +}; + +class MemoryRegion +{ +public: + QString name; + QDateTime createdDate = Services::DateTimeService::currentDateTime(); + Targets::TargetMemoryType memoryType; + MemoryRegionType type; + + /** + * The addressRangeType holds the user's preference when inputting address ranges in the memory region manager + * window, for this particular memory region. + * + * It has no significance anywhere else. We never store the address in relative form - this->addressRange will + * always be in absolute form. Conversion is done at the point of applying the changes. + * + * For more, see the following and their call sites: + * See RegionItem::convertRelativeToAbsoluteAddressRange() + * See RegionItem::convertAbsoluteToRelativeAddressRange() + */ + AddressType addressRangeInputType = AddressType::ABSOLUTE; + + /** + * This address range will always be in absolute form. Regardless of the value of this->addressRangeType. + * See the comment above, for this->addressRangeType, for more. + */ + Targets::TargetMemoryAddressRange addressRange; + + MemoryRegion( + const QString& name, + Targets::TargetMemoryType memoryType, + MemoryRegionType type, + const Targets::TargetMemoryAddressRange& addressRange + ); + + MemoryRegion(const QJsonObject& jsonObject); + + virtual QJsonObject toJson() const; + + virtual ~MemoryRegion() = default; + + MemoryRegion(const MemoryRegion& other) = default; + MemoryRegion(MemoryRegion&& other) = default; + + MemoryRegion& operator = (const MemoryRegion& other) = default; + MemoryRegion& operator = (MemoryRegion&& other) = default; + + [[nodiscard]] bool intersectsWith(const MemoryRegion& other) const { + return this->addressRange.intersectsWith(other.addressRange); + } + +private: + static const inline BiMap memoryRegionTypesByName = { + {MemoryRegionType::EXCLUDED, "excluded"}, + {MemoryRegionType::FOCUSED, "focused"}, }; - enum class MemoryRegionAddressInputType: std::uint8_t - { - ABSOLUTE, - RELATIVE, + static const inline BiMap addressTypesByName = { + {AddressType::ABSOLUTE, "absolute"}, + {AddressType::RELATIVE, "relative"}, }; - - class MemoryRegion - { - public: - QString name; - QDateTime createdDate = Services::DateTimeService::currentDateTime(); - Targets::TargetMemoryType memoryType; - MemoryRegionType type; - - /** - * The addressRangeType holds the user's preference when inputting address ranges in the memory region manager - * window, for this particular memory region. - * - * It has no significance anywhere else. We never store the address in relative form - this->addressRange will - * always be in absolute form. Conversion is done at the point of applying the changes. - * - * For more, see the following and their call sites: - * See RegionItem::convertRelativeToAbsoluteAddressRange() - * See RegionItem::convertAbsoluteToRelativeAddressRange() - */ - AddressType addressRangeInputType = AddressType::ABSOLUTE; - - /** - * This address range will always be in absolute form. Regardless of the value of this->addressRangeType. - * See the comment above, for this->addressRangeType, for more. - */ - Targets::TargetMemoryAddressRange addressRange; - - MemoryRegion( - const QString& name, - Targets::TargetMemoryType memoryType, - MemoryRegionType type, - const Targets::TargetMemoryAddressRange& addressRange - ); - - MemoryRegion(const QJsonObject& jsonObject); - - virtual QJsonObject toJson() const; - - virtual ~MemoryRegion() = default; - - MemoryRegion(const MemoryRegion& other) = default; - MemoryRegion(MemoryRegion&& other) = default; - - MemoryRegion& operator = (const MemoryRegion& other) = default; - MemoryRegion& operator = (MemoryRegion&& other) = default; - - [[nodiscard]] bool intersectsWith(const MemoryRegion& other) const { - return this->addressRange.intersectsWith(other.addressRange); - } - - private: - static const inline BiMap memoryRegionTypesByName = { - {MemoryRegionType::EXCLUDED, "excluded"}, - {MemoryRegionType::FOCUSED, "focused"}, - }; - - static const inline BiMap addressTypesByName = { - {AddressType::ABSOLUTE, "absolute"}, - {AddressType::RELATIVE, "relative"}, - }; - }; -} +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.cpp index c8d7e385..700b5060 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.cpp @@ -6,7 +6,7 @@ #include "src/Exceptions/Exception.hpp" #include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp" -namespace Bloom::Widgets +namespace Widgets { ExcludedRegionItem::ExcludedRegionItem( const ExcludedMemoryRegion& region, @@ -23,7 +23,7 @@ namespace Bloom::Widgets ); if (!formUiFile.open(QFile::ReadOnly)) { - throw Bloom::Exceptions::Exception("Failed to open excluded region item form UI file"); + throw Exceptions::Exception("Failed to open excluded region item form UI file"); } auto uiLoader = UiLoader(this); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.hpp index 9dae69de..53a50394 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/ExcludedRegionItem.hpp @@ -3,7 +3,7 @@ #include "RegionItem.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp" -namespace Bloom::Widgets +namespace Widgets { class ExcludedRegionItem: public RegionItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.cpp index 34d11a38..fb7235e1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.cpp @@ -6,7 +6,7 @@ #include "src/Exceptions/Exception.hpp" #include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp" -namespace Bloom::Widgets +namespace Widgets { using Targets::TargetMemoryAddressRange; @@ -25,7 +25,7 @@ namespace Bloom::Widgets ); if (!formUiFile.open(QFile::ReadOnly)) { - throw Bloom::Exceptions::Exception("Failed to open focused region item form UI file"); + throw Exceptions::Exception("Failed to open focused region item form UI file"); } auto uiLoader = UiLoader(this); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.hpp index 916c2730..01f04229 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/FocusedRegionItem.hpp @@ -3,7 +3,7 @@ #include "RegionItem.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp" -namespace Bloom::Widgets +namespace Widgets { struct DataTypeOption { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.cpp index 3b3f53ff..6dda6c47 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.cpp @@ -11,9 +11,9 @@ #include "src/Helpers/EnumToStringMappings.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Exceptions::Exception; + using Exceptions::Exception; MemoryRegionManagerWindow::MemoryRegionManagerWindow( const Targets::TargetMemoryDescriptor& memoryDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.hpp index 78bc484e..f3cbfb2e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.hpp @@ -21,7 +21,7 @@ #include "FocusedRegionItem.hpp" #include "ExcludedRegionItem.hpp" -namespace Bloom::Widgets +namespace Widgets { class MemoryRegionManagerWindow: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.cpp index 683a4ea4..ed6f7b5f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { using Targets::TargetMemoryAddressRange; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp index 7ee99c02..fc2098c5 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp @@ -14,7 +14,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Widgets +namespace Widgets { struct AddressRangeTypeOption { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.cpp index 9b343495..00672ee1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.cpp @@ -7,137 +7,134 @@ #include "src/Helpers/EnumToStringMappings.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - MemorySnapshot::MemorySnapshot( - const QString& name, - const QString& description, - Targets::TargetMemoryType memoryType, - const Targets::TargetMemoryBuffer& data, - Targets::TargetProgramCounter programCounter, - Targets::TargetStackPointer stackPointer, - const std::vector& focusedRegions, - const std::vector& excludedRegions - ) - : id(QUuid::createUuid().toString(QUuid::StringFormat::WithoutBraces)) - , name(name) - , description(description) - , memoryType(memoryType) - , data(data) - , programCounter(programCounter) - , stackPointer(stackPointer) - , focusedRegions(focusedRegions) - , excludedRegions(excludedRegions) - {} +MemorySnapshot::MemorySnapshot( + const QString& name, + const QString& description, + Targets::TargetMemoryType memoryType, + const Targets::TargetMemoryBuffer& data, + Targets::TargetProgramCounter programCounter, + Targets::TargetStackPointer stackPointer, + const std::vector& focusedRegions, + const std::vector& excludedRegions +) + : id(QUuid::createUuid().toString(QUuid::StringFormat::WithoutBraces)) + , name(name) + , description(description) + , memoryType(memoryType) + , data(data) + , programCounter(programCounter) + , stackPointer(stackPointer) + , focusedRegions(focusedRegions) + , excludedRegions(excludedRegions) +{} - MemorySnapshot::MemorySnapshot(const QJsonObject& jsonObject) { - using Exceptions::Exception; +MemorySnapshot::MemorySnapshot(const QJsonObject& jsonObject) { + using Exceptions::Exception; - if ( - !jsonObject.contains("id") - || !jsonObject.contains("name") - || !jsonObject.contains("description") - || !jsonObject.contains("memoryType") - || !jsonObject.contains("hexData") - || !jsonObject.contains("programCounter") - || !jsonObject.contains("stackPointer") - || !jsonObject.contains("createdTimestamp") - || !jsonObject.contains("focusedRegions") - || !jsonObject.contains("excludedRegions") - ) { - throw Exception("Missing data"); - } + if ( + !jsonObject.contains("id") + || !jsonObject.contains("name") + || !jsonObject.contains("description") + || !jsonObject.contains("memoryType") + || !jsonObject.contains("hexData") + || !jsonObject.contains("programCounter") + || !jsonObject.contains("stackPointer") + || !jsonObject.contains("createdTimestamp") + || !jsonObject.contains("focusedRegions") + || !jsonObject.contains("excludedRegions") + ) { + throw Exception("Missing data"); + } - this->id = jsonObject.find("id")->toString(); - this->name = jsonObject.find("name")->toString(); - this->description = jsonObject.find("description")->toString(); - this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString()); - this->programCounter = static_cast(jsonObject.find("programCounter")->toInteger()); - this->stackPointer = static_cast(jsonObject.find("stackPointer")->toInteger()); - this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger()); + this->id = jsonObject.find("id")->toString(); + this->name = jsonObject.find("name")->toString(); + this->description = jsonObject.find("description")->toString(); + this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString()); + this->programCounter = static_cast(jsonObject.find("programCounter")->toInteger()); + this->stackPointer = static_cast(jsonObject.find("stackPointer")->toInteger()); + this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger()); - const auto hexData = QByteArray::fromHex(jsonObject.find("hexData")->toString().toUtf8()); - this->data = Targets::TargetMemoryBuffer(hexData.begin(), hexData.end()); + const auto hexData = QByteArray::fromHex(jsonObject.find("hexData")->toString().toUtf8()); + this->data = Targets::TargetMemoryBuffer(hexData.begin(), hexData.end()); - if (jsonObject.contains("focusedRegions")) { - for (const auto& regionValue : jsonObject.find("focusedRegions")->toArray()) { - try { - this->focusedRegions.emplace_back(regionValue.toObject()); + if (jsonObject.contains("focusedRegions")) { + for (const auto& regionValue : jsonObject.find("focusedRegions")->toArray()) { + try { + this->focusedRegions.emplace_back(regionValue.toObject()); - } catch (Exception exception) { - throw Exception("Invalid focused memory region"); - } - } - } - - if (jsonObject.contains("excludedRegions")) { - for (const auto& regionValue : jsonObject.find("excludedRegions")->toArray()) { - try { - this->excludedRegions.emplace_back(regionValue.toObject()); - - } catch (Exception exception) { - throw Exception("Invalid excluded memory region"); - } + } catch (Exception exception) { + throw Exception("Invalid focused memory region"); } } } - QJsonObject MemorySnapshot::toJson() const { - auto focusedRegions = QJsonArray(); - for (const auto& focusedRegion : this->focusedRegions) { - focusedRegions.push_back(focusedRegion.toJson()); - } + if (jsonObject.contains("excludedRegions")) { + for (const auto& regionValue : jsonObject.find("excludedRegions")->toArray()) { + try { + this->excludedRegions.emplace_back(regionValue.toObject()); - auto excludedRegions = QJsonArray(); - for (const auto& excludedRegion : this->excludedRegions) { - excludedRegions.push_back(excludedRegion.toJson()); - } - - return QJsonObject({ - {"id", this->id}, - {"name", this->name}, - {"description", this->description}, - {"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)}, - {"hexData", QString(QByteArray( - reinterpret_cast(this->data.data()), - static_cast(this->data.size()) - ).toHex())}, - {"programCounter", static_cast(this->programCounter)}, - {"stackPointer", static_cast(this->stackPointer)}, - {"createdTimestamp", this->createdDate.toSecsSinceEpoch()}, - {"focusedRegions", focusedRegions}, - {"excludedRegions", excludedRegions}, - }); - } - - bool MemorySnapshot::isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const { - if (this->memoryType != memoryDescriptor.type) { - return false; - } - - if (this->data.size() != memoryDescriptor.size()) { - return false; - } - - const auto& memoryAddressRange = memoryDescriptor.addressRange; - for (const auto& focusedRegion : this->focusedRegions) { - if ( - focusedRegion.addressRange.startAddress < memoryAddressRange.startAddress - || focusedRegion.addressRange.endAddress > memoryAddressRange.endAddress - ) { - return false; + } catch (Exception exception) { + throw Exception("Invalid excluded memory region"); } } - - for (const auto& excludedRegion : this->excludedRegions) { - if ( - excludedRegion.addressRange.startAddress < memoryAddressRange.startAddress - || excludedRegion.addressRange.endAddress > memoryAddressRange.endAddress - ) { - return false; - } - } - - return true; } } + +QJsonObject MemorySnapshot::toJson() const { + auto focusedRegions = QJsonArray(); + for (const auto& focusedRegion : this->focusedRegions) { + focusedRegions.push_back(focusedRegion.toJson()); + } + + auto excludedRegions = QJsonArray(); + for (const auto& excludedRegion : this->excludedRegions) { + excludedRegions.push_back(excludedRegion.toJson()); + } + + return QJsonObject({ + {"id", this->id}, + {"name", this->name}, + {"description", this->description}, + {"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)}, + {"hexData", QString(QByteArray( + reinterpret_cast(this->data.data()), + static_cast(this->data.size()) + ).toHex())}, + {"programCounter", static_cast(this->programCounter)}, + {"stackPointer", static_cast(this->stackPointer)}, + {"createdTimestamp", this->createdDate.toSecsSinceEpoch()}, + {"focusedRegions", focusedRegions}, + {"excludedRegions", excludedRegions}, + }); +} + +bool MemorySnapshot::isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const { + if (this->memoryType != memoryDescriptor.type) { + return false; + } + + if (this->data.size() != memoryDescriptor.size()) { + return false; + } + + const auto& memoryAddressRange = memoryDescriptor.addressRange; + for (const auto& focusedRegion : this->focusedRegions) { + if ( + focusedRegion.addressRange.startAddress < memoryAddressRange.startAddress + || focusedRegion.addressRange.endAddress > memoryAddressRange.endAddress + ) { + return false; + } + } + + for (const auto& excludedRegion : this->excludedRegions) { + if ( + excludedRegion.addressRange.startAddress < memoryAddressRange.startAddress + || excludedRegion.addressRange.endAddress > memoryAddressRange.endAddress + ) { + return false; + } + } + + return true; +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp index 87cde40e..f8a1ca4d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp @@ -12,46 +12,43 @@ #include "FocusedMemoryRegion.hpp" #include "ExcludedMemoryRegion.hpp" -namespace Bloom +struct MemorySnapshot { - struct MemorySnapshot - { - public: - QString id; - QString name; - QString description; - Targets::TargetMemoryType memoryType; - Targets::TargetMemoryBuffer data; - Targets::TargetProgramCounter programCounter; - Targets::TargetStackPointer stackPointer; - QDateTime createdDate = Services::DateTimeService::currentDateTime(); +public: + QString id; + QString name; + QString description; + Targets::TargetMemoryType memoryType; + Targets::TargetMemoryBuffer data; + Targets::TargetProgramCounter programCounter; + Targets::TargetStackPointer stackPointer; + QDateTime createdDate = Services::DateTimeService::currentDateTime(); - std::vector focusedRegions; - std::vector excludedRegions; + std::vector focusedRegions; + std::vector excludedRegions; - MemorySnapshot( - const QString& name, - const QString& description, - Targets::TargetMemoryType memoryType, - const Targets::TargetMemoryBuffer& data, - Targets::TargetProgramCounter programCounter, - Targets::TargetStackPointer stackPointer, - const std::vector& focusedRegions, - const std::vector& excludedRegions - ); + MemorySnapshot( + const QString& name, + const QString& description, + Targets::TargetMemoryType memoryType, + const Targets::TargetMemoryBuffer& data, + Targets::TargetProgramCounter programCounter, + Targets::TargetStackPointer stackPointer, + const std::vector& focusedRegions, + const std::vector& excludedRegions + ); - MemorySnapshot(const QJsonObject& jsonObject); + MemorySnapshot(const QJsonObject& jsonObject); - QJsonObject toJson() const; + QJsonObject toJson() const; - bool isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const; + bool isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const; - virtual ~MemorySnapshot() = default; + virtual ~MemorySnapshot() = default; - MemorySnapshot(const MemorySnapshot& other) = default; - MemorySnapshot(MemorySnapshot&& other) = default; + MemorySnapshot(const MemorySnapshot& other) = default; + MemorySnapshot(MemorySnapshot&& other) = default; - MemorySnapshot& operator = (const MemorySnapshot& other) = default; - MemorySnapshot& operator = (MemorySnapshot&& other) = default; - }; -} + MemorySnapshot& operator = (const MemorySnapshot& other) = default; + MemorySnapshot& operator = (MemorySnapshot&& other) = default; +}; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.cpp index 2aac143d..86538fb3 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.cpp @@ -12,9 +12,9 @@ #include "src/Helpers/EnumToStringMappings.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Exceptions::Exception; + using Exceptions::Exception; CreateSnapshotWindow::CreateSnapshotWindow( Targets::TargetMemoryType memoryType, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.hpp index 2747d79a..9b3f9e18 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/CreateSnapshotWindow/CreateSnapshotWindow.hpp @@ -12,7 +12,7 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Targets/TargetState.hpp" -namespace Bloom::Widgets +namespace Widgets { class CreateSnapshotWindow: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.cpp index b4783d12..5d45224b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.cpp @@ -2,7 +2,7 @@ #include "src/Services/DateTimeService.hpp" -namespace Bloom::Widgets +namespace Widgets { MemorySnapshotItem::MemorySnapshotItem(const MemorySnapshot& memorySnapshot) : memorySnapshot(memorySnapshot) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.hpp index 68738133..d1161eda 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/MemorySnapshotItem.hpp @@ -7,7 +7,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Widgets +namespace Widgets { class MemorySnapshotItem: public ListItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerItemRenderer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerItemRenderer.cpp index d5fbec64..c2d8f1be 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerItemRenderer.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerItemRenderer.cpp @@ -6,7 +6,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteAddressContainer.hpp" -namespace Bloom::Widgets +namespace Widgets { DifferentialHexViewerItemRenderer::DifferentialHexViewerItemRenderer( DifferentialHexViewerWidgetType differentialHexViewerWidgetType, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerItemRenderer.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerItemRenderer.hpp index e0fc1e2f..06e22345 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerItemRenderer.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerItemRenderer.hpp @@ -3,7 +3,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerItemRenderer.hpp" #include "DifferentialHexViewerWidgetType.hpp" -namespace Bloom::Widgets +namespace Widgets { class DifferentialHexViewerItemRenderer: public HexViewerItemRenderer { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerSharedState.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerSharedState.hpp index 9673a63f..21099224 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerSharedState.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerSharedState.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets +namespace Widgets { struct DifferentialHexViewerSharedState { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.cpp index eaa3d813..35091a9d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { DifferentialHexViewerWidget::DifferentialHexViewerWidget( DifferentialHexViewerWidgetType type, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.hpp index 61fd651a..a2c20cca 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.hpp @@ -8,7 +8,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp" -namespace Bloom::Widgets +namespace Widgets { class DifferentialHexViewerWidget final: public HexViewerWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidgetType.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidgetType.hpp index 6bd83a36..8abf9b49 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidgetType.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidgetType.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets +namespace Widgets { enum class DifferentialHexViewerWidgetType: std::uint8_t { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.cpp index 9f73c820..823f95f5 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.cpp @@ -4,7 +4,7 @@ #include "DifferentialHexViewerItemRenderer.hpp" -namespace Bloom::Widgets +namespace Widgets { DifferentialItemGraphicsScene::DifferentialItemGraphicsScene( DifferentialHexViewerWidgetType differentialHexViewerWidgetType, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.hpp index 718f028c..ad922485 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.hpp @@ -8,7 +8,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp" -namespace Bloom::Widgets +namespace Widgets { class DifferentialItemGraphicsScene final: public ItemGraphicsScene { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsView.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsView.cpp index 43d5eecc..a80bd71f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsView.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsView.cpp @@ -1,6 +1,6 @@ #include "DifferentialItemGraphicsView.hpp" -namespace Bloom::Widgets +namespace Widgets { DifferentialItemGraphicsView::DifferentialItemGraphicsView( DifferentialHexViewerWidgetType differentialHexViewerWidgetType, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsView.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsView.hpp index 0601cc19..2019fb5d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsView.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsView.hpp @@ -8,7 +8,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp" -namespace Bloom::Widgets +namespace Widgets { class DifferentialItemGraphicsView final: public ItemGraphicsView { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiff.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiff.cpp index 079ca29f..1a2321cf 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiff.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiff.cpp @@ -19,9 +19,9 @@ #include "src/Insight/InsightSignals.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Exceptions::Exception; + using Exceptions::Exception; SnapshotDiff::SnapshotDiff( MemorySnapshot& snapshotA, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiff.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiff.hpp index 1129ce3b..1c2ac240 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiff.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiff.hpp @@ -19,7 +19,7 @@ #include "DifferentialHexViewerWidget/DifferentialHexViewerWidget.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.hpp" -namespace Bloom::Widgets +namespace Widgets { class SnapshotDiff: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp index 91f95892..891c64a3 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp @@ -1,6 +1,6 @@ #pragma once -namespace Bloom::Widgets +namespace Widgets { struct SnapshotDiffSettings { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp index f24477e3..72e25b73 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp @@ -18,9 +18,9 @@ #include "src/Exceptions/Exception.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Exceptions::Exception; + using Exceptions::Exception; SnapshotManager::SnapshotManager( const Targets::TargetMemoryDescriptor& memoryDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp index 22589164..27d9d194 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp @@ -25,7 +25,7 @@ #include "SnapshotViewer/SnapshotViewer.hpp" #include "SnapshotDiff/SnapshotDiff.hpp" -namespace Bloom::Widgets +namespace Widgets { class SnapshotManager: public PaneWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/MemoryRegionItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/MemoryRegionItem.cpp index a9d0a9fd..58f68ccf 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/MemoryRegionItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/MemoryRegionItem.cpp @@ -2,7 +2,7 @@ #include "src/Services/DateTimeService.hpp" -namespace Bloom::Widgets +namespace Widgets { MemoryRegionItem::MemoryRegionItem(const MemoryRegion& memoryRegion) : memoryRegion(memoryRegion) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/MemoryRegionItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/MemoryRegionItem.hpp index 8c1d8353..4646c2fb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/MemoryRegionItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/MemoryRegionItem.hpp @@ -7,7 +7,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp" #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Widgets +namespace Widgets { class MemoryRegionItem: public ListItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.cpp index c2117b36..ce0f7c7f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.cpp @@ -23,9 +23,9 @@ #include "src/Insight/InsightSignals.hpp" #include "src/Logger/Logger.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Exceptions::Exception; + using Exceptions::Exception; SnapshotViewer::SnapshotViewer( MemorySnapshot& snapshot, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.hpp index 460427e1..c85d7b8a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotViewer/SnapshotViewer.hpp @@ -19,7 +19,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ContextMenuAction.hpp" #include "MemoryRegionItem.hpp" -namespace Bloom::Widgets +namespace Widgets { class SnapshotViewer: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp index 1bfa3897..af22ac77 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp @@ -16,13 +16,13 @@ #include "src/Helpers/EnumToStringMappings.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::Widgets +namespace Widgets { - using namespace Bloom::Exceptions; + using namespace Exceptions; - using Bloom::Targets::TargetMemoryDescriptor; - using Bloom::Targets::TargetMemoryType; - using Bloom::Targets::TargetMemoryAddressRange; + using Targets::TargetMemoryDescriptor; + using Targets::TargetMemoryType; + using Targets::TargetMemoryAddressRange; TargetMemoryInspectionPane::TargetMemoryInspectionPane( const TargetMemoryDescriptor& targetMemoryDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp index 646f6719..d47689db 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp @@ -28,7 +28,7 @@ #include "TargetMemoryInspectionPaneSettings.hpp" -namespace Bloom::Widgets +namespace Widgets { class TargetMemoryInspectionPane: public PaneWidget { @@ -104,7 +104,7 @@ namespace Bloom::Widgets void onProgrammingModeEnabled(); void onProgrammingModeDisabled(); void onTargetMemoryWritten( - Bloom::Targets::TargetMemoryType memoryType, + Targets::TargetMemoryType memoryType, Targets::TargetMemoryAddressRange addressRange ); void onSubtaskCreated(const QSharedPointer& task); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp index 8d8a820e..d5c3ec3d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp @@ -10,7 +10,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/PanelState.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/PaneState.hpp" -namespace Bloom::Widgets +namespace Widgets { struct TargetMemoryInspectionPaneSettings { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.cpp index b1bd044d..639689f3 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.cpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { BitBodyWidget::BitBodyWidget( int bitIndex, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.hpp index 79328144..2008e7a7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitBodyWidget.hpp @@ -10,7 +10,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { class BitBodyWidget: public ClickableWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitWidget.cpp index 09667c6a..dcd46628 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitWidget.cpp @@ -6,7 +6,7 @@ #include "BitBodyWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { BitWidget::BitWidget( int bitIndex, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitWidget.hpp index 2abb7f2d..38b06b42 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitWidget.hpp @@ -13,7 +13,7 @@ #include "BitBodyWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { class BitWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitsetWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitsetWidget.cpp index 5257e06a..a247e53a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitsetWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitsetWidget.cpp @@ -8,7 +8,7 @@ #include "../TargetRegisterInspectorWindow.hpp" -namespace Bloom::Widgets +namespace Widgets { BitsetWidget::BitsetWidget(int byteNumber, unsigned char& byte, bool readOnly, QWidget* parent) : QWidget(parent), byteNumber(byteNumber), byte(byte), readOnly(readOnly) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitsetWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitsetWidget.hpp index dedadfdf..0ccf8f5d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitsetWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/BitsetWidget/BitsetWidget.hpp @@ -8,7 +8,7 @@ #include "BitWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { class BitsetWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/CurrentItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/CurrentItem.cpp index 4cced871..11ba49d1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/CurrentItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/CurrentItem.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { CurrentItem::CurrentItem( const Targets::TargetMemoryBuffer& registerValue, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/CurrentItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/CurrentItem.hpp index 3616ed67..78d716c0 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/CurrentItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/CurrentItem.hpp @@ -9,7 +9,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Widgets +namespace Widgets { class CurrentItem: public Item { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/Item.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/Item.cpp index 70357b40..749f558d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/Item.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/Item.cpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets +namespace Widgets { Item::Item(const Targets::TargetMemoryBuffer& registerValue, QWidget* parent) : ClickableWidget(parent), registerValue(registerValue) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/Item.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/Item.hpp index 01e45089..b972a715 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/Item.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/Item.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Widgets +namespace Widgets { class Item: public ClickableWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryItem.cpp index 5eb11cf7..ee24b9cd 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryItem.cpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { RegisterHistoryItem::RegisterHistoryItem( const Targets::TargetMemoryBuffer& registerValue, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryItem.hpp index 86f6be6f..6c821446 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryItem.hpp @@ -6,7 +6,7 @@ #include "Item.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp" -namespace Bloom::Widgets +namespace Widgets { class RegisterHistoryItem: public Item { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.cpp index cdd11848..d3997d4a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.cpp @@ -14,13 +14,13 @@ #include "src/Services/PathService.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::Widgets +namespace Widgets { - using namespace Bloom::Exceptions; + using namespace Exceptions; - using Bloom::Targets::TargetRegisterDescriptor; - using Bloom::Targets::TargetRegisterDescriptors; - using Bloom::Targets::TargetRegisterType; + using Targets::TargetRegisterDescriptor; + using Targets::TargetRegisterDescriptors; + using Targets::TargetRegisterType; RegisterHistoryWidget::RegisterHistoryWidget( const Targets::TargetRegisterDescriptor& registerDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.hpp index 5bad3470..8e561724 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.hpp @@ -16,7 +16,7 @@ #include "CurrentItem.hpp" #include "RegisterHistoryItem.hpp" -namespace Bloom::Widgets +namespace Widgets { class RegisterHistoryWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp index 91b27dc3..6f661765 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp @@ -17,13 +17,13 @@ #include "src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp" #include "src/Insight/InsightWorker/Tasks/WriteTargetRegister.hpp" -namespace Bloom::Widgets +namespace Widgets { - using Bloom::Exceptions::Exception; - using Bloom::Targets::TargetRegisterDescriptor; - using Bloom::Targets::TargetRegisterDescriptors; - using Bloom::Targets::TargetRegisterType; - using Bloom::Targets::TargetState; + using Exceptions::Exception; + using Targets::TargetRegisterDescriptor; + using Targets::TargetRegisterDescriptors; + using Targets::TargetRegisterType; + using Targets::TargetState; TargetRegisterInspectorWindow::TargetRegisterInspectorWindow( const Targets::TargetRegisterDescriptor& registerDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.hpp index 711755d0..fe693125 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.hpp @@ -17,7 +17,7 @@ #include "BitsetWidget/BitsetWidget.hpp" #include "RegisterHistoryWidget/RegisterHistoryWidget.hpp" -namespace Bloom::Widgets +namespace Widgets { class TargetRegisterInspectorWindow: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.cpp index 317fa930..d807e271 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.cpp @@ -10,7 +10,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListScene.hpp" #include "src/Services/PathService.hpp" -namespace Bloom::Widgets +namespace Widgets { RegisterGroupItem::RegisterGroupItem( QString name, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.hpp index 70d4c494..e49a7f6f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupItem.hpp @@ -11,7 +11,7 @@ #include "RegisterItem.hpp" #include "src/Targets/TargetRegister.hpp" -namespace Bloom::Widgets +namespace Widgets { class RegisterGroupItem: public ListItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.cpp index 2ebfa3cf..139e4bc4 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.cpp @@ -9,7 +9,7 @@ #include "src/Services/PathService.hpp" -namespace Bloom::Widgets +namespace Widgets { RegisterItem::RegisterItem( const Targets::TargetRegisterDescriptor& registerDescriptor diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.hpp index c78939f8..74d58c98 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterItem.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetRegister.hpp" -namespace Bloom::Widgets +namespace Widgets { class RegisterItem: public ListItem { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp index 31a77b7c..60b22e9f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp @@ -16,14 +16,14 @@ #include "src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp" -namespace Bloom::Widgets +namespace Widgets { - using namespace Bloom::Exceptions; + using namespace Exceptions; - using Bloom::Targets::TargetDescriptor; - using Bloom::Targets::TargetRegisterDescriptor; - using Bloom::Targets::TargetRegisterDescriptors; - using Bloom::Targets::TargetRegisterType; + using Targets::TargetDescriptor; + using Targets::TargetRegisterDescriptor; + using Targets::TargetRegisterDescriptors; + using Targets::TargetRegisterType; TargetRegistersPaneWidget::TargetRegistersPaneWidget( const TargetDescriptor& targetDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp index 2eb34b00..b91fbc8f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp @@ -22,7 +22,7 @@ #include "src/Targets/TargetState.hpp" #include "src/Targets/TargetDescriptor.hpp" -namespace Bloom::Widgets +namespace Widgets { class TargetRegistersPaneWidget: public PaneWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp index d44c5e07..5d385b8a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp @@ -1,6 +1,6 @@ #include "BodyWidget.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Dip +namespace Widgets::InsightTargetWidgets::Dip { BodyWidget::BodyWidget(QWidget* parent, std::size_t pinCount): QWidget(parent) { this->setObjectName("target-body"); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.hpp index 69e3489a..49a41d4e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets::InsightTargetWidgets::Dip +namespace Widgets::InsightTargetWidgets::Dip { class BodyWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp index f297783f..3cd29d9e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp @@ -8,9 +8,9 @@ #include "src/Services/PathService.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Dip +namespace Widgets::InsightTargetWidgets::Dip { - using Bloom::Targets::TargetVariant; + using Targets::TargetVariant; DualInlinePackageWidget::DualInlinePackageWidget( const TargetVariant& targetVariant, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp index 25ee14ac..a91be63c 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp @@ -13,7 +13,7 @@ #include "BodyWidget.hpp" #include "src/Targets/TargetVariant.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Dip +namespace Widgets::InsightTargetWidgets::Dip { /** * The DualInlinePackageWidget implements a custom Qt widget for the Dual-inline package target variants. diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinBodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinBodyWidget.cpp index 4746c2ba..fceb1022 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinBodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinBodyWidget.cpp @@ -2,9 +2,9 @@ #include -namespace Bloom::Widgets::InsightTargetWidgets::Dip +namespace Widgets::InsightTargetWidgets::Dip { - using namespace Bloom::Targets; + using namespace Targets; PinBodyWidget::PinBodyWidget(QWidget* parent, Targets::TargetPinDescriptor pinDescriptor) : TargetPinBodyWidget(parent, std::move(pinDescriptor)) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinBodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinBodyWidget.hpp index 55015496..1deb5444 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinBodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinBodyWidget.hpp @@ -7,7 +7,7 @@ #include "src/Targets/TargetPinDescriptor.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Dip +namespace Widgets::InsightTargetWidgets::Dip { class PinBodyWidget: public TargetPinBodyWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.cpp index caad8064..280e3c9b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.cpp @@ -1,8 +1,8 @@ #include "PinWidget.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Dip +namespace Widgets::InsightTargetWidgets::Dip { - using namespace Bloom::Targets; + using namespace Targets; PinWidget::PinWidget( const TargetPinDescriptor& pinDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp index 1c52c0fc..42dac69f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp @@ -11,7 +11,7 @@ #include "PinBodyWidget.hpp" #include "src/Targets/TargetVariant.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Dip +namespace Widgets::InsightTargetWidgets::Dip { enum class Position: std::uint8_t { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/BodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/BodyWidget.cpp index 44f83b06..47e0cf72 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/BodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/BodyWidget.cpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets::InsightTargetWidgets::Qfp +namespace Widgets::InsightTargetWidgets::Qfp { void BodyWidget::paintEvent(QPaintEvent* event) { auto painter = QPainter(this); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/BodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/BodyWidget.hpp index 14d68a91..a278e942 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/BodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/BodyWidget.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets::InsightTargetWidgets::Qfp +namespace Widgets::InsightTargetWidgets::Qfp { class BodyWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinBodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinBodyWidget.cpp index 25a339d6..ca025038 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinBodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinBodyWidget.cpp @@ -3,9 +3,9 @@ #include #include -namespace Bloom::Widgets::InsightTargetWidgets::Qfp +namespace Widgets::InsightTargetWidgets::Qfp { - using namespace Bloom::Targets; + using namespace Targets; PinBodyWidget::PinBodyWidget(QWidget* parent, Targets::TargetPinDescriptor pinDescriptor, bool isVertical) : TargetPinBodyWidget(parent, std::move(pinDescriptor)), isVertical(isVertical) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinBodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinBodyWidget.hpp index 9715fb38..0e2b49fe 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinBodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinBodyWidget.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetPinDescriptor.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Qfp +namespace Widgets::InsightTargetWidgets::Qfp { class PinBodyWidget: public TargetPinBodyWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.cpp index 450193de..e7d9a0fb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.cpp @@ -7,9 +7,9 @@ #include "PinWidget.hpp" #include "PinBodyWidget.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Qfp +namespace Widgets::InsightTargetWidgets::Qfp { - using namespace Bloom::Targets; + using namespace Targets; PinWidget::PinWidget( const TargetPinDescriptor& pinDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp index f5453352..aae55b1b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/PinWidget.hpp @@ -10,7 +10,7 @@ #include "PinBodyWidget.hpp" #include "src/Targets/TargetVariant.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Qfp +namespace Widgets::InsightTargetWidgets::Qfp { enum class Position: std::uint8_t { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.cpp index 0c916888..4b97d305 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.cpp @@ -11,9 +11,9 @@ #include "PinWidget.hpp" #include "BodyWidget.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Qfp +namespace Widgets::InsightTargetWidgets::Qfp { - using namespace Bloom::Targets; + using namespace Targets; QuadFlatPackageWidget::QuadFlatPackageWidget( const TargetVariant& targetVariant, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.hpp index 18b9d91b..4a82015f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/QuadFlatPackageWidget.hpp @@ -10,7 +10,7 @@ #include "BodyWidget.hpp" #include "src/Targets/TargetVariant.hpp" -namespace Bloom::Widgets::InsightTargetWidgets::Qfp +namespace Widgets::InsightTargetWidgets::Qfp { /** * QuadFlatPackageWidget implements a custom Qt widget for Quad-flat package variants. diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp index 1309e37d..c949b5ca 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp @@ -6,9 +6,9 @@ #include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.hpp" -namespace Bloom::Widgets::InsightTargetWidgets +namespace Widgets::InsightTargetWidgets { - using Bloom::Targets::TargetState; + using Targets::TargetState; TargetPackageWidget::TargetPackageWidget( Targets::TargetVariant targetVariant, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp index b66fc349..3ff86137 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp @@ -11,7 +11,7 @@ #include "src/Targets/TargetState.hpp" #include "src/Targets/TargetRegister.hpp" -namespace Bloom::Widgets::InsightTargetWidgets +namespace Widgets::InsightTargetWidgets { /** * Each custom target package widget should be derived from this class. diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp index 311ecd97..3ecfc9bd 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.cpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Widgets::InsightTargetWidgets +namespace Widgets::InsightTargetWidgets { TargetPackageWidgetContainer::TargetPackageWidgetContainer(QWidget* parent): QWidget(parent) {} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp index 91241265..f57826eb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp @@ -5,7 +5,7 @@ #include "TargetPackageWidget.hpp" -namespace Bloom::Widgets::InsightTargetWidgets +namespace Widgets::InsightTargetWidgets { class TargetPackageWidgetContainer: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.cpp index 65c4411e..48ee7b90 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.cpp @@ -2,9 +2,9 @@ #include "TargetPinBodyWidget.hpp" -namespace Bloom::Widgets::InsightTargetWidgets +namespace Widgets::InsightTargetWidgets { - using namespace Bloom::Targets; + using namespace Targets; TargetPinBodyWidget::TargetPinBodyWidget(QWidget* parent, Targets::TargetPinDescriptor pinDescriptor) : QWidget(parent), pinDescriptor(std::move(pinDescriptor)) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.hpp index f00c4d25..fc27f887 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinBodyWidget.hpp @@ -7,7 +7,7 @@ #include "src/Targets/TargetVariant.hpp" #include "src/Targets/TargetPinDescriptor.hpp" -namespace Bloom::Widgets::InsightTargetWidgets +namespace Widgets::InsightTargetWidgets { class TargetPinBodyWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp index 7b208e8c..1f7fa575 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp @@ -3,12 +3,12 @@ #include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/InsightWorker/Tasks/SetTargetPinState.hpp" -namespace Bloom::Widgets::InsightTargetWidgets +namespace Widgets::InsightTargetWidgets { - using Bloom::Targets::TargetVariant; - using Bloom::Targets::TargetPinDescriptor; - using Bloom::Targets::TargetPinType; - using Bloom::Targets::TargetPinState; + using Targets::TargetVariant; + using Targets::TargetPinDescriptor; + using Targets::TargetPinType; + using Targets::TargetPinState; TargetPinWidget::TargetPinWidget( Targets::TargetPinDescriptor pinDescriptor, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.hpp index 42a30480..9c70d2d7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.hpp @@ -7,7 +7,7 @@ #include "src/Targets/TargetVariant.hpp" #include "src/Targets/TargetPinDescriptor.hpp" -namespace Bloom::Widgets::InsightTargetWidgets +namespace Widgets::InsightTargetWidgets { class TargetPinWidget: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskIndicator/TaskIndicator.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskIndicator/TaskIndicator.cpp index e29ba2e6..01d90759 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskIndicator/TaskIndicator.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskIndicator/TaskIndicator.cpp @@ -5,7 +5,7 @@ #include "src/Insight/InsightSignals.hpp" -namespace Bloom::Widgets +namespace Widgets { TaskIndicator::TaskIndicator(QWidget* parent) : QWidget(parent) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskIndicator/TaskIndicator.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskIndicator/TaskIndicator.hpp index a0af3eea..a4dc3d39 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskIndicator/TaskIndicator.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskIndicator/TaskIndicator.hpp @@ -9,7 +9,7 @@ #include "src/Insight/InsightWorker/Tasks/InsightWorkerTask.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.hpp" -namespace Bloom::Widgets +namespace Widgets { class TaskIndicator: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.cpp index cf9d0c7f..cdeacf90 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.cpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { TaskProgressIndicator::TaskProgressIndicator(QWidget* parent) : QWidget(parent) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.hpp index 6cfe8ed1..23306d8b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.hpp @@ -9,7 +9,7 @@ #include "src/Insight/InsightWorker/Tasks/InsightWorkerTask.hpp" -namespace Bloom::Widgets +namespace Widgets { class TaskProgressIndicator: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/Task.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/Task.cpp index 6074d30f..ce5e0f97 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/Task.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/Task.cpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { Task::Task( const QSharedPointer& task, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/Task.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/Task.hpp index 700a2e67..1f9a6ca2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/Task.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/Task.hpp @@ -6,7 +6,7 @@ #include "src/Insight/InsightWorker/Tasks/InsightWorkerTask.hpp" -namespace Bloom::Widgets +namespace Widgets { class Task: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.cpp index 54bc8a0c..a2631390 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.cpp @@ -10,7 +10,7 @@ #include "src/Services/PathService.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom::Widgets +namespace Widgets { TaskWindow::TaskWindow(QWidget* parent) : QWidget(parent) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.hpp index f79baff7..500e49de 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TaskWindow/TaskWindow.hpp @@ -11,7 +11,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp" #include "src/Insight/InsightWorker/Tasks/InsightWorkerTask.hpp" -namespace Bloom::Widgets +namespace Widgets { class TaskWindow: public QWidget { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.cpp index d8affbc5..24f0c902 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.cpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { TextInput::TextInput(QWidget* parent) : QLineEdit(parent) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp index a4ba1b00..3e9bba7f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Widgets +namespace Widgets { class TextInput: public QLineEdit { diff --git a/src/Logger/Logger.cpp b/src/Logger/Logger.cpp index cdc85289..8dc2eda4 100644 --- a/src/Logger/Logger.cpp +++ b/src/Logger/Logger.cpp @@ -2,64 +2,61 @@ #include -namespace Bloom -{ - void Logger::configure(const ProjectConfig& projectConfig) { - if (projectConfig.debugLoggingEnabled) { - Logger::debugPrintingEnabled = true; - Logger::debug("Debug log printing has been enabled"); - } - } - - void Logger::silence() { - Logger::debugPrintingEnabled = false; - Logger::infoPrintingEnabled = false; - Logger::errorPrintingEnabled = false; - Logger::warningPrintingEnabled = false; - } - - void Logger::log(const LogEntry& logEntry) { - static auto timezoneAbbreviation = Services::DateTimeService::getTimeZoneAbbreviation( - logEntry.timestamp - ).toStdString(); - - const auto lock = std::unique_lock(Logger::printMutex); - - // Print the timestamp and id in a green font color: - std::cout << "\033[32m"; - std::cout << logEntry.timestamp.toString("yyyy-MM-dd hh:mm:ss ").toStdString() - + timezoneAbbreviation; - - if (!logEntry.threadName.empty()) { - std::cout << " [" << logEntry.threadName << "]"; - } - - std::cout << " [" << logEntry.id << "]: "; - std::cout << "\033[0m"; - - switch (logEntry.logLevel) { - case LogLevel::ERROR: { - // Errors in red - std::cout << "\033[31m"; - std::cout << "[ERROR] "; - break; - } - case LogLevel::WARNING: { - // Warnings in yellow - std::cout << "\033[33m"; - std::cout << "[WARNING] "; - break; - } - case LogLevel::INFO: { - std::cout << "[INFO] "; - break; - } - case LogLevel::DEBUG: { - std::cout << "[DEBUG] "; - break; - } - } - - std::cout << logEntry.message << "\033[0m" << std::endl; +void Logger::configure(const ProjectConfig& projectConfig) { + if (projectConfig.debugLoggingEnabled) { + Logger::debugPrintingEnabled = true; + Logger::debug("Debug log printing has been enabled"); } } + +void Logger::silence() { + Logger::debugPrintingEnabled = false; + Logger::infoPrintingEnabled = false; + Logger::errorPrintingEnabled = false; + Logger::warningPrintingEnabled = false; +} + +void Logger::log(const LogEntry& logEntry) { + static auto timezoneAbbreviation = Services::DateTimeService::getTimeZoneAbbreviation( + logEntry.timestamp + ).toStdString(); + + const auto lock = std::unique_lock(Logger::printMutex); + + // Print the timestamp and id in a green font color: + std::cout << "\033[32m"; + std::cout << logEntry.timestamp.toString("yyyy-MM-dd hh:mm:ss ").toStdString() + + timezoneAbbreviation; + + if (!logEntry.threadName.empty()) { + std::cout << " [" << logEntry.threadName << "]"; + } + + std::cout << " [" << logEntry.id << "]: "; + std::cout << "\033[0m"; + + switch (logEntry.logLevel) { + case LogLevel::ERROR: { + // Errors in red + std::cout << "\033[31m"; + std::cout << "[ERROR] "; + break; + } + case LogLevel::WARNING: { + // Warnings in yellow + std::cout << "\033[33m"; + std::cout << "[WARNING] "; + break; + } + case LogLevel::INFO: { + std::cout << "[INFO] "; + break; + } + case LogLevel::DEBUG: { + std::cout << "[DEBUG] "; + break; + } + } + + std::cout << logEntry.message << "\033[0m" << std::endl; +} diff --git a/src/Logger/Logger.hpp b/src/Logger/Logger.hpp index 78689a06..fe765dd7 100644 --- a/src/Logger/Logger.hpp +++ b/src/Logger/Logger.hpp @@ -8,93 +8,90 @@ #include "src/ProjectConfig.hpp" #include "src/Services/DateTimeService.hpp" -namespace Bloom +static_assert(std::atomic::is_always_lock_free); + +enum class LogLevel: std::uint8_t { - static_assert(std::atomic::is_always_lock_free); + INFO, + WARNING, + ERROR, + DEBUG, +}; - enum class LogLevel: std::uint8_t +class LogEntry +{ +public: + std::uint32_t id = ++(LogEntry::lastLogId); + std::string message; + LogLevel logLevel; + QDateTime timestamp = Services::DateTimeService::currentDateTime(); + std::string threadName; + + LogEntry(std::string message, LogLevel logLevel) + : message(std::move(message)) + , logLevel(logLevel) { - INFO, - WARNING, - ERROR, - DEBUG, + // Get thread name + std::array threadNameBuf = {}; + + if (::pthread_getname_np(::pthread_self(), threadNameBuf.data(), threadNameBuf.size()) == 0) { + /* + * The name of the main thread is also the name of the process, so we have to name the + * main thread "Bloom" (to prevent confusion). + * + * We override the main thread name when printing logs, to keep the format of the thread name in the + * logs consistent. + */ + this->threadName = std::string(threadNameBuf.data()); + this->threadName = this->threadName == "Bloom" ? "MT" : this->threadName; + } }; - class LogEntry - { - public: - std::uint32_t id = ++(LogEntry::lastLogId); - std::string message; - LogLevel logLevel; - QDateTime timestamp = Services::DateTimeService::currentDateTime(); - std::string threadName; +private: + static inline std::atomic lastLogId = 0; +}; - LogEntry(std::string message, LogLevel logLevel) - : message(std::move(message)) - , logLevel(logLevel) - { - // Get thread name - std::array threadNameBuf = {}; +/** + * Super simple thread safe static Logger class for basic logging. + */ +class Logger +{ +public: + static void configure(const ProjectConfig& projectConfig); - if (::pthread_getname_np(::pthread_self(), threadNameBuf.data(), threadNameBuf.size()) == 0) { - /* - * The name of the main thread is also the name of the process, so we have to name the - * main thread "Bloom" (to prevent confusion). - * - * We override the main thread name when printing logs, to keep the format of the thread name in the - * logs consistent. - */ - this->threadName = std::string(threadNameBuf.data()); - this->threadName = this->threadName == "Bloom" ? "MT" : this->threadName; - } - }; + static void silence(); - private: - static inline std::atomic lastLogId = 0; - }; - - /** - * Super simple thread safe static Logger class for basic logging. - */ - class Logger - { - public: - static void configure(const ProjectConfig& projectConfig); - - static void silence(); - - static void info(const std::string& message) { - if (Logger::infoPrintingEnabled) { - Logger::log(LogEntry(message, LogLevel::INFO)); - } + static void info(const std::string& message) { + if (Logger::infoPrintingEnabled) { + Logger::log(LogEntry(message, LogLevel::INFO)); } + } - static void warning(const std::string& message) { - if (Logger::warningPrintingEnabled) { - Logger::log(LogEntry(message, LogLevel::WARNING)); - } + static void warning(const std::string& message) { + if (Logger::warningPrintingEnabled) { + Logger::log(LogEntry(message, LogLevel::WARNING)); } + } - static void error(const std::string& message) { - if (Logger::errorPrintingEnabled) { - Logger::log(LogEntry(message, LogLevel::ERROR)); - } + static void error(const std::string& message) { + if (Logger::errorPrintingEnabled) { + Logger::log(LogEntry(message, LogLevel::ERROR)); } + } - static void debug(const std::string& message) { - if (Logger::debugPrintingEnabled) { - Logger::log(LogEntry(message, LogLevel::DEBUG)); - } + static void debug(const std::string& message) { + if (Logger::debugPrintingEnabled) { + Logger::log(LogEntry(message, LogLevel::DEBUG)); } + } - private: - static inline bool errorPrintingEnabled = true; - static inline bool warningPrintingEnabled = true; - static inline bool infoPrintingEnabled = true; - static inline bool debugPrintingEnabled = false; +private: + static inline bool errorPrintingEnabled = true; + static inline bool warningPrintingEnabled = true; + static inline bool infoPrintingEnabled = true; + static inline bool debugPrintingEnabled = false; - static inline std::mutex printMutex; + static inline std::mutex printMutex; - static void log(const LogEntry& logEntry); - }; -} + static void log(const LogEntry& logEntry); +}; diff --git a/src/ProjectConfig.cpp b/src/ProjectConfig.cpp index 76eee5a9..503720b0 100644 --- a/src/ProjectConfig.cpp +++ b/src/ProjectConfig.cpp @@ -4,168 +4,165 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/InvalidConfig.hpp" -namespace Bloom -{ - using Services::StringService; +using Services::StringService; - ProjectConfig::ProjectConfig(const YAML::Node& configNode) { - if (!configNode["environments"]) { - throw Exceptions::InvalidConfig( - "No environments found - please review the bloom.yaml configuration file and ensure that " - "no syntax errors are present." - ); - } +ProjectConfig::ProjectConfig(const YAML::Node& configNode) { + if (!configNode["environments"]) { + throw Exceptions::InvalidConfig( + "No environments found - please review the bloom.yaml configuration file and ensure that " + "no syntax errors are present." + ); + } - if (!configNode["environments"].IsMap()) { - throw Exceptions::InvalidConfig( - "Invalid environments configuration provided - 'environments' must be of mapping type." - ); - } + if (!configNode["environments"].IsMap()) { + throw Exceptions::InvalidConfig( + "Invalid environments configuration provided - 'environments' must be of mapping type." + ); + } - const auto& environments = configNode["environments"]; + const auto& environments = configNode["environments"]; - for (auto environmentIt = environments.begin(); environmentIt != environments.end(); environmentIt++) { - auto environmentName = std::optional(std::nullopt); + for (auto environmentIt = environments.begin(); environmentIt != environments.end(); environmentIt++) { + auto environmentName = std::optional(std::nullopt); - try { - environmentName = environmentIt->first.as(); + try { + environmentName = environmentIt->first.as(); - if (!StringService::isAscii(environmentName.value())) { - throw Exceptions::InvalidConfig( - "Environment name ('" + environmentName.value() + "') is not in ASCII form." - ); - } - - this->environments.insert( - std::pair( - environmentName.value(), - EnvironmentConfig(environmentName.value(), environmentIt->second) - ) - ); - - } catch (Exceptions::InvalidConfig& exception) { - Logger::error( - "Invalid environment config for environment '" + environmentName.value() + "': " - + exception.getMessage() + " Environment will be ignored." - ); - - } catch (YAML::BadConversion& exception) { - Logger::error( - "Invalid environment name provided. Environment names must be ASCII strings. Environment will be " - "ignored" + if (!StringService::isAscii(environmentName.value())) { + throw Exceptions::InvalidConfig( + "Environment name ('" + environmentName.value() + "') is not in ASCII form." ); } - } - if (configNode["server"]) { - this->debugServerConfig = DebugServerConfig(configNode["server"]); - } - - if (configNode["insight"]) { - this->insightConfig = InsightConfig(configNode["insight"]); - } - - if (configNode["debugLoggingEnabled"]) { - this->debugLoggingEnabled = configNode["debugLoggingEnabled"].as(this->debugLoggingEnabled); - } - } - - InsightConfig::InsightConfig(const YAML::Node& insightNode) { - if (!insightNode.IsMap()) { - throw Exceptions::InvalidConfig( - "Invalid insight configuration provided - node must take the form of a YAML mapping." + this->environments.insert( + std::pair( + environmentName.value(), + EnvironmentConfig(environmentName.value(), environmentIt->second) + ) ); - } - if (insightNode["activateOnStartup"]) { - this->activateOnStartup = insightNode["activateOnStartup"].as(this->activateOnStartup); - } + } catch (Exceptions::InvalidConfig& exception) { + Logger::error( + "Invalid environment config for environment '" + environmentName.value() + "': " + + exception.getMessage() + " Environment will be ignored." + ); - if (insightNode["shutdownOnClose"]) { - this->shutdownOnClose = insightNode["shutdownOnClose"].as(this->shutdownOnClose); - } - } - - EnvironmentConfig::EnvironmentConfig(std::string name, const YAML::Node& environmentNode) - : name(std::move(name)) - { - if (!environmentNode.IsMap()) { - throw Exceptions::InvalidConfig("Environment node must take the form of a YAML mapping."); - } - - if (!environmentNode["tool"]) { - throw Exceptions::InvalidConfig("Missing debug tool configuration."); - } - - if (!environmentNode["target"]) { - throw Exceptions::InvalidConfig("Missing target configuration."); - } - - this->debugToolConfig = DebugToolConfig(environmentNode["tool"]); - this->targetConfig = TargetConfig(environmentNode["target"]); - - if (environmentNode["server"]) { - this->debugServerConfig = DebugServerConfig(environmentNode["server"]); - } - - if (environmentNode["insight"]) { - this->insightConfig = InsightConfig(environmentNode["insight"]); - } - - if (environmentNode["shutdownPostDebugSession"]) { - this->shutdownPostDebugSession = environmentNode["shutdownPostDebugSession"].as( - this->shutdownPostDebugSession + } catch (YAML::BadConversion& exception) { + Logger::error( + "Invalid environment name provided. Environment names must be ASCII strings. Environment will be " + "ignored" ); } } - TargetConfig::TargetConfig(const YAML::Node& targetNode) { - if (!targetNode.IsMap()) { - throw Exceptions::InvalidConfig( - "Invalid target configuration provided - node must take the form of a YAML mapping." - ); - } - - if (!targetNode["name"]) { - throw Exceptions::InvalidConfig("No target name found."); - } - - this->name = StringService::asciiToLower(targetNode["name"].as()); - - if (targetNode["variantName"]) { - this->variantName = StringService::asciiToLower(targetNode["variantName"].as()); - } - - this->targetNode = targetNode; + if (configNode["server"]) { + this->debugServerConfig = DebugServerConfig(configNode["server"]); } - DebugToolConfig::DebugToolConfig(const YAML::Node& debugToolNode) { - if (!debugToolNode.IsMap()) { - throw Exceptions::InvalidConfig( - "Invalid debug tool configuration provided - node must take the form of a YAML mapping." - ); - } - - if (!debugToolNode["name"]) { - throw Exceptions::InvalidConfig("No debug tool name found."); - } - - this->name = StringService::asciiToLower(debugToolNode["name"].as()); - this->debugToolNode = debugToolNode; + if (configNode["insight"]) { + this->insightConfig = InsightConfig(configNode["insight"]); } - DebugServerConfig::DebugServerConfig(const YAML::Node& debugServerNode) { - if (!debugServerNode.IsMap()) { - throw Exceptions::InvalidConfig( - "Invalid debug server configuration provided - node must take the form of a YAML mapping." - ); - } - - if (!debugServerNode["name"]) { - throw Exceptions::InvalidConfig("No debug server name found."); - } - - this->name = StringService::asciiToLower(debugServerNode["name"].as()); - this->debugServerNode = debugServerNode; + if (configNode["debugLoggingEnabled"]) { + this->debugLoggingEnabled = configNode["debugLoggingEnabled"].as(this->debugLoggingEnabled); } } + +InsightConfig::InsightConfig(const YAML::Node& insightNode) { + if (!insightNode.IsMap()) { + throw Exceptions::InvalidConfig( + "Invalid insight configuration provided - node must take the form of a YAML mapping." + ); + } + + if (insightNode["activateOnStartup"]) { + this->activateOnStartup = insightNode["activateOnStartup"].as(this->activateOnStartup); + } + + if (insightNode["shutdownOnClose"]) { + this->shutdownOnClose = insightNode["shutdownOnClose"].as(this->shutdownOnClose); + } +} + +EnvironmentConfig::EnvironmentConfig(std::string name, const YAML::Node& environmentNode) + : name(std::move(name)) +{ + if (!environmentNode.IsMap()) { + throw Exceptions::InvalidConfig("Environment node must take the form of a YAML mapping."); + } + + if (!environmentNode["tool"]) { + throw Exceptions::InvalidConfig("Missing debug tool configuration."); + } + + if (!environmentNode["target"]) { + throw Exceptions::InvalidConfig("Missing target configuration."); + } + + this->debugToolConfig = DebugToolConfig(environmentNode["tool"]); + this->targetConfig = TargetConfig(environmentNode["target"]); + + if (environmentNode["server"]) { + this->debugServerConfig = DebugServerConfig(environmentNode["server"]); + } + + if (environmentNode["insight"]) { + this->insightConfig = InsightConfig(environmentNode["insight"]); + } + + if (environmentNode["shutdownPostDebugSession"]) { + this->shutdownPostDebugSession = environmentNode["shutdownPostDebugSession"].as( + this->shutdownPostDebugSession + ); + } +} + +TargetConfig::TargetConfig(const YAML::Node& targetNode) { + if (!targetNode.IsMap()) { + throw Exceptions::InvalidConfig( + "Invalid target configuration provided - node must take the form of a YAML mapping." + ); + } + + if (!targetNode["name"]) { + throw Exceptions::InvalidConfig("No target name found."); + } + + this->name = StringService::asciiToLower(targetNode["name"].as()); + + if (targetNode["variantName"]) { + this->variantName = StringService::asciiToLower(targetNode["variantName"].as()); + } + + this->targetNode = targetNode; +} + +DebugToolConfig::DebugToolConfig(const YAML::Node& debugToolNode) { + if (!debugToolNode.IsMap()) { + throw Exceptions::InvalidConfig( + "Invalid debug tool configuration provided - node must take the form of a YAML mapping." + ); + } + + if (!debugToolNode["name"]) { + throw Exceptions::InvalidConfig("No debug tool name found."); + } + + this->name = StringService::asciiToLower(debugToolNode["name"].as()); + this->debugToolNode = debugToolNode; +} + +DebugServerConfig::DebugServerConfig(const YAML::Node& debugServerNode) { + if (!debugServerNode.IsMap()) { + throw Exceptions::InvalidConfig( + "Invalid debug server configuration provided - node must take the form of a YAML mapping." + ); + } + + if (!debugServerNode["name"]) { + throw Exceptions::InvalidConfig("No debug server name found."); + } + + this->name = StringService::asciiToLower(debugServerNode["name"].as()); + this->debugServerNode = debugServerNode; +} diff --git a/src/ProjectConfig.hpp b/src/ProjectConfig.hpp index c66972d1..4a7158c3 100644 --- a/src/ProjectConfig.hpp +++ b/src/ProjectConfig.hpp @@ -6,229 +6,226 @@ #include #include -namespace Bloom +/* + * Currently, all user configuration is stored in a YAML file (bloom.yaml), in the user's project directory. + * + * The YAML config file should define parameters for specific debug environments. Because a config file can define + * multiple debug environments, each environment must be assigned a unique name that can be used to identify the + * environment. This is why the 'environments' parameter is a YAML map, with the key being the environment name. + * + * On application start up, we extract the config from this YAML file and generate a ProjectConfig object. + * See Application::loadProjectConfiguration() for more on this. + * + * Some config parameters are specific to certain entities within Bloom, but have no significance across the + * rest of the application. For example, AVR8 targets require the 'physicalInterface' and other AVR8 specific + * parameters. These are used to configure AVR8 targets, but have no significance across the rest of the + * application. This is why some configuration structs (like TargetConfig) include a YAML::Node member. + * When instances of these structs are passed to the appropriate entities, any configuration required by those + * entities is extracted from the YAML::Node member. This means we don't have to worry about any entity specific + * config parameters at the application level. We can simply extract what we need at an entity level and the rest + * of the application can remain oblivious. For an example on extracting entity specific config, see + * Avr8TargetConfig::Avr8TargetConfig() and Avr8::preActivationConfigure(). + * + * For more on project configuration, see Bloom documentation at https://bloom.oscillate.io/docs/configuration + */ + +/** + * Configuration relating to a specific target. + * + * Please don't define any target specific configuration here, unless it applies to *all* targets across + * the application. If a target requires specific config, it should be extracted from the YAML::Node (targetNode) + * member. This should be done in Target::preActivationConfigure(), to which an instance of TargetConfig is passed. + * See the comment above on entity specific config for more on this. + */ +struct TargetConfig { - /* - * Currently, all user configuration is stored in a YAML file (bloom.yaml), in the user's project directory. - * - * The YAML config file should define parameters for specific debug environments. Because a config file can define - * multiple debug environments, each environment must be assigned a unique name that can be used to identify the - * environment. This is why the 'environments' parameter is a YAML map, with the key being the environment name. - * - * On application start up, we extract the config from this YAML file and generate a ProjectConfig object. - * See Application::loadProjectConfiguration() for more on this. - * - * Some config parameters are specific to certain entities within Bloom, but have no significance across the - * rest of the application. For example, AVR8 targets require the 'physicalInterface' and other AVR8 specific - * parameters. These are used to configure AVR8 targets, but have no significance across the rest of the - * application. This is why some configuration structs (like TargetConfig) include a YAML::Node member. - * When instances of these structs are passed to the appropriate entities, any configuration required by those - * entities is extracted from the YAML::Node member. This means we don't have to worry about any entity specific - * config parameters at the application level. We can simply extract what we need at an entity level and the rest - * of the application can remain oblivious. For an example on extracting entity specific config, see - * Avr8TargetConfig::Avr8TargetConfig() and Avr8::preActivationConfigure(). - * - * For more on project configuration, see Bloom documentation at https://bloom.oscillate.io/docs/configuration + /** + * The name of the selected target. */ + std::string name; /** - * Configuration relating to a specific target. + * The name of the selected target variant. * - * Please don't define any target specific configuration here, unless it applies to *all* targets across - * the application. If a target requires specific config, it should be extracted from the YAML::Node (targetNode) - * member. This should be done in Target::preActivationConfigure(), to which an instance of TargetConfig is passed. - * See the comment above on entity specific config for more on this. + * Insight uses this to determine which variant to select on start up. */ - struct TargetConfig - { - /** - * The name of the selected target. - */ - std::string name; - - /** - * The name of the selected target variant. - * - * Insight uses this to determine which variant to select on start up. - */ - std::optional variantName; - - /** - * For extracting any target specific configuration. See Avr8TargetConfig::Avr8TargetConfig() and - * Avr8::preActivationConfigure() for an example of this. - */ - YAML::Node targetNode; - - TargetConfig() = default; - - /** - * Obtains config parameters from YAML node. - * - * @param targetNode - */ - explicit TargetConfig(const YAML::Node& targetNode); - }; + std::optional variantName; /** - * Configuration relating to a specific debug tool. + * For extracting any target specific configuration. See Avr8TargetConfig::Avr8TargetConfig() and + * Avr8::preActivationConfigure() for an example of this. + */ + YAML::Node targetNode; + + TargetConfig() = default; + + /** + * Obtains config parameters from YAML node. * - * As with the TargetConfig struct, please don't add any manufacture/model specific configuration here. This - * configuration should apply to all supported debug tools. Specific configuration can be extracted from the - * YAML::Node (debugToolNode) member, as described in the TargetConfig comment above. + * @param targetNode */ - struct DebugToolConfig - { - /** - * The name of the selected debug tool. - */ - std::string name; + explicit TargetConfig(const YAML::Node& targetNode); +}; - /** - * For extracting any debug tool specific configuration. - */ - YAML::Node debugToolNode; - - DebugToolConfig() = default; - - /** - * Obtains config parameters from YAML node. - * - * @param debugToolNode - */ - explicit DebugToolConfig(const YAML::Node& debugToolNode); - }; +/** + * Configuration relating to a specific debug tool. + * + * As with the TargetConfig struct, please don't add any manufacture/model specific configuration here. This + * configuration should apply to all supported debug tools. Specific configuration can be extracted from the + * YAML::Node (debugToolNode) member, as described in the TargetConfig comment above. + */ +struct DebugToolConfig +{ + /** + * The name of the selected debug tool. + */ + std::string name; /** - * Debug server configuration. + * For extracting any debug tool specific configuration. */ - struct DebugServerConfig - { - /** - * The name of the selected debug server. - */ - std::string name; + YAML::Node debugToolNode; - /** - * For extracting any debug server specific configuration. See GdbDebugServerConfig::GdbDebugServerConfig() and - * GdbRspDebugServer::GdbRspDebugServer() for an example of this. - */ - YAML::Node debugServerNode; - - DebugServerConfig() = default; - - /** - * Obtains config parameters from YAML node. - * - * @param debugServerNode - */ - explicit DebugServerConfig(const YAML::Node& debugServerNode); - }; - - struct InsightConfig - { - /** - * If true, the Insight GUI will be activated immediately at startup. - */ - bool activateOnStartup = false; - - /** - * If true, Bloom will shutdown when the user closes the Insight GUI. - */ - bool shutdownOnClose = false; - - InsightConfig() = default; - - /** - * Obtains config parameters from YAML node. - * - * @param insightNode - */ - explicit InsightConfig(const YAML::Node& insightNode); - }; + DebugToolConfig() = default; /** - * Configuration relating to a specific user defined environment. + * Obtains config parameters from YAML node. * - * An instance of this type will be instantiated for each environment defined in the user's config file. - * See Application::loadProjectConfiguration() implementation for more on this. + * @param debugToolNode */ - struct EnvironmentConfig - { - /** - * The environment name is stored as the key to the YAML map containing the environment parameters. - * - * Environment names must be unique. - */ - std::string name; + explicit DebugToolConfig(const YAML::Node& debugToolNode); +}; - /** - * Flag to determine whether Bloom should shutdown at the end of a debug session. - */ - bool shutdownPostDebugSession = false; - - /** - * Configuration for the environment's selected debug tool. - * - * Each environment can select only one debug tool. - */ - DebugToolConfig debugToolConfig; - - /** - * Configuration for the environment's selected target. - * - * Each environment can select only one target. - */ - TargetConfig targetConfig; - - /** - * Configuration for the environment's debug server. Users can define this at the application level if - * they desire. - */ - std::optional debugServerConfig; - - /** - * Insight configuration can be defined at an environment level as well as at an application level. - */ - std::optional insightConfig; - - /** - * Obtains config parameters from YAML node. - * - * @param name - * @param environmentNode - */ - EnvironmentConfig(std::string name, const YAML::Node& environmentNode); - }; +/** + * Debug server configuration. + */ +struct DebugServerConfig +{ + /** + * The name of the selected debug server. + */ + std::string name; /** - * This holds all user provided project configuration. + * For extracting any debug server specific configuration. See GdbDebugServerConfig::GdbDebugServerConfig() and + * GdbRspDebugServer::GdbRspDebugServer() for an example of this. */ - struct ProjectConfig - { - /** - * A mapping of environment names to EnvironmentConfig objects. - */ - std::map environments; + YAML::Node debugServerNode; - /** - * Application level debug server configuration. We use this as a fallback if no debug server config is - * provided at the environment level. - */ - std::optional debugServerConfig; + DebugServerConfig() = default; - /** - * Application level Insight configuration. We use this as a fallback if no Insight config is provided at - * the environment level. - */ - std::optional insightConfig; + /** + * Obtains config parameters from YAML node. + * + * @param debugServerNode + */ + explicit DebugServerConfig(const YAML::Node& debugServerNode); +}; - bool debugLoggingEnabled = false; +struct InsightConfig +{ + /** + * If true, the Insight GUI will be activated immediately at startup. + */ + bool activateOnStartup = false; - /** - * Obtains config parameters from YAML node. - * - * @param configNode - */ - explicit ProjectConfig(const YAML::Node& configNode); - }; -} + /** + * If true, Bloom will shutdown when the user closes the Insight GUI. + */ + bool shutdownOnClose = false; + + InsightConfig() = default; + + /** + * Obtains config parameters from YAML node. + * + * @param insightNode + */ + explicit InsightConfig(const YAML::Node& insightNode); +}; + +/** + * Configuration relating to a specific user defined environment. + * + * An instance of this type will be instantiated for each environment defined in the user's config file. + * See Application::loadProjectConfiguration() implementation for more on this. + */ +struct EnvironmentConfig +{ + /** + * The environment name is stored as the key to the YAML map containing the environment parameters. + * + * Environment names must be unique. + */ + std::string name; + + /** + * Flag to determine whether Bloom should shutdown at the end of a debug session. + */ + bool shutdownPostDebugSession = false; + + /** + * Configuration for the environment's selected debug tool. + * + * Each environment can select only one debug tool. + */ + DebugToolConfig debugToolConfig; + + /** + * Configuration for the environment's selected target. + * + * Each environment can select only one target. + */ + TargetConfig targetConfig; + + /** + * Configuration for the environment's debug server. Users can define this at the application level if + * they desire. + */ + std::optional debugServerConfig; + + /** + * Insight configuration can be defined at an environment level as well as at an application level. + */ + std::optional insightConfig; + + /** + * Obtains config parameters from YAML node. + * + * @param name + * @param environmentNode + */ + EnvironmentConfig(std::string name, const YAML::Node& environmentNode); +}; + +/** + * This holds all user provided project configuration. + */ +struct ProjectConfig +{ + /** + * A mapping of environment names to EnvironmentConfig objects. + */ + std::map environments; + + /** + * Application level debug server configuration. We use this as a fallback if no debug server config is + * provided at the environment level. + */ + std::optional debugServerConfig; + + /** + * Application level Insight configuration. We use this as a fallback if no Insight config is provided at + * the environment level. + */ + std::optional insightConfig; + + bool debugLoggingEnabled = false; + + /** + * Obtains config parameters from YAML node. + * + * @param configNode + */ + explicit ProjectConfig(const YAML::Node& configNode); +}; diff --git a/src/ProjectSettings.cpp b/src/ProjectSettings.cpp index 2db466d2..3e241e8b 100644 --- a/src/ProjectSettings.cpp +++ b/src/ProjectSettings.cpp @@ -6,355 +6,353 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - ProjectSettings::ProjectSettings(const QJsonObject& jsonObject) { + +ProjectSettings::ProjectSettings(const QJsonObject& jsonObject) { #ifndef EXCLUDE_INSIGHT - if (jsonObject.contains("insight")) { - this->insightSettings = InsightProjectSettings(jsonObject.find("insight")->toObject()); - } -#endif - } - - QJsonObject ProjectSettings::toJson() const { - auto projectSettingsObj = QJsonObject(); - -#ifndef EXCLUDE_INSIGHT - projectSettingsObj.insert("insight", this->insightSettings.toJson()); -#endif - - return projectSettingsObj; - } - -#ifndef EXCLUDE_INSIGHT - InsightProjectSettings::InsightProjectSettings(const QJsonObject& jsonObject) { - if (jsonObject.contains("mainWindowSize")) { - const auto mainWindowSizeObj = jsonObject.find("mainWindowSize")->toObject(); - - if (mainWindowSizeObj.contains("width") && mainWindowSizeObj.contains("height")) { - this->mainWindowSize = QSize( - mainWindowSizeObj.find("width")->toInt(), - mainWindowSizeObj.find("height")->toInt() - ); - } - } - - if (jsonObject.contains("leftPanelState")) { - this->leftPanelState = this->panelStateFromJson( - jsonObject.find("leftPanelState")->toObject() - ); - } - - if (jsonObject.contains("bottomPanelState")) { - this->bottomPanelState = this->panelStateFromJson( - jsonObject.find("bottomPanelState")->toObject() - ); - } - - if (jsonObject.contains("registersPaneState")) { - this->registersPaneState = this->paneStateFromJson( - jsonObject.find("registersPaneState")->toObject() - ); - } - - if (jsonObject.contains("ramInspectionPaneState")) { - this->ramInspectionPaneState = this->paneStateFromJson( - jsonObject.find("ramInspectionPaneState")->toObject() - ); - } - - if (jsonObject.contains("eepromInspectionPaneState")) { - this->eepromInspectionPaneState = this->paneStateFromJson( - jsonObject.find("eepromInspectionPaneState")->toObject() - ); - } - - if (jsonObject.contains("flashInspectionPaneState")) { - this->flashInspectionPaneState = this->paneStateFromJson( - jsonObject.find("flashInspectionPaneState")->toObject() - ); - } - - if (jsonObject.contains("memoryInspectionPaneSettings")) { - const auto settingsMappingObj = jsonObject.find("memoryInspectionPaneSettings")->toObject(); - - for (auto settingsIt = settingsMappingObj.begin(); settingsIt != settingsMappingObj.end(); settingsIt++) { - const auto settingsObj = settingsIt.value().toObject(); - const auto memoryTypeName = settingsIt.key(); - - if (!EnumToStringMappings::targetMemoryTypes.contains(memoryTypeName)) { - continue; - } - - this->memoryInspectionPaneSettingsByMemoryType.insert(std::pair( - EnumToStringMappings::targetMemoryTypes.at(memoryTypeName), - this->memoryInspectionPaneSettingsFromJson(settingsObj) - )); - } - } - } - - QJsonObject InsightProjectSettings::toJson() const { - auto insightObj = QJsonObject(); - - if (this->mainWindowSize.has_value()) { - insightObj.insert("mainWindowSize", QJsonObject({ - {"width", this->mainWindowSize->width()}, - {"height", this->mainWindowSize->height()}, - })); - } - - auto memoryInspectionPaneSettingsObj = QJsonObject(); - - for (const auto& [memoryType, inspectionPaneSettings] : this->memoryInspectionPaneSettingsByMemoryType) { - if (!EnumToStringMappings::targetMemoryTypes.contains(memoryType)) { - // This is just a precaution - all known memory types should be in the mapping. - continue; - } - - memoryInspectionPaneSettingsObj.insert( - EnumToStringMappings::targetMemoryTypes.at(memoryType), - this->memoryInspectionPaneSettingsToJson(inspectionPaneSettings) - ); - } - - insightObj.insert("memoryInspectionPaneSettings", memoryInspectionPaneSettingsObj); - - if (this->leftPanelState.has_value()) { - insightObj.insert( - "leftPanelState", - this->panelStateToJson(this->leftPanelState.value()) - ); - } - - if (this->bottomPanelState.has_value()) { - insightObj.insert( - "bottomPanelState", - this->panelStateToJson(this->bottomPanelState.value()) - ); - } - - if (this->registersPaneState.has_value()) { - insightObj.insert( - "registersPaneState", - this->paneStateToJson(this->registersPaneState.value()) - ); - } - - if (this->ramInspectionPaneState.has_value()) { - insightObj.insert( - "ramInspectionPaneState", - this->paneStateToJson(this->ramInspectionPaneState.value()) - ); - } - - if (this->eepromInspectionPaneState.has_value()) { - insightObj.insert( - "eepromInspectionPaneState", - this->paneStateToJson(this->eepromInspectionPaneState.value()) - ); - } - - if (this->flashInspectionPaneState.has_value()) { - insightObj.insert( - "flashInspectionPaneState", - this->paneStateToJson(this->flashInspectionPaneState.value()) - ); - } - - return insightObj; - } - - Widgets::TargetMemoryInspectionPaneSettings InsightProjectSettings::memoryInspectionPaneSettingsFromJson( - const QJsonObject& jsonObject - ) const { - using Exceptions::Exception; - - auto inspectionPaneSettings = Widgets::TargetMemoryInspectionPaneSettings(); - - if (jsonObject.contains("refreshOnTargetStop")) { - inspectionPaneSettings.refreshOnTargetStop = jsonObject.value("refreshOnTargetStop").toBool(); - } - - if (jsonObject.contains("refreshOnActivation")) { - inspectionPaneSettings.refreshOnActivation = jsonObject.value("refreshOnActivation").toBool(); - } - - if (jsonObject.contains("hexViewerSettings")) { - auto& hexViewerSettings = inspectionPaneSettings.hexViewerWidgetSettings; - const auto hexViewerSettingsObj = jsonObject.find("hexViewerSettings")->toObject(); - - if (hexViewerSettingsObj.contains("groupStackMemory")) { - hexViewerSettings.groupStackMemory = - hexViewerSettingsObj.value("groupStackMemory").toBool(); - } - - if (hexViewerSettingsObj.contains("highlightFocusedMemory")) { - hexViewerSettings.highlightFocusedMemory = - hexViewerSettingsObj.value("highlightFocusedMemory").toBool(); - } - - if (hexViewerSettingsObj.contains("highlightHoveredRowAndCol")) { - hexViewerSettings.highlightHoveredRowAndCol = - hexViewerSettingsObj.value("highlightHoveredRowAndCol").toBool(); - } - - if (hexViewerSettingsObj.contains("displayAsciiValues")) { - hexViewerSettings.displayAsciiValues = - hexViewerSettingsObj.value("displayAsciiValues").toBool(); - } - - if (hexViewerSettingsObj.contains("displayAnnotations")) { - hexViewerSettings.displayAnnotations = - hexViewerSettingsObj.value("displayAnnotations").toBool(); - } - - if (hexViewerSettingsObj.contains("addressLabelType")) { - hexViewerSettings.addressLabelType = InsightProjectSettings::addressTypesByName.valueAt( - hexViewerSettingsObj.value("addressLabelType").toString() - ).value_or(hexViewerSettings.addressLabelType); - } - } - - if (jsonObject.contains("focusedRegions")) { - for (const auto& regionValue : jsonObject.find("focusedRegions")->toArray()) { - try { - inspectionPaneSettings.focusedMemoryRegions.emplace_back(regionValue.toObject()); - - } catch (Exception exception) { - Logger::warning( - "Failed to parse focused memory region from project settings file - " - + exception.getMessage() + " - region will be ignored." - ); - } - } - } - - if (jsonObject.contains("excludedRegions")) { - for (const auto& regionValue : jsonObject.find("excludedRegions")->toArray()) { - try { - inspectionPaneSettings.excludedMemoryRegions.emplace_back(regionValue.toObject()); - - } catch (Exception exception) { - Logger::warning( - "Failed to parse excluded memory region from project settings file - " - + exception.getMessage() + " - region will be ignored." - ); - } - } - } - - return inspectionPaneSettings; - } - - Widgets::PanelState InsightProjectSettings::panelStateFromJson(const QJsonObject& jsonObject) const { - return Widgets::PanelState( - (jsonObject.contains("size") ? static_cast(jsonObject.value("size").toInteger()) : 0), - (jsonObject.contains("open") ? jsonObject.value("open").toBool() : false) - ); - } - - Widgets::PaneState InsightProjectSettings::paneStateFromJson(const QJsonObject& jsonObject) const { - auto detachedWindowState = std::optional(std::nullopt); - - if (jsonObject.contains("detachedWindowState")) { - detachedWindowState = Widgets::DetachedWindowState(); - - const auto detachedWindowStateObject = jsonObject.value("detachedWindowState").toObject(); - - if (detachedWindowStateObject.contains("size")) { - const auto sizeObject = detachedWindowStateObject.value("size").toObject(); - detachedWindowState->size = QSize( - sizeObject.value("width").toInt(0), - sizeObject.value("height").toInt(0) - ); - } - - if (detachedWindowStateObject.contains("position")) { - const auto positionObject = detachedWindowStateObject.value("position").toObject(); - detachedWindowState->position = QPoint( - positionObject.value("x").toInt(0), - positionObject.value("y").toInt(0) - ); - } - } - - return Widgets::PaneState( - (jsonObject.contains("activated") ? jsonObject.value("activated").toBool() : false), - (jsonObject.contains("attached") ? jsonObject.value("attached").toBool() : true), - detachedWindowState - ); - } - - QJsonObject InsightProjectSettings::memoryInspectionPaneSettingsToJson( - const Widgets::TargetMemoryInspectionPaneSettings& inspectionPaneSettings - ) const { - const auto& addressTypesByName = InsightProjectSettings::addressTypesByName; - - auto settingsObj = QJsonObject({ - {"refreshOnTargetStop", inspectionPaneSettings.refreshOnTargetStop}, - {"refreshOnActivation", inspectionPaneSettings.refreshOnActivation}, - }); - - const auto& hexViewerSettings = inspectionPaneSettings.hexViewerWidgetSettings; - settingsObj.insert("hexViewerSettings", QJsonObject({ - {"groupStackMemory", hexViewerSettings.groupStackMemory}, - {"highlightFocusedMemory", hexViewerSettings.highlightFocusedMemory}, - {"highlightHoveredRowAndCol", hexViewerSettings.highlightHoveredRowAndCol}, - {"displayAsciiValues", hexViewerSettings.displayAsciiValues}, - {"displayAnnotations", hexViewerSettings.displayAnnotations}, - {"addressLabelType", addressTypesByName.valueAt(hexViewerSettings.addressLabelType).value()}, - })); - - auto focusedRegions = QJsonArray(); - for (const auto& focusedRegion : inspectionPaneSettings.focusedMemoryRegions) { - focusedRegions.push_back(focusedRegion.toJson()); - } - - auto excludedRegions = QJsonArray(); - for (const auto& excludedRegion : inspectionPaneSettings.excludedMemoryRegions) { - excludedRegions.push_back(excludedRegion.toJson()); - } - - settingsObj.insert("focusedRegions", focusedRegions); - settingsObj.insert("excludedRegions", excludedRegions); - - return settingsObj; - } - - QJsonObject InsightProjectSettings::panelStateToJson(const Widgets::PanelState& panelState) const { - return QJsonObject({ - {"size", panelState.size}, - {"open", panelState.open}, - }); - } - - QJsonObject InsightProjectSettings::paneStateToJson(const Widgets::PaneState& paneState) const { - auto json = QJsonObject({ - {"activated", paneState.activated}, - {"attached", paneState.attached}, - }); - - if (paneState.detachedWindowState.has_value()) { - json.insert("detachedWindowState", QJsonObject({ - { - "size", - QJsonObject({ - {"width", paneState.detachedWindowState->size.width()}, - {"height", paneState.detachedWindowState->size.height()}, - }) - }, - { - "position", - QJsonObject({ - {"x", paneState.detachedWindowState->position.x()}, - {"y", paneState.detachedWindowState->position.y()}, - }) - } - })); - } - - return json; + if (jsonObject.contains("insight")) { + this->insightSettings = InsightProjectSettings(jsonObject.find("insight")->toObject()); } #endif } + +QJsonObject ProjectSettings::toJson() const { + auto projectSettingsObj = QJsonObject(); + +#ifndef EXCLUDE_INSIGHT + projectSettingsObj.insert("insight", this->insightSettings.toJson()); +#endif + + return projectSettingsObj; +} + +#ifndef EXCLUDE_INSIGHT +InsightProjectSettings::InsightProjectSettings(const QJsonObject& jsonObject) { + if (jsonObject.contains("mainWindowSize")) { + const auto mainWindowSizeObj = jsonObject.find("mainWindowSize")->toObject(); + + if (mainWindowSizeObj.contains("width") && mainWindowSizeObj.contains("height")) { + this->mainWindowSize = QSize( + mainWindowSizeObj.find("width")->toInt(), + mainWindowSizeObj.find("height")->toInt() + ); + } + } + + if (jsonObject.contains("leftPanelState")) { + this->leftPanelState = this->panelStateFromJson( + jsonObject.find("leftPanelState")->toObject() + ); + } + + if (jsonObject.contains("bottomPanelState")) { + this->bottomPanelState = this->panelStateFromJson( + jsonObject.find("bottomPanelState")->toObject() + ); + } + + if (jsonObject.contains("registersPaneState")) { + this->registersPaneState = this->paneStateFromJson( + jsonObject.find("registersPaneState")->toObject() + ); + } + + if (jsonObject.contains("ramInspectionPaneState")) { + this->ramInspectionPaneState = this->paneStateFromJson( + jsonObject.find("ramInspectionPaneState")->toObject() + ); + } + + if (jsonObject.contains("eepromInspectionPaneState")) { + this->eepromInspectionPaneState = this->paneStateFromJson( + jsonObject.find("eepromInspectionPaneState")->toObject() + ); + } + + if (jsonObject.contains("flashInspectionPaneState")) { + this->flashInspectionPaneState = this->paneStateFromJson( + jsonObject.find("flashInspectionPaneState")->toObject() + ); + } + + if (jsonObject.contains("memoryInspectionPaneSettings")) { + const auto settingsMappingObj = jsonObject.find("memoryInspectionPaneSettings")->toObject(); + + for (auto settingsIt = settingsMappingObj.begin(); settingsIt != settingsMappingObj.end(); settingsIt++) { + const auto settingsObj = settingsIt.value().toObject(); + const auto memoryTypeName = settingsIt.key(); + + if (!EnumToStringMappings::targetMemoryTypes.contains(memoryTypeName)) { + continue; + } + + this->memoryInspectionPaneSettingsByMemoryType.insert(std::pair( + EnumToStringMappings::targetMemoryTypes.at(memoryTypeName), + this->memoryInspectionPaneSettingsFromJson(settingsObj) + )); + } + } +} + +QJsonObject InsightProjectSettings::toJson() const { + auto insightObj = QJsonObject(); + + if (this->mainWindowSize.has_value()) { + insightObj.insert("mainWindowSize", QJsonObject({ + {"width", this->mainWindowSize->width()}, + {"height", this->mainWindowSize->height()}, + })); + } + + auto memoryInspectionPaneSettingsObj = QJsonObject(); + + for (const auto& [memoryType, inspectionPaneSettings] : this->memoryInspectionPaneSettingsByMemoryType) { + if (!EnumToStringMappings::targetMemoryTypes.contains(memoryType)) { + // This is just a precaution - all known memory types should be in the mapping. + continue; + } + + memoryInspectionPaneSettingsObj.insert( + EnumToStringMappings::targetMemoryTypes.at(memoryType), + this->memoryInspectionPaneSettingsToJson(inspectionPaneSettings) + ); + } + + insightObj.insert("memoryInspectionPaneSettings", memoryInspectionPaneSettingsObj); + + if (this->leftPanelState.has_value()) { + insightObj.insert( + "leftPanelState", + this->panelStateToJson(this->leftPanelState.value()) + ); + } + + if (this->bottomPanelState.has_value()) { + insightObj.insert( + "bottomPanelState", + this->panelStateToJson(this->bottomPanelState.value()) + ); + } + + if (this->registersPaneState.has_value()) { + insightObj.insert( + "registersPaneState", + this->paneStateToJson(this->registersPaneState.value()) + ); + } + + if (this->ramInspectionPaneState.has_value()) { + insightObj.insert( + "ramInspectionPaneState", + this->paneStateToJson(this->ramInspectionPaneState.value()) + ); + } + + if (this->eepromInspectionPaneState.has_value()) { + insightObj.insert( + "eepromInspectionPaneState", + this->paneStateToJson(this->eepromInspectionPaneState.value()) + ); + } + + if (this->flashInspectionPaneState.has_value()) { + insightObj.insert( + "flashInspectionPaneState", + this->paneStateToJson(this->flashInspectionPaneState.value()) + ); + } + + return insightObj; +} + +Widgets::TargetMemoryInspectionPaneSettings InsightProjectSettings::memoryInspectionPaneSettingsFromJson( + const QJsonObject& jsonObject +) const { + using Exceptions::Exception; + + auto inspectionPaneSettings = Widgets::TargetMemoryInspectionPaneSettings(); + + if (jsonObject.contains("refreshOnTargetStop")) { + inspectionPaneSettings.refreshOnTargetStop = jsonObject.value("refreshOnTargetStop").toBool(); + } + + if (jsonObject.contains("refreshOnActivation")) { + inspectionPaneSettings.refreshOnActivation = jsonObject.value("refreshOnActivation").toBool(); + } + + if (jsonObject.contains("hexViewerSettings")) { + auto& hexViewerSettings = inspectionPaneSettings.hexViewerWidgetSettings; + const auto hexViewerSettingsObj = jsonObject.find("hexViewerSettings")->toObject(); + + if (hexViewerSettingsObj.contains("groupStackMemory")) { + hexViewerSettings.groupStackMemory = + hexViewerSettingsObj.value("groupStackMemory").toBool(); + } + + if (hexViewerSettingsObj.contains("highlightFocusedMemory")) { + hexViewerSettings.highlightFocusedMemory = + hexViewerSettingsObj.value("highlightFocusedMemory").toBool(); + } + + if (hexViewerSettingsObj.contains("highlightHoveredRowAndCol")) { + hexViewerSettings.highlightHoveredRowAndCol = + hexViewerSettingsObj.value("highlightHoveredRowAndCol").toBool(); + } + + if (hexViewerSettingsObj.contains("displayAsciiValues")) { + hexViewerSettings.displayAsciiValues = + hexViewerSettingsObj.value("displayAsciiValues").toBool(); + } + + if (hexViewerSettingsObj.contains("displayAnnotations")) { + hexViewerSettings.displayAnnotations = + hexViewerSettingsObj.value("displayAnnotations").toBool(); + } + + if (hexViewerSettingsObj.contains("addressLabelType")) { + hexViewerSettings.addressLabelType = InsightProjectSettings::addressTypesByName.valueAt( + hexViewerSettingsObj.value("addressLabelType").toString() + ).value_or(hexViewerSettings.addressLabelType); + } + } + + if (jsonObject.contains("focusedRegions")) { + for (const auto& regionValue : jsonObject.find("focusedRegions")->toArray()) { + try { + inspectionPaneSettings.focusedMemoryRegions.emplace_back(regionValue.toObject()); + + } catch (Exception exception) { + Logger::warning( + "Failed to parse focused memory region from project settings file - " + + exception.getMessage() + " - region will be ignored." + ); + } + } + } + + if (jsonObject.contains("excludedRegions")) { + for (const auto& regionValue : jsonObject.find("excludedRegions")->toArray()) { + try { + inspectionPaneSettings.excludedMemoryRegions.emplace_back(regionValue.toObject()); + + } catch (Exception exception) { + Logger::warning( + "Failed to parse excluded memory region from project settings file - " + + exception.getMessage() + " - region will be ignored." + ); + } + } + } + + return inspectionPaneSettings; +} + +Widgets::PanelState InsightProjectSettings::panelStateFromJson(const QJsonObject& jsonObject) const { + return Widgets::PanelState( + (jsonObject.contains("size") ? static_cast(jsonObject.value("size").toInteger()) : 0), + (jsonObject.contains("open") ? jsonObject.value("open").toBool() : false) + ); +} + +Widgets::PaneState InsightProjectSettings::paneStateFromJson(const QJsonObject& jsonObject) const { + auto detachedWindowState = std::optional(std::nullopt); + + if (jsonObject.contains("detachedWindowState")) { + detachedWindowState = Widgets::DetachedWindowState(); + + const auto detachedWindowStateObject = jsonObject.value("detachedWindowState").toObject(); + + if (detachedWindowStateObject.contains("size")) { + const auto sizeObject = detachedWindowStateObject.value("size").toObject(); + detachedWindowState->size = QSize( + sizeObject.value("width").toInt(0), + sizeObject.value("height").toInt(0) + ); + } + + if (detachedWindowStateObject.contains("position")) { + const auto positionObject = detachedWindowStateObject.value("position").toObject(); + detachedWindowState->position = QPoint( + positionObject.value("x").toInt(0), + positionObject.value("y").toInt(0) + ); + } + } + + return Widgets::PaneState( + (jsonObject.contains("activated") ? jsonObject.value("activated").toBool() : false), + (jsonObject.contains("attached") ? jsonObject.value("attached").toBool() : true), + detachedWindowState + ); +} + +QJsonObject InsightProjectSettings::memoryInspectionPaneSettingsToJson( + const Widgets::TargetMemoryInspectionPaneSettings& inspectionPaneSettings +) const { + const auto& addressTypesByName = InsightProjectSettings::addressTypesByName; + + auto settingsObj = QJsonObject({ + {"refreshOnTargetStop", inspectionPaneSettings.refreshOnTargetStop}, + {"refreshOnActivation", inspectionPaneSettings.refreshOnActivation}, + }); + + const auto& hexViewerSettings = inspectionPaneSettings.hexViewerWidgetSettings; + settingsObj.insert("hexViewerSettings", QJsonObject({ + {"groupStackMemory", hexViewerSettings.groupStackMemory}, + {"highlightFocusedMemory", hexViewerSettings.highlightFocusedMemory}, + {"highlightHoveredRowAndCol", hexViewerSettings.highlightHoveredRowAndCol}, + {"displayAsciiValues", hexViewerSettings.displayAsciiValues}, + {"displayAnnotations", hexViewerSettings.displayAnnotations}, + {"addressLabelType", addressTypesByName.valueAt(hexViewerSettings.addressLabelType).value()}, + })); + + auto focusedRegions = QJsonArray(); + for (const auto& focusedRegion : inspectionPaneSettings.focusedMemoryRegions) { + focusedRegions.push_back(focusedRegion.toJson()); + } + + auto excludedRegions = QJsonArray(); + for (const auto& excludedRegion : inspectionPaneSettings.excludedMemoryRegions) { + excludedRegions.push_back(excludedRegion.toJson()); + } + + settingsObj.insert("focusedRegions", focusedRegions); + settingsObj.insert("excludedRegions", excludedRegions); + + return settingsObj; +} + +QJsonObject InsightProjectSettings::panelStateToJson(const Widgets::PanelState& panelState) const { + return QJsonObject({ + {"size", panelState.size}, + {"open", panelState.open}, + }); +} + +QJsonObject InsightProjectSettings::paneStateToJson(const Widgets::PaneState& paneState) const { + auto json = QJsonObject({ + {"activated", paneState.activated}, + {"attached", paneState.attached}, + }); + + if (paneState.detachedWindowState.has_value()) { + json.insert("detachedWindowState", QJsonObject({ + { + "size", + QJsonObject({ + {"width", paneState.detachedWindowState->size.width()}, + {"height", paneState.detachedWindowState->size.height()}, + }) + }, + { + "position", + QJsonObject({ + {"x", paneState.detachedWindowState->position.x()}, + {"y", paneState.detachedWindowState->position.y()}, + }) + } + })); + } + + return json; +} +#endif diff --git a/src/ProjectSettings.hpp b/src/ProjectSettings.hpp index 8c1c1bab..00cb731f 100644 --- a/src/ProjectSettings.hpp +++ b/src/ProjectSettings.hpp @@ -17,69 +17,66 @@ #include "src/Helpers/BiMap.hpp" -namespace Bloom +#ifndef EXCLUDE_INSIGHT +struct InsightProjectSettings +{ +public: + std::optional mainWindowSize; + std::optional leftPanelState; + std::optional bottomPanelState; + std::optional registersPaneState; + std::optional ramInspectionPaneState; + std::optional eepromInspectionPaneState; + std::optional flashInspectionPaneState; + + std::map< + Targets::TargetMemoryType, + Widgets::TargetMemoryInspectionPaneSettings + > memoryInspectionPaneSettingsByMemoryType; + + InsightProjectSettings() = default; + explicit InsightProjectSettings(const QJsonObject& jsonObject); + + [[nodiscard]] QJsonObject toJson() const; + +private: + static const inline BiMap memoryTypesByName = { + {Targets::TargetMemoryType::RAM, "ram"}, + {Targets::TargetMemoryType::EEPROM, "eeprom"}, + {Targets::TargetMemoryType::FLASH, "flash"}, + }; + + static const inline BiMap addressTypesByName = { + {AddressType::ABSOLUTE, "absolute"}, + {AddressType::RELATIVE, "relative"}, + }; + + [[nodiscard]] Widgets::TargetMemoryInspectionPaneSettings memoryInspectionPaneSettingsFromJson( + const QJsonObject& jsonObject + ) const; + + [[nodiscard]] Widgets::PanelState panelStateFromJson(const QJsonObject& jsonObject) const; + + [[nodiscard]] Widgets::PaneState paneStateFromJson(const QJsonObject& jsonObject) const; + + [[nodiscard]] QJsonObject memoryInspectionPaneSettingsToJson( + const Widgets::TargetMemoryInspectionPaneSettings& inspectionPaneSettings + ) const; + + [[nodiscard]] QJsonObject panelStateToJson(const Widgets::PanelState& panelState) const; + + [[nodiscard]] QJsonObject paneStateToJson(const Widgets::PaneState& paneState) const; +}; +#endif + +struct ProjectSettings { #ifndef EXCLUDE_INSIGHT - struct InsightProjectSettings - { - public: - std::optional mainWindowSize; - std::optional leftPanelState; - std::optional bottomPanelState; - std::optional registersPaneState; - std::optional ramInspectionPaneState; - std::optional eepromInspectionPaneState; - std::optional flashInspectionPaneState; - - std::map< - Targets::TargetMemoryType, - Widgets::TargetMemoryInspectionPaneSettings - > memoryInspectionPaneSettingsByMemoryType; - - InsightProjectSettings() = default; - explicit InsightProjectSettings(const QJsonObject& jsonObject); - - [[nodiscard]] QJsonObject toJson() const; - - private: - static const inline BiMap memoryTypesByName = { - {Targets::TargetMemoryType::RAM, "ram"}, - {Targets::TargetMemoryType::EEPROM, "eeprom"}, - {Targets::TargetMemoryType::FLASH, "flash"}, - }; - - static const inline BiMap addressTypesByName = { - {AddressType::ABSOLUTE, "absolute"}, - {AddressType::RELATIVE, "relative"}, - }; - - [[nodiscard]] Widgets::TargetMemoryInspectionPaneSettings memoryInspectionPaneSettingsFromJson( - const QJsonObject& jsonObject - ) const; - - [[nodiscard]] Widgets::PanelState panelStateFromJson(const QJsonObject& jsonObject) const; - - [[nodiscard]] Widgets::PaneState paneStateFromJson(const QJsonObject& jsonObject) const; - - [[nodiscard]] QJsonObject memoryInspectionPaneSettingsToJson( - const Widgets::TargetMemoryInspectionPaneSettings& inspectionPaneSettings - ) const; - - [[nodiscard]] QJsonObject panelStateToJson(const Widgets::PanelState& panelState) const; - - [[nodiscard]] QJsonObject paneStateToJson(const Widgets::PaneState& paneState) const; - }; + InsightProjectSettings insightSettings; #endif - struct ProjectSettings - { -#ifndef EXCLUDE_INSIGHT - InsightProjectSettings insightSettings; -#endif + ProjectSettings() = default; + explicit ProjectSettings(const QJsonObject& jsonObject); - ProjectSettings() = default; - explicit ProjectSettings(const QJsonObject& jsonObject); - - [[nodiscard]] QJsonObject toJson() const; - }; -} + [[nodiscard]] QJsonObject toJson() const; +}; diff --git a/src/Services/DateTimeService.hpp b/src/Services/DateTimeService.hpp index 7a6b1644..03346ec4 100644 --- a/src/Services/DateTimeService.hpp +++ b/src/Services/DateTimeService.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Services +namespace Services { /** * Some (maybe all) QDateTime static functions are not thread-safe and thus can result in data races. diff --git a/src/Services/PathService.cpp b/src/Services/PathService.cpp index 3f271aec..594d185c 100644 --- a/src/Services/PathService.cpp +++ b/src/Services/PathService.cpp @@ -7,7 +7,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::Services +namespace Services { std::string PathService::applicationDirPath() { auto pathCharArray = std::array(); diff --git a/src/Services/PathService.hpp b/src/Services/PathService.hpp index 62d4910c..c8e33108 100644 --- a/src/Services/PathService.hpp +++ b/src/Services/PathService.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Services +namespace Services { class PathService { diff --git a/src/Services/ProcessService.cpp b/src/Services/ProcessService.cpp index 400ed9ea..f251f8e2 100644 --- a/src/Services/ProcessService.cpp +++ b/src/Services/ProcessService.cpp @@ -6,7 +6,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::Services +namespace Services { ::pid_t ProcessService::getProcessId() { return getpid(); diff --git a/src/Services/ProcessService.hpp b/src/Services/ProcessService.hpp index 9fec38de..9a67a6ab 100644 --- a/src/Services/ProcessService.hpp +++ b/src/Services/ProcessService.hpp @@ -5,7 +5,7 @@ #include #include -namespace Bloom::Services +namespace Services { class ProcessService { diff --git a/src/Services/StringService.cpp b/src/Services/StringService.cpp index 26c79910..e441f302 100644 --- a/src/Services/StringService.cpp +++ b/src/Services/StringService.cpp @@ -5,7 +5,7 @@ #include #include -namespace Bloom::Services +namespace Services { std::string StringService::asciiToLower(std::string str) { std::transform(str.begin(), str.end(), str.begin(), [] (unsigned char character) { diff --git a/src/Services/StringService.hpp b/src/Services/StringService.hpp index 32660a2d..9c4ec067 100644 --- a/src/Services/StringService.hpp +++ b/src/Services/StringService.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Services +namespace Services { class StringService { diff --git a/src/Services/TargetControllerService.cpp b/src/Services/TargetControllerService.cpp index b5bb6949..054ea66a 100644 --- a/src/Services/TargetControllerService.cpp +++ b/src/Services/TargetControllerService.cpp @@ -27,7 +27,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::Services +namespace Services { using TargetController::Commands::StartAtomicSession; using TargetController::Commands::EndAtomicSession; diff --git a/src/Services/TargetControllerService.hpp b/src/Services/TargetControllerService.hpp index 236e7e8c..2a49c388 100644 --- a/src/Services/TargetControllerService.hpp +++ b/src/Services/TargetControllerService.hpp @@ -17,7 +17,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::Services +namespace Services { /** * The TargetControllerService provides an interface to the TargetController. diff --git a/src/SignalHandler/SignalHandler.cpp b/src/SignalHandler/SignalHandler.cpp index 1503108c..db91cac8 100644 --- a/src/SignalHandler/SignalHandler.cpp +++ b/src/SignalHandler/SignalHandler.cpp @@ -6,80 +6,77 @@ #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" -namespace Bloom -{ - void SignalHandler::run() { - try { - this->startup(); - const auto signalSet = this->getRegisteredSignalSet(); - int signalNumber = 0; +void SignalHandler::run() { + try { + this->startup(); + const auto signalSet = this->getRegisteredSignalSet(); + int signalNumber = 0; - Logger::debug("SignalHandler ready"); - while(Thread::getThreadState() == ThreadState::READY) { - if (::sigwait(&signalSet, &signalNumber) == 0) { - Logger::debug("SIGNAL " + std::to_string(signalNumber) + " received"); + Logger::debug("SignalHandler ready"); + while(Thread::getThreadState() == ThreadState::READY) { + if (::sigwait(&signalSet, &signalNumber) == 0) { + Logger::debug("SIGNAL " + std::to_string(signalNumber) + " received"); - const auto& handlerIt = this->handlersBySignalNum.find(signalNumber); - if (handlerIt != this->handlersBySignalNum.end()) { - // We have a registered handler for this signal. - handlerIt->second(); - } + const auto& handlerIt = this->handlersBySignalNum.find(signalNumber); + if (handlerIt != this->handlersBySignalNum.end()) { + // We have a registered handler for this signal. + handlerIt->second(); } } - - } catch (std::exception& exception) { - Logger::error("SignalHandler fatal error: " + std::string(exception.what())); } - Logger::info("Shutting down SignalHandler"); - this->threadState = ThreadState::STOPPED; + } catch (std::exception& exception) { + Logger::error("SignalHandler fatal error: " + std::string(exception.what())); } - void SignalHandler::startup() { - this->setName("SH"); - this->threadState = ThreadState::STARTING; - Logger::debug("Starting SignalHandler"); - // Block all signal interrupts - auto signalSet = this->getRegisteredSignalSet(); - ::sigprocmask(SIG_SETMASK, &signalSet, NULL); + Logger::info("Shutting down SignalHandler"); + this->threadState = ThreadState::STOPPED; +} - // Register handlers - this->handlersBySignalNum.insert(std::pair( - SIGINT, - std::bind(&SignalHandler::triggerApplicationShutdown, this) - )); +void SignalHandler::startup() { + this->setName("SH"); + this->threadState = ThreadState::STARTING; + Logger::debug("Starting SignalHandler"); + // Block all signal interrupts + auto signalSet = this->getRegisteredSignalSet(); + ::sigprocmask(SIG_SETMASK, &signalSet, NULL); - this->handlersBySignalNum.insert(std::pair( - SIGTERM, - std::bind(&SignalHandler::triggerApplicationShutdown, this) - )); + // Register handlers + this->handlersBySignalNum.insert(std::pair( + SIGINT, + std::bind(&SignalHandler::triggerApplicationShutdown, this) + )); - // It's possible that the SignalHandler has been instructed to shut down, before it could finish starting up. - if (this->getThreadState() != ThreadState::SHUTDOWN_INITIATED) { - this->threadState = ThreadState::READY; - } - } + this->handlersBySignalNum.insert(std::pair( + SIGTERM, + std::bind(&SignalHandler::triggerApplicationShutdown, this) + )); - ::sigset_t SignalHandler::getRegisteredSignalSet() const { - ::sigset_t set = {}; - if (::sigfillset(&set) == -1) { - throw Exceptions::Exception("::sigfillset() failed - error number: " + std::to_string(errno)); - } - - return set; - } - - void SignalHandler::triggerApplicationShutdown() { - Logger::warning("Shutdown signal received"); - this->shutdownSignalsReceived++; - - if (this->shutdownSignalsReceived > 1) { - // User has likely run out of patience - Logger::warning("Aborting immediately"); - std::exit(EXIT_FAILURE); - } - - Logger::info("Attempting clean shutdown"); - EventManager::triggerEvent(std::make_shared()); + // It's possible that the SignalHandler has been instructed to shut down, before it could finish starting up. + if (this->getThreadState() != ThreadState::SHUTDOWN_INITIATED) { + this->threadState = ThreadState::READY; } } + +::sigset_t SignalHandler::getRegisteredSignalSet() const { + ::sigset_t set = {}; + if (::sigfillset(&set) == -1) { + throw Exceptions::Exception("::sigfillset() failed - error number: " + std::to_string(errno)); + } + + return set; +} + +void SignalHandler::triggerApplicationShutdown() { + Logger::warning("Shutdown signal received"); + this->shutdownSignalsReceived++; + + if (this->shutdownSignalsReceived > 1) { + // User has likely run out of patience + Logger::warning("Aborting immediately"); + std::exit(EXIT_FAILURE); + } + + Logger::info("Attempting clean shutdown"); + EventManager::triggerEvent(std::make_shared()); +} diff --git a/src/SignalHandler/SignalHandler.hpp b/src/SignalHandler/SignalHandler.hpp index 5986048a..a384bcaf 100644 --- a/src/SignalHandler/SignalHandler.hpp +++ b/src/SignalHandler/SignalHandler.hpp @@ -6,57 +6,54 @@ #include "src/EventManager/EventManager.hpp" #include "src/Helpers/Synchronised.hpp" -namespace Bloom +class SignalHandler: public Thread { - class SignalHandler: public Thread - { - public: - SignalHandler() = default; +public: + SignalHandler() = default; - /** - * Entry point for SignalHandler thread. - */ - void run(); + /** + * Entry point for SignalHandler thread. + */ + void run(); - /** - * Triggers the shutdown of the SignalHandler thread. - */ - void triggerShutdown() { - this->threadState = ThreadState::SHUTDOWN_INITIATED; - }; - - private: - /** - * Mapping of signal numbers to handler functions. - */ - std::map> handlersBySignalNum; - - /** - * We keep record of the number of shutdown signals received. See definition of triggerApplicationShutdown() - * for more on this. - */ - int shutdownSignalsReceived = 0; - - /** - * Initiates the SignalHandler thread. - */ - void startup(); - - /** - * Fetches all signals currently of interest to the application. - * - * Currently this just returns a set of all signals (using sigfillset()) - * - * @return - */ - [[nodiscard]] ::sigset_t getRegisteredSignalSet() const; - - /** - * Handler for SIGINT, SIGTERM, etc signals. - * - * Will trigger a ShutdownApplication event to kick-off a clean shutdown or it will terminate the - * program immediately if numerous SIGINT signals have been received. - */ - void triggerApplicationShutdown(); + /** + * Triggers the shutdown of the SignalHandler thread. + */ + void triggerShutdown() { + this->threadState = ThreadState::SHUTDOWN_INITIATED; }; -} + +private: + /** + * Mapping of signal numbers to handler functions. + */ + std::map> handlersBySignalNum; + + /** + * We keep record of the number of shutdown signals received. See definition of triggerApplicationShutdown() + * for more on this. + */ + int shutdownSignalsReceived = 0; + + /** + * Initiates the SignalHandler thread. + */ + void startup(); + + /** + * Fetches all signals currently of interest to the application. + * + * Currently this just returns a set of all signals (using sigfillset()) + * + * @return + */ + [[nodiscard]] ::sigset_t getRegisteredSignalSet() const; + + /** + * Handler for SIGINT, SIGTERM, etc signals. + * + * Will trigger a ShutdownApplication event to kick-off a clean shutdown or it will terminate the + * program immediately if numerous SIGINT signals have been received. + */ + void triggerApplicationShutdown(); +}; diff --git a/src/TargetController/AtomicSession.hpp b/src/TargetController/AtomicSession.hpp index f2452039..9fe42152 100644 --- a/src/TargetController/AtomicSession.hpp +++ b/src/TargetController/AtomicSession.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::TargetController +namespace TargetController { using AtomicSessionIdType = int; static_assert(std::atomic::is_always_lock_free); diff --git a/src/TargetController/CommandManager.hpp b/src/TargetController/CommandManager.hpp index 7f582bda..aeac07c9 100644 --- a/src/TargetController/CommandManager.hpp +++ b/src/TargetController/CommandManager.hpp @@ -14,7 +14,7 @@ #include "src/Logger/Logger.hpp" -namespace Bloom::TargetController +namespace TargetController { class CommandManager { diff --git a/src/TargetController/Commands/Command.hpp b/src/TargetController/Commands/Command.hpp index 0623dc2d..dd7843c5 100644 --- a/src/TargetController/Commands/Command.hpp +++ b/src/TargetController/Commands/Command.hpp @@ -8,7 +8,7 @@ #include "src/TargetController/Responses/Response.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { using CommandIdType = int; static_assert(std::atomic::is_always_lock_free); diff --git a/src/TargetController/Commands/CommandTypes.hpp b/src/TargetController/Commands/CommandTypes.hpp index 2bcec412..605f8be5 100644 --- a/src/TargetController/Commands/CommandTypes.hpp +++ b/src/TargetController/Commands/CommandTypes.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { enum class CommandType: std::uint8_t { diff --git a/src/TargetController/Commands/DisableProgrammingMode.hpp b/src/TargetController/Commands/DisableProgrammingMode.hpp index 0e36e56c..6da3d594 100644 --- a/src/TargetController/Commands/DisableProgrammingMode.hpp +++ b/src/TargetController/Commands/DisableProgrammingMode.hpp @@ -2,7 +2,7 @@ #include "Command.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class DisableProgrammingMode: public Command { diff --git a/src/TargetController/Commands/EnableProgrammingMode.hpp b/src/TargetController/Commands/EnableProgrammingMode.hpp index a9efd7aa..3671be28 100644 --- a/src/TargetController/Commands/EnableProgrammingMode.hpp +++ b/src/TargetController/Commands/EnableProgrammingMode.hpp @@ -2,7 +2,7 @@ #include "Command.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class EnableProgrammingMode: public Command { diff --git a/src/TargetController/Commands/EndAtomicSession.hpp b/src/TargetController/Commands/EndAtomicSession.hpp index acc3394d..7b50d68d 100644 --- a/src/TargetController/Commands/EndAtomicSession.hpp +++ b/src/TargetController/Commands/EndAtomicSession.hpp @@ -4,7 +4,7 @@ #include "src/TargetController/Responses/AtomicSessionId.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class EndAtomicSession: public Command { diff --git a/src/TargetController/Commands/EraseTargetMemory.hpp b/src/TargetController/Commands/EraseTargetMemory.hpp index e98708a2..1c28aabc 100644 --- a/src/TargetController/Commands/EraseTargetMemory.hpp +++ b/src/TargetController/Commands/EraseTargetMemory.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class EraseTargetMemory: public Command { diff --git a/src/TargetController/Commands/GetTargetDescriptor.hpp b/src/TargetController/Commands/GetTargetDescriptor.hpp index 518f43a2..ba498ea4 100644 --- a/src/TargetController/Commands/GetTargetDescriptor.hpp +++ b/src/TargetController/Commands/GetTargetDescriptor.hpp @@ -4,7 +4,7 @@ #include "src/TargetController/Responses/TargetDescriptor.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class GetTargetDescriptor: public Command { diff --git a/src/TargetController/Commands/GetTargetPinStates.hpp b/src/TargetController/Commands/GetTargetPinStates.hpp index 21812b8b..0d2eb174 100644 --- a/src/TargetController/Commands/GetTargetPinStates.hpp +++ b/src/TargetController/Commands/GetTargetPinStates.hpp @@ -4,7 +4,7 @@ #include "src/TargetController/Responses/TargetPinStates.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class GetTargetPinStates: public Command { diff --git a/src/TargetController/Commands/GetTargetProgramCounter.hpp b/src/TargetController/Commands/GetTargetProgramCounter.hpp index 35911eca..6437bb8a 100644 --- a/src/TargetController/Commands/GetTargetProgramCounter.hpp +++ b/src/TargetController/Commands/GetTargetProgramCounter.hpp @@ -4,7 +4,7 @@ #include "src/TargetController/Responses/TargetProgramCounter.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class GetTargetProgramCounter: public Command { diff --git a/src/TargetController/Commands/GetTargetStackPointer.hpp b/src/TargetController/Commands/GetTargetStackPointer.hpp index f0a2f034..07a38c27 100644 --- a/src/TargetController/Commands/GetTargetStackPointer.hpp +++ b/src/TargetController/Commands/GetTargetStackPointer.hpp @@ -4,7 +4,7 @@ #include "src/TargetController/Responses/TargetStackPointer.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class GetTargetStackPointer: public Command { diff --git a/src/TargetController/Commands/GetTargetState.hpp b/src/TargetController/Commands/GetTargetState.hpp index aa325e90..8b543652 100644 --- a/src/TargetController/Commands/GetTargetState.hpp +++ b/src/TargetController/Commands/GetTargetState.hpp @@ -3,7 +3,7 @@ #include "Command.hpp" #include "src/TargetController/Responses/TargetState.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class GetTargetState: public Command { diff --git a/src/TargetController/Commands/ReadTargetMemory.hpp b/src/TargetController/Commands/ReadTargetMemory.hpp index 32bf619a..b62f02e0 100644 --- a/src/TargetController/Commands/ReadTargetMemory.hpp +++ b/src/TargetController/Commands/ReadTargetMemory.hpp @@ -8,7 +8,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class ReadTargetMemory: public Command { diff --git a/src/TargetController/Commands/ReadTargetRegisters.hpp b/src/TargetController/Commands/ReadTargetRegisters.hpp index df74a6ce..25ca5224 100644 --- a/src/TargetController/Commands/ReadTargetRegisters.hpp +++ b/src/TargetController/Commands/ReadTargetRegisters.hpp @@ -5,7 +5,7 @@ #include "src/Targets/TargetRegister.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class ReadTargetRegisters: public Command { diff --git a/src/TargetController/Commands/RemoveBreakpoint.hpp b/src/TargetController/Commands/RemoveBreakpoint.hpp index afacfe0b..2273ecfc 100644 --- a/src/TargetController/Commands/RemoveBreakpoint.hpp +++ b/src/TargetController/Commands/RemoveBreakpoint.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetBreakpoint.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class RemoveBreakpoint: public Command { diff --git a/src/TargetController/Commands/ResetTarget.hpp b/src/TargetController/Commands/ResetTarget.hpp index 42975c83..52e4da9e 100644 --- a/src/TargetController/Commands/ResetTarget.hpp +++ b/src/TargetController/Commands/ResetTarget.hpp @@ -2,7 +2,7 @@ #include "Command.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class ResetTarget: public Command { diff --git a/src/TargetController/Commands/ResumeTargetExecution.hpp b/src/TargetController/Commands/ResumeTargetExecution.hpp index d637312a..3f59c72e 100644 --- a/src/TargetController/Commands/ResumeTargetExecution.hpp +++ b/src/TargetController/Commands/ResumeTargetExecution.hpp @@ -6,7 +6,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class ResumeTargetExecution: public Command { diff --git a/src/TargetController/Commands/SetBreakpoint.hpp b/src/TargetController/Commands/SetBreakpoint.hpp index 41e2e132..37029678 100644 --- a/src/TargetController/Commands/SetBreakpoint.hpp +++ b/src/TargetController/Commands/SetBreakpoint.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetBreakpoint.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class SetBreakpoint: public Command { diff --git a/src/TargetController/Commands/SetTargetPinState.hpp b/src/TargetController/Commands/SetTargetPinState.hpp index 924c8172..79d75abc 100644 --- a/src/TargetController/Commands/SetTargetPinState.hpp +++ b/src/TargetController/Commands/SetTargetPinState.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetPinDescriptor.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class SetTargetPinState: public Command { diff --git a/src/TargetController/Commands/SetTargetProgramCounter.hpp b/src/TargetController/Commands/SetTargetProgramCounter.hpp index 1e7a7d1c..2ef388b0 100644 --- a/src/TargetController/Commands/SetTargetProgramCounter.hpp +++ b/src/TargetController/Commands/SetTargetProgramCounter.hpp @@ -6,7 +6,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class SetTargetProgramCounter: public Command { diff --git a/src/TargetController/Commands/Shutdown.hpp b/src/TargetController/Commands/Shutdown.hpp index 96e1ba48..a5d2b5b2 100644 --- a/src/TargetController/Commands/Shutdown.hpp +++ b/src/TargetController/Commands/Shutdown.hpp @@ -2,7 +2,7 @@ #include "Command.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class Shutdown: public Command { diff --git a/src/TargetController/Commands/StartAtomicSession.hpp b/src/TargetController/Commands/StartAtomicSession.hpp index 786ba4f4..dd414e98 100644 --- a/src/TargetController/Commands/StartAtomicSession.hpp +++ b/src/TargetController/Commands/StartAtomicSession.hpp @@ -4,7 +4,7 @@ #include "src/TargetController/Responses/AtomicSessionId.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class StartAtomicSession: public Command { diff --git a/src/TargetController/Commands/StepTargetExecution.hpp b/src/TargetController/Commands/StepTargetExecution.hpp index e8b0b16c..4c535482 100644 --- a/src/TargetController/Commands/StepTargetExecution.hpp +++ b/src/TargetController/Commands/StepTargetExecution.hpp @@ -6,7 +6,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class StepTargetExecution: public Command { diff --git a/src/TargetController/Commands/StopTargetExecution.hpp b/src/TargetController/Commands/StopTargetExecution.hpp index 47833973..44d9a198 100644 --- a/src/TargetController/Commands/StopTargetExecution.hpp +++ b/src/TargetController/Commands/StopTargetExecution.hpp @@ -2,7 +2,7 @@ #include "Command.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class StopTargetExecution: public Command { diff --git a/src/TargetController/Commands/WriteTargetMemory.hpp b/src/TargetController/Commands/WriteTargetMemory.hpp index 0f494783..f669dbc0 100644 --- a/src/TargetController/Commands/WriteTargetMemory.hpp +++ b/src/TargetController/Commands/WriteTargetMemory.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class WriteTargetMemory: public Command { diff --git a/src/TargetController/Commands/WriteTargetRegisters.hpp b/src/TargetController/Commands/WriteTargetRegisters.hpp index beb5a4eb..0d833907 100644 --- a/src/TargetController/Commands/WriteTargetRegisters.hpp +++ b/src/TargetController/Commands/WriteTargetRegisters.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetRegister.hpp" -namespace Bloom::TargetController::Commands +namespace TargetController::Commands { class WriteTargetRegisters: public Command { diff --git a/src/TargetController/Exceptions/DeviceCommunicationFailure.hpp b/src/TargetController/Exceptions/DeviceCommunicationFailure.hpp index 32cbff8d..0f8d8fec 100644 --- a/src/TargetController/Exceptions/DeviceCommunicationFailure.hpp +++ b/src/TargetController/Exceptions/DeviceCommunicationFailure.hpp @@ -2,7 +2,7 @@ #include "DeviceFailure.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class DeviceCommunicationFailure: public DeviceFailure { diff --git a/src/TargetController/Exceptions/DeviceFailure.hpp b/src/TargetController/Exceptions/DeviceFailure.hpp index e3d51d7b..7535d824 100644 --- a/src/TargetController/Exceptions/DeviceFailure.hpp +++ b/src/TargetController/Exceptions/DeviceFailure.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class DeviceFailure: public Exception { diff --git a/src/TargetController/Exceptions/DeviceInitializationFailure.hpp b/src/TargetController/Exceptions/DeviceInitializationFailure.hpp index 901b94e6..6df88eec 100644 --- a/src/TargetController/Exceptions/DeviceInitializationFailure.hpp +++ b/src/TargetController/Exceptions/DeviceInitializationFailure.hpp @@ -2,7 +2,7 @@ #include "DeviceFailure.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class DeviceInitializationFailure: public DeviceFailure { diff --git a/src/TargetController/Exceptions/DeviceNotFound.hpp b/src/TargetController/Exceptions/DeviceNotFound.hpp index 90aaf0d1..224fc4ac 100644 --- a/src/TargetController/Exceptions/DeviceNotFound.hpp +++ b/src/TargetController/Exceptions/DeviceNotFound.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class DeviceNotFound: public Exception { diff --git a/src/TargetController/Exceptions/TargetOperationFailure.hpp b/src/TargetController/Exceptions/TargetOperationFailure.hpp index ac42de86..c9019e0b 100644 --- a/src/TargetController/Exceptions/TargetOperationFailure.hpp +++ b/src/TargetController/Exceptions/TargetOperationFailure.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class TargetOperationFailure: public Exception { diff --git a/src/TargetController/Responses/AtomicSessionId.hpp b/src/TargetController/Responses/AtomicSessionId.hpp index 2c59092d..64fd5912 100644 --- a/src/TargetController/Responses/AtomicSessionId.hpp +++ b/src/TargetController/Responses/AtomicSessionId.hpp @@ -6,7 +6,7 @@ #include "src/TargetController/AtomicSession.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class AtomicSessionId: public Response { diff --git a/src/TargetController/Responses/Error.hpp b/src/TargetController/Responses/Error.hpp index bb5f4560..5e0e9049 100644 --- a/src/TargetController/Responses/Error.hpp +++ b/src/TargetController/Responses/Error.hpp @@ -2,7 +2,7 @@ #include "Response.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class Error: public Response { diff --git a/src/TargetController/Responses/Response.hpp b/src/TargetController/Responses/Response.hpp index 255e6d56..b9d206bb 100644 --- a/src/TargetController/Responses/Response.hpp +++ b/src/TargetController/Responses/Response.hpp @@ -2,7 +2,7 @@ #include "ResponseTypes.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class Response { diff --git a/src/TargetController/Responses/ResponseTypes.hpp b/src/TargetController/Responses/ResponseTypes.hpp index 28ae75eb..f48bc0e2 100644 --- a/src/TargetController/Responses/ResponseTypes.hpp +++ b/src/TargetController/Responses/ResponseTypes.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { enum class ResponseType: std::uint8_t { diff --git a/src/TargetController/Responses/TargetDescriptor.hpp b/src/TargetController/Responses/TargetDescriptor.hpp index 7f35929b..e593785e 100644 --- a/src/TargetController/Responses/TargetDescriptor.hpp +++ b/src/TargetController/Responses/TargetDescriptor.hpp @@ -6,7 +6,7 @@ #include "src/Targets/TargetDescriptor.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class TargetDescriptor: public Response { diff --git a/src/TargetController/Responses/TargetMemoryRead.hpp b/src/TargetController/Responses/TargetMemoryRead.hpp index ef380485..a0db4f1c 100644 --- a/src/TargetController/Responses/TargetMemoryRead.hpp +++ b/src/TargetController/Responses/TargetMemoryRead.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class TargetMemoryRead: public Response { diff --git a/src/TargetController/Responses/TargetPinStates.hpp b/src/TargetController/Responses/TargetPinStates.hpp index 80bd7253..03533843 100644 --- a/src/TargetController/Responses/TargetPinStates.hpp +++ b/src/TargetController/Responses/TargetPinStates.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetPinDescriptor.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class TargetPinStates: public Response { diff --git a/src/TargetController/Responses/TargetProgramCounter.hpp b/src/TargetController/Responses/TargetProgramCounter.hpp index 79058377..eb6b0395 100644 --- a/src/TargetController/Responses/TargetProgramCounter.hpp +++ b/src/TargetController/Responses/TargetProgramCounter.hpp @@ -6,7 +6,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class TargetProgramCounter: public Response { diff --git a/src/TargetController/Responses/TargetRegistersRead.hpp b/src/TargetController/Responses/TargetRegistersRead.hpp index c49e6ed3..d2171b9b 100644 --- a/src/TargetController/Responses/TargetRegistersRead.hpp +++ b/src/TargetController/Responses/TargetRegistersRead.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetRegister.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class TargetRegistersRead: public Response { diff --git a/src/TargetController/Responses/TargetStackPointer.hpp b/src/TargetController/Responses/TargetStackPointer.hpp index 85c3d537..dbec564d 100644 --- a/src/TargetController/Responses/TargetStackPointer.hpp +++ b/src/TargetController/Responses/TargetStackPointer.hpp @@ -6,7 +6,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class TargetStackPointer: public Response { diff --git a/src/TargetController/Responses/TargetState.hpp b/src/TargetController/Responses/TargetState.hpp index f85c3043..af281abd 100644 --- a/src/TargetController/Responses/TargetState.hpp +++ b/src/TargetController/Responses/TargetState.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetState.hpp" -namespace Bloom::TargetController::Responses +namespace TargetController::Responses { class TargetState: public Response { diff --git a/src/TargetController/TargetControllerComponent.cpp b/src/TargetController/TargetControllerComponent.cpp index 50afcdca..c7258d9a 100644 --- a/src/TargetController/TargetControllerComponent.cpp +++ b/src/TargetController/TargetControllerComponent.cpp @@ -11,11 +11,11 @@ #include "src/Exceptions/InvalidConfig.hpp" -namespace Bloom::TargetController +namespace TargetController { - using namespace Bloom::Targets; - using namespace Bloom::Events; - using namespace Bloom::Exceptions; + using namespace Targets; + using namespace Events; + using namespace Exceptions; using Commands::CommandIdType; diff --git a/src/TargetController/TargetControllerComponent.hpp b/src/TargetController/TargetControllerComponent.hpp index 648d77fa..00b4bffe 100644 --- a/src/TargetController/TargetControllerComponent.hpp +++ b/src/TargetController/TargetControllerComponent.hpp @@ -66,7 +66,7 @@ #include "src/EventManager/EventListener.hpp" #include "src/EventManager/Events/Events.hpp" -namespace Bloom::TargetController +namespace TargetController { static_assert(std::atomic::is_always_lock_free); diff --git a/src/TargetController/TargetControllerState.hpp b/src/TargetController/TargetControllerState.hpp index a1e1fb77..e63e95a2 100644 --- a/src/TargetController/TargetControllerState.hpp +++ b/src/TargetController/TargetControllerState.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::TargetController +namespace TargetController { enum class TargetControllerState: std::uint8_t { diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index 81e0809a..c0962819 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -14,7 +14,7 @@ #include "Exceptions/DebugWirePhysicalInterfaceError.hpp" #include "src/Targets/TargetRegister.hpp" -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { using namespace Exceptions; diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp index 87b50f6f..69b911a7 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp @@ -24,7 +24,7 @@ #include "Avr8TargetConfig.hpp" -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { class Avr8: public Target { @@ -34,7 +34,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit /* * The functions below implement the Target interface for AVR8 targets. * - * See the Bloom::Targets::Target abstract class for documentation on the expected behaviour of + * See the Targets::Target abstract class for documentation on the expected behaviour of * each function. */ diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp index 573a8a6f..f88d5e95 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.cpp @@ -5,12 +5,12 @@ #include "src/Exceptions/InvalidConfig.hpp" -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { Avr8TargetConfig::Avr8TargetConfig(const TargetConfig& targetConfig) : TargetConfig(targetConfig) { - using Bloom::Exceptions::InvalidConfig; + using Exceptions::InvalidConfig; const auto& targetNode = targetConfig.targetNode; diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp index 16725084..4bf9781f 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp @@ -8,7 +8,7 @@ #include "PhysicalInterface.hpp" -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { /** * Extending the generic TargetConfig struct to accommodate AVR8 target configuration parameters. diff --git a/src/Targets/Microchip/AVR/AVR8/Exceptions/DebugWirePhysicalInterfaceError.hpp b/src/Targets/Microchip/AVR/AVR8/Exceptions/DebugWirePhysicalInterfaceError.hpp index 3c29d1eb..24582c48 100644 --- a/src/Targets/Microchip/AVR/AVR8/Exceptions/DebugWirePhysicalInterfaceError.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Exceptions/DebugWirePhysicalInterfaceError.hpp @@ -2,7 +2,7 @@ #include "src/TargetController/Exceptions/TargetOperationFailure.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class DebugWirePhysicalInterfaceError: public TargetOperationFailure { diff --git a/src/Targets/Microchip/AVR/AVR8/Family.hpp b/src/Targets/Microchip/AVR/AVR8/Family.hpp index 921d307d..1ac4f24d 100644 --- a/src/Targets/Microchip/AVR/AVR8/Family.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Family.hpp @@ -1,6 +1,6 @@ #pragma once -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { enum class Family: int { diff --git a/src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp b/src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp index 5704cdea..81065d20 100644 --- a/src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp +++ b/src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { /** * Pin configurations for AVR8 targets may vary across target variants. This is why we must differentiate a pin diff --git a/src/Targets/Microchip/AVR/AVR8/PhysicalInterface.cpp b/src/Targets/Microchip/AVR/AVR8/PhysicalInterface.cpp index 1f1f5d14..3332835e 100644 --- a/src/Targets/Microchip/AVR/AVR8/PhysicalInterface.cpp +++ b/src/Targets/Microchip/AVR/AVR8/PhysicalInterface.cpp @@ -1,6 +1,6 @@ #include "PhysicalInterface.hpp" -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { std::map getPhysicalInterfaceNames() { return std::map({ diff --git a/src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp b/src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp index 0a77997e..6450ae60 100644 --- a/src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp +++ b/src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { enum class PhysicalInterface: std::uint8_t { diff --git a/src/Targets/Microchip/AVR/AVR8/ProgramMemorySection.hpp b/src/Targets/Microchip/AVR/AVR8/ProgramMemorySection.hpp index b0037a64..7e517408 100644 --- a/src/Targets/Microchip/AVR/AVR8/ProgramMemorySection.hpp +++ b/src/Targets/Microchip/AVR/AVR8/ProgramMemorySection.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { enum class ProgramMemorySection: std::uint8_t { diff --git a/src/Targets/Microchip/AVR/AVR8/ProgrammingSession.hpp b/src/Targets/Microchip/AVR/AVR8/ProgrammingSession.hpp index 5c316a73..ac9fdcdc 100644 --- a/src/Targets/Microchip/AVR/AVR8/ProgrammingSession.hpp +++ b/src/Targets/Microchip/AVR/AVR8/ProgrammingSession.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { /** * Information relating to a specific AVR8 programming session. diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp index 4c78ff81..a94caca5 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp @@ -10,17 +10,17 @@ #include "src/Exceptions/Exception.hpp" #include "src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp" -namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription +namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription { - using namespace Bloom::Exceptions; + using namespace Exceptions; - using Bloom::Targets::TargetDescription::RegisterGroup; - using Bloom::Targets::TargetDescription::AddressSpace; - using Bloom::Targets::TargetDescription::MemorySegment; - using Bloom::Targets::TargetDescription::MemorySegmentType; - using Bloom::Targets::TargetDescription::Register; - using Bloom::Targets::TargetVariant; - using Bloom::Targets::TargetRegisterDescriptor; + using Targets::TargetDescription::RegisterGroup; + using Targets::TargetDescription::AddressSpace; + using Targets::TargetDescription::MemorySegment; + using Targets::TargetDescription::MemorySegmentType; + using Targets::TargetDescription::Register; + using Targets::TargetVariant; + using Targets::TargetRegisterDescriptor; TargetDescriptionFile::TargetDescriptionFile(const std::string& targetName) { const auto mapping = TargetDescriptionFile::getTargetDescriptionMapping(); diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp index e28dad86..020db0f2 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp @@ -17,7 +17,7 @@ #include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp" #include "src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp" -namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription +namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription { /** * Represents an AVR8 TDF. See the Targets::TargetDescription::TargetDescriptionFile close for more on TDFs. diff --git a/src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp b/src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp index ee68e021..61145441 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp @@ -6,7 +6,7 @@ #include "../TargetSignature.hpp" #include "Family.hpp" -namespace Bloom::Targets::Microchip::Avr::Avr8Bit +namespace Targets::Microchip::Avr::Avr8Bit { /** * Holds all parameters that would be required for configuring a debug tool, for an AVR8 target. diff --git a/src/Targets/Microchip/AVR/Fuse.hpp b/src/Targets/Microchip/AVR/Fuse.hpp index d6ecb59e..b4c5bd44 100644 --- a/src/Targets/Microchip/AVR/Fuse.hpp +++ b/src/Targets/Microchip/AVR/Fuse.hpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetMemory.hpp" -namespace Bloom::Targets::Microchip::Avr +namespace Targets::Microchip::Avr { enum class FuseType: std::uint8_t { diff --git a/src/Targets/Microchip/AVR/IspParameters.hpp b/src/Targets/Microchip/AVR/IspParameters.hpp index c6e934bc..9b2ac2b1 100644 --- a/src/Targets/Microchip/AVR/IspParameters.hpp +++ b/src/Targets/Microchip/AVR/IspParameters.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Targets::Microchip::Avr +namespace Targets::Microchip::Avr { /** * These parameters are required by the ISP interface. They can be extracted from the target's TDF. diff --git a/src/Targets/Microchip/AVR/TargetSignature.hpp b/src/Targets/Microchip/AVR/TargetSignature.hpp index 18a916d9..a374a439 100644 --- a/src/Targets/Microchip/AVR/TargetSignature.hpp +++ b/src/Targets/Microchip/AVR/TargetSignature.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Targets::Microchip::Avr +namespace Targets::Microchip::Avr { /** * All AVR targets carry a three-byte signature that is *usually* unique to the target. diff --git a/src/Targets/Target.hpp b/src/Targets/Target.hpp index 04f90c71..b6e7665b 100644 --- a/src/Targets/Target.hpp +++ b/src/Targets/Target.hpp @@ -17,7 +17,7 @@ #include "src/DebugToolDrivers/DebugTool.hpp" -namespace Bloom::Targets +namespace Targets { /** * Abstract class for Targets. diff --git a/src/Targets/TargetBreakpoint.hpp b/src/Targets/TargetBreakpoint.hpp index fa6eb73a..546e0b55 100644 --- a/src/Targets/TargetBreakpoint.hpp +++ b/src/Targets/TargetBreakpoint.hpp @@ -4,7 +4,7 @@ #include "TargetMemory.hpp" -namespace Bloom::Targets +namespace Targets { enum class TargetBreakCause: int { diff --git a/src/Targets/TargetDescription/AddressSpace.hpp b/src/Targets/TargetDescription/AddressSpace.hpp index f2a9978a..1c37aa58 100644 --- a/src/Targets/TargetDescription/AddressSpace.hpp +++ b/src/Targets/TargetDescription/AddressSpace.hpp @@ -4,7 +4,7 @@ #include "MemorySegment.hpp" -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct AddressSpace { diff --git a/src/Targets/TargetDescription/BitField.hpp b/src/Targets/TargetDescription/BitField.hpp index 27e4de10..4ea62539 100644 --- a/src/Targets/TargetDescription/BitField.hpp +++ b/src/Targets/TargetDescription/BitField.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct BitField { diff --git a/src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp b/src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp index f1c162b9..4f183a4f 100644 --- a/src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp +++ b/src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp @@ -2,7 +2,7 @@ #include "src/Exceptions/Exception.hpp" -namespace Bloom::Exceptions +namespace Exceptions { class TargetDescriptionParsingFailureException: public Exception { diff --git a/src/Targets/TargetDescription/Interface.hpp b/src/Targets/TargetDescription/Interface.hpp index 1d3e14a7..6e85c80e 100644 --- a/src/Targets/TargetDescription/Interface.hpp +++ b/src/Targets/TargetDescription/Interface.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct Interface { diff --git a/src/Targets/TargetDescription/MemorySegment.hpp b/src/Targets/TargetDescription/MemorySegment.hpp index 25559afe..88df861c 100644 --- a/src/Targets/TargetDescription/MemorySegment.hpp +++ b/src/Targets/TargetDescription/MemorySegment.hpp @@ -6,7 +6,7 @@ #include "src/Helpers/BiMap.hpp" -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { enum class MemorySegmentType { diff --git a/src/Targets/TargetDescription/Module.hpp b/src/Targets/TargetDescription/Module.hpp index 4ebd38d9..66fbba43 100644 --- a/src/Targets/TargetDescription/Module.hpp +++ b/src/Targets/TargetDescription/Module.hpp @@ -3,7 +3,7 @@ #include "ModuleInstance.hpp" #include "RegisterGroup.hpp" -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct Module { diff --git a/src/Targets/TargetDescription/ModuleInstance.hpp b/src/Targets/TargetDescription/ModuleInstance.hpp index 014b9844..d5da719d 100644 --- a/src/Targets/TargetDescription/ModuleInstance.hpp +++ b/src/Targets/TargetDescription/ModuleInstance.hpp @@ -7,7 +7,7 @@ #include "RegisterGroup.hpp" #include "Signal.hpp" -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct ModuleInstance { diff --git a/src/Targets/TargetDescription/Pinout.hpp b/src/Targets/TargetDescription/Pinout.hpp index 84b2ff64..3799b287 100644 --- a/src/Targets/TargetDescription/Pinout.hpp +++ b/src/Targets/TargetDescription/Pinout.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct Pin { diff --git a/src/Targets/TargetDescription/PropertyGroup.hpp b/src/Targets/TargetDescription/PropertyGroup.hpp index 66183694..f823ca2a 100644 --- a/src/Targets/TargetDescription/PropertyGroup.hpp +++ b/src/Targets/TargetDescription/PropertyGroup.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct Property { diff --git a/src/Targets/TargetDescription/RegisterGroup.hpp b/src/Targets/TargetDescription/RegisterGroup.hpp index 0a99a3a0..35cac923 100644 --- a/src/Targets/TargetDescription/RegisterGroup.hpp +++ b/src/Targets/TargetDescription/RegisterGroup.hpp @@ -7,7 +7,7 @@ #include "BitField.hpp" -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct Register { diff --git a/src/Targets/TargetDescription/Signal.hpp b/src/Targets/TargetDescription/Signal.hpp index 2a721add..350c3caa 100644 --- a/src/Targets/TargetDescription/Signal.hpp +++ b/src/Targets/TargetDescription/Signal.hpp @@ -3,7 +3,7 @@ #include #include -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct Signal { diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/TargetDescription/TargetDescriptionFile.cpp index 7d362eb0..1bf6ca7d 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.cpp @@ -7,9 +7,9 @@ #include "src/Logger/Logger.hpp" #include "src/Services/PathService.hpp" -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { - using namespace Bloom::Exceptions; + using namespace Exceptions; const std::string& TargetDescriptionFile::getTargetName() const { return this->targetName; diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.hpp b/src/Targets/TargetDescription/TargetDescriptionFile.hpp index 2f77544b..7260b3e0 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.hpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.hpp @@ -12,7 +12,7 @@ #include "Pinout.hpp" #include "Interface.hpp" -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { /** * A target description file (TDF) is an XML file that describes a particular target. All supported targets come diff --git a/src/Targets/TargetDescription/Variant.hpp b/src/Targets/TargetDescription/Variant.hpp index 6fcbdbcb..47f2dfa2 100644 --- a/src/Targets/TargetDescription/Variant.hpp +++ b/src/Targets/TargetDescription/Variant.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Targets::TargetDescription +namespace Targets::TargetDescription { struct Variant { diff --git a/src/Targets/TargetDescriptor.hpp b/src/Targets/TargetDescriptor.hpp index f8db9de1..933242c0 100644 --- a/src/Targets/TargetDescriptor.hpp +++ b/src/Targets/TargetDescriptor.hpp @@ -11,7 +11,7 @@ #include "TargetRegister.hpp" #include "TargetVariant.hpp" -namespace Bloom::Targets +namespace Targets { struct TargetDescriptor { @@ -56,4 +56,4 @@ namespace Bloom::Targets }; } -Q_DECLARE_METATYPE(Bloom::Targets::TargetDescriptor) +Q_DECLARE_METATYPE(Targets::TargetDescriptor) diff --git a/src/Targets/TargetMemory.hpp b/src/Targets/TargetMemory.hpp index e3c7fb56..c9089ac4 100644 --- a/src/Targets/TargetMemory.hpp +++ b/src/Targets/TargetMemory.hpp @@ -4,7 +4,7 @@ #include #include -namespace Bloom::Targets +namespace Targets { using TargetMemoryAddress = std::uint32_t; using TargetMemorySize = std::uint32_t; diff --git a/src/Targets/TargetPinDescriptor.hpp b/src/Targets/TargetPinDescriptor.hpp index 356d3943..e20ee240 100644 --- a/src/Targets/TargetPinDescriptor.hpp +++ b/src/Targets/TargetPinDescriptor.hpp @@ -7,7 +7,7 @@ #include #include -namespace Bloom::Targets +namespace Targets { enum class TargetPinType: std::uint8_t { @@ -57,9 +57,9 @@ namespace Bloom::Targets std::optional ioDirection; }; - using TargetPinStateMapping = std::map; + using TargetPinStateMapping = std::map; } -Q_DECLARE_METATYPE(Bloom::Targets::TargetPinDescriptor) -Q_DECLARE_METATYPE(Bloom::Targets::TargetPinState) -Q_DECLARE_METATYPE(Bloom::Targets::TargetPinStateMapping) +Q_DECLARE_METATYPE(Targets::TargetPinDescriptor) +Q_DECLARE_METATYPE(Targets::TargetPinState) +Q_DECLARE_METATYPE(Targets::TargetPinStateMapping) diff --git a/src/Targets/TargetRegister.cpp b/src/Targets/TargetRegister.cpp index eab50eeb..15107714 100644 --- a/src/Targets/TargetRegister.cpp +++ b/src/Targets/TargetRegister.cpp @@ -1,6 +1,6 @@ #include "TargetRegister.hpp" -namespace Bloom::Targets +namespace Targets { std::size_t TargetRegisterDescriptor::getHash() const { if (!this->cachedHash.has_value()) { diff --git a/src/Targets/TargetRegister.hpp b/src/Targets/TargetRegister.hpp index 14506f7a..40167040 100644 --- a/src/Targets/TargetRegister.hpp +++ b/src/Targets/TargetRegister.hpp @@ -11,7 +11,7 @@ #include "TargetMemory.hpp" -namespace Bloom::Targets +namespace Targets { using TargetRegisterDescriptorId = std::uint32_t; using TargetRegisterDescriptorIds = std::set; @@ -97,7 +97,7 @@ namespace Bloom::Targets static inline std::atomic lastRegisterDescriptorId = 0; std::size_t getHash() const; - friend std::hash; + friend std::hash; }; struct TargetRegister @@ -129,10 +129,10 @@ namespace std * class) */ template<> - class hash + class hash { public: - std::size_t operator()(const Bloom::Targets::TargetRegisterDescriptor& descriptor) const { + std::size_t operator()(const Targets::TargetRegisterDescriptor& descriptor) const { return descriptor.getHash(); } }; diff --git a/src/Targets/TargetState.hpp b/src/Targets/TargetState.hpp index aa016769..0f6facad 100644 --- a/src/Targets/TargetState.hpp +++ b/src/Targets/TargetState.hpp @@ -2,7 +2,7 @@ #include -namespace Bloom::Targets +namespace Targets { enum class TargetState: std::uint8_t { @@ -12,4 +12,4 @@ namespace Bloom::Targets }; } -Q_DECLARE_METATYPE(Bloom::Targets::TargetState) +Q_DECLARE_METATYPE(Targets::TargetState) diff --git a/src/Targets/TargetVariant.hpp b/src/Targets/TargetVariant.hpp index 62eb1ae1..084119e5 100644 --- a/src/Targets/TargetVariant.hpp +++ b/src/Targets/TargetVariant.hpp @@ -6,7 +6,7 @@ #include "TargetPinDescriptor.hpp" -namespace Bloom::Targets +namespace Targets { enum class TargetPackage: std::uint8_t { diff --git a/src/VersionNumber.cpp b/src/VersionNumber.cpp index d72efd7d..6f3fadfd 100644 --- a/src/VersionNumber.cpp +++ b/src/VersionNumber.cpp @@ -2,27 +2,24 @@ #include -namespace Bloom -{ - VersionNumber::VersionNumber(std::uint16_t major, std::uint16_t minor, std::uint16_t patch) - : major{major} - , minor{minor} - , patch{patch} - {} +VersionNumber::VersionNumber(std::uint16_t major, std::uint16_t minor, std::uint16_t patch) + : major{major} + , minor{minor} + , patch{patch} +{} - VersionNumber::VersionNumber(const std::string& versionNumber) - : VersionNumber(QString::fromStdString(versionNumber)) - {} +VersionNumber::VersionNumber(const std::string& versionNumber) + : VersionNumber(QString::fromStdString(versionNumber)) +{} - VersionNumber::VersionNumber(const QString& versionNumber) { - const auto explodedString = versionNumber.split('.'); +VersionNumber::VersionNumber(const QString& versionNumber) { + const auto explodedString = versionNumber.split('.'); - this->major = explodedString.value(0, "0").toUShort(); - this->minor = explodedString.value(1, "0").toUShort(); - this->patch = explodedString.value(2, "0").toUShort(); - } - - std::string VersionNumber::toString() const { - return std::to_string(this->major) + "." + std::to_string(this->minor) + "." + std::to_string(this->patch); - } + this->major = explodedString.value(0, "0").toUShort(); + this->minor = explodedString.value(1, "0").toUShort(); + this->patch = explodedString.value(2, "0").toUShort(); +} + +std::string VersionNumber::toString() const { + return std::to_string(this->major) + "." + std::to_string(this->minor) + "." + std::to_string(this->patch); } diff --git a/src/VersionNumber.hpp b/src/VersionNumber.hpp index eb0ac89f..799db26b 100644 --- a/src/VersionNumber.hpp +++ b/src/VersionNumber.hpp @@ -4,49 +4,46 @@ #include #include -namespace Bloom +class VersionNumber { - class VersionNumber - { - public: - std::uint16_t major = 0; - std::uint16_t minor = 0; - std::uint16_t patch = 0; +public: + std::uint16_t major = 0; + std::uint16_t minor = 0; + std::uint16_t patch = 0; - VersionNumber(std::uint16_t major, std::uint16_t minor, std::uint16_t patch); - VersionNumber(const std::string& versionNumber); - VersionNumber(const QString& versionNumber); + VersionNumber(std::uint16_t major, std::uint16_t minor, std::uint16_t patch); + VersionNumber(const std::string& versionNumber); + VersionNumber(const QString& versionNumber); - std::string toString() const; + std::string toString() const; - bool operator == (const VersionNumber& other) const { - return - this->major == other.major - && this->minor == other.minor - && this->patch == other.patch; - } + bool operator == (const VersionNumber& other) const { + return + this->major == other.major + && this->minor == other.minor + && this->patch == other.patch; + } - bool operator != (const VersionNumber& other) const { - return !(*this == other); - } + bool operator != (const VersionNumber& other) const { + return !(*this == other); + } - bool operator < (const VersionNumber& other) const { - return - this->major < other.major - || (this->major == other.major && this->minor < other.minor) - || (this->major == other.major && this->minor == other.minor && this->patch < other.patch); - } + bool operator < (const VersionNumber& other) const { + return + this->major < other.major + || (this->major == other.major && this->minor < other.minor) + || (this->major == other.major && this->minor == other.minor && this->patch < other.patch); + } - bool operator > (const VersionNumber& other) const { - return other < *this; - } + bool operator > (const VersionNumber& other) const { + return other < *this; + } - bool operator <= (const VersionNumber& other) const { - return !(other < *this); - } + bool operator <= (const VersionNumber& other) const { + return !(other < *this); + } - bool operator >= (const VersionNumber& other) const { - return !(*this < other); - } - }; -} + bool operator >= (const VersionNumber& other) const { + return !(*this < other); + } +}; diff --git a/src/main.cpp b/src/main.cpp index 62233119..3d6aaf63 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,6 @@ #include "Application.hpp" int main(int argc, char* argv[]) { - auto application = Bloom::Application(std::vector(argv, argv + argc)); + auto application = Application(std::vector(argv, argv + argc)); return application.run(); }