Pass the TargetDescriptor by const-reference where we can
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Bloom::TargetController::Responses
|
|||||||
public:
|
public:
|
||||||
static constexpr ResponseType type = ResponseType::TARGET_DESCRIPTOR;
|
static constexpr ResponseType type = ResponseType::TARGET_DESCRIPTOR;
|
||||||
|
|
||||||
Targets::TargetDescriptor targetDescriptor;
|
const Targets::TargetDescriptor& targetDescriptor;
|
||||||
|
|
||||||
explicit TargetDescriptor(const Targets::TargetDescriptor& targetDescriptor)
|
explicit TargetDescriptor(const Targets::TargetDescriptor& targetDescriptor)
|
||||||
: targetDescriptor(targetDescriptor)
|
: targetDescriptor(targetDescriptor)
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ namespace Bloom::TargetController
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TargetControllerComponent::loadRegisterDescriptors() {
|
void TargetControllerComponent::loadRegisterDescriptors() {
|
||||||
auto& targetDescriptor = this->getTargetDescriptor();
|
const auto& targetDescriptor = this->getTargetDescriptor();
|
||||||
|
|
||||||
for (const auto& [registerType, registerDescriptors] : targetDescriptor.registerDescriptorsByType) {
|
for (const auto& [registerType, registerDescriptors] : targetDescriptor.registerDescriptorsByType) {
|
||||||
for (const auto& registerDescriptor : registerDescriptors) {
|
for (const auto& registerDescriptor : registerDescriptors) {
|
||||||
@@ -753,12 +753,12 @@ namespace Bloom::TargetController
|
|||||||
EventManager::triggerEvent(std::make_shared<Events::ProgrammingModeDisabled>());
|
EventManager::triggerEvent(std::make_shared<Events::ProgrammingModeDisabled>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Targets::TargetDescriptor& TargetControllerComponent::getTargetDescriptor() {
|
const Targets::TargetDescriptor& TargetControllerComponent::getTargetDescriptor() {
|
||||||
if (!this->cachedTargetDescriptor.has_value()) {
|
if (!this->cachedTargetDescriptor.has_value()) {
|
||||||
this->cachedTargetDescriptor = this->target->getDescriptor();
|
this->cachedTargetDescriptor.emplace(this->target->getDescriptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->cachedTargetDescriptor.value();
|
return *this->cachedTargetDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetControllerComponent::onShutdownTargetControllerEvent(const Events::ShutdownTargetController&) {
|
void TargetControllerComponent::onShutdownTargetControllerEvent(const Events::ShutdownTargetController&) {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ namespace Bloom::TargetController
|
|||||||
/**
|
/**
|
||||||
* Obtaining a TargetDescriptor for the connected target can be quite expensive. We cache it here.
|
* Obtaining a TargetDescriptor for the connected target can be quite expensive. We cache it here.
|
||||||
*/
|
*/
|
||||||
std::optional<Targets::TargetDescriptor> cachedTargetDescriptor;
|
std::optional<const Targets::TargetDescriptor> cachedTargetDescriptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target register descriptors mapped by the memory type on which the register is stored.
|
* Target register descriptors mapped by the memory type on which the register is stored.
|
||||||
@@ -313,7 +313,7 @@ namespace Bloom::TargetController
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Targets::TargetDescriptor& getTargetDescriptor();
|
const Targets::TargetDescriptor& getTargetDescriptor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invokes a shutdown.
|
* Invokes a shutdown.
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ namespace Bloom::TargetController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetDescriptor TargetControllerConsole::getTargetDescriptor() {
|
const TargetDescriptor& TargetControllerConsole::getTargetDescriptor() {
|
||||||
return this->commandManager.sendCommandAndWaitForResponse(
|
return this->commandManager.sendCommandAndWaitForResponse(
|
||||||
std::make_unique<GetTargetDescriptor>(),
|
std::make_unique<GetTargetDescriptor>(),
|
||||||
this->defaultTimeout
|
this->defaultTimeout
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace Bloom::TargetController
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Targets::TargetDescriptor getTargetDescriptor();
|
const Targets::TargetDescriptor& getTargetDescriptor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the current target state.
|
* Fetches the current target state.
|
||||||
|
|||||||
Reference in New Issue
Block a user