From f594d29a2dbfd707ade7498749e97ddf0952dce8 Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Wed, 8 Jan 2025 06:23:34 -0400 Subject: [PATCH] DevMgr: Add sensorDevSpecs list and make intero/extro lists use unique_ptr --- hcore/deviceManager/deviceManager.cpp | 12 +++++++----- hcore/deviceManager/deviceSpecp.yy | 20 ++++++++++++-------- hcore/include/deviceManager/deviceManager.h | 9 +++++++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/hcore/deviceManager/deviceManager.cpp b/hcore/deviceManager/deviceManager.cpp index 4c66d25..ff602e4 100644 --- a/hcore/deviceManager/deviceManager.cpp +++ b/hcore/deviceManager/deviceManager.cpp @@ -4,14 +4,16 @@ #include #include #include +#include #include #include - -std::vector +std::vector> DeviceManager::interoceptorDeviceSpecs; -std::vector +std::vector> DeviceManager::extrospectorDeviceSpecs; +std::vector> + DeviceManager::sensorDeviceSpecs; std::ostream& operator<<( std::ostream& os, const DeviceManager::SensorDeviceSpec& spec) @@ -35,11 +37,11 @@ const std::string DeviceManager::printDeviceSpecs(void) std::ostringstream oss; for (const auto& spec : DeviceManager::interoceptorDeviceSpecs) { - oss << "Interoceptor " << spec; + oss << "Interoceptor " << *spec; } for (const auto& spec : DeviceManager::extrospectorDeviceSpecs) { - oss << "Extrospector " << spec; + oss << "Extrospector " << *spec; } return oss.str(); diff --git a/hcore/deviceManager/deviceSpecp.yy b/hcore/deviceManager/deviceSpecp.yy index fa0a98f..6200c25 100644 --- a/hcore/deviceManager/deviceSpecp.yy +++ b/hcore/deviceManager/deviceSpecp.yy @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #ifndef yylex @@ -70,23 +72,25 @@ sensor_spec: interoceptor_spec: KEYWORD_SPECTYPE_INTEROSPECTOR PIPE spec_body { - DeviceManager::InteroceptorDeviceSpec *spec = - static_cast($3); + auto spec = std::make_unique( + *static_cast($3)); spec->sensorType = $1; - DeviceManager::interoceptorDeviceSpecs.push_back(*spec); - delete spec; + DeviceManager::interoceptorDeviceSpecs.push_back(std::move(spec)); + DeviceManager::sensorDeviceSpecs.push_back(*spec); + delete $3; } ; extrospector_spec: KEYWORD_SPECTYPE_EXTROSPECTOR PIPE spec_body { - DeviceManager::ExtrospectorDeviceSpec *spec = - static_cast($3); + auto spec = std::make_unique( + *static_cast($3)); spec->sensorType = $1; - DeviceManager::extrospectorDeviceSpecs.push_back(*spec); - delete spec; + DeviceManager::extrospectorDeviceSpecs.push_back(std::move(spec)); + DeviceManager::sensorDeviceSpecs.push_back(*spec); + delete $3; } ; diff --git a/hcore/include/deviceManager/deviceManager.h b/hcore/include/deviceManager/deviceManager.h index 94b0a78..5adc720 100644 --- a/hcore/include/deviceManager/deviceManager.h +++ b/hcore/include/deviceManager/deviceManager.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -51,8 +52,12 @@ private: public: std::string allDeviceSpecs; - static std::vector interoceptorDeviceSpecs; - static std::vector extrospectorDeviceSpecs; + static std::vector> + interoceptorDeviceSpecs; + static std::vector> + extrospectorDeviceSpecs; + static std::vector> + sensorDeviceSpecs; }; #endif // DEVICEMANAGER_H