DevMgr: Add sensorDevSpecs list and make intero/extro lists use unique_ptr
This commit is contained in:
@@ -4,14 +4,16 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <memory>
|
||||||
#include <opts.h>
|
#include <opts.h>
|
||||||
#include <deviceManager/deviceManager.h>
|
#include <deviceManager/deviceManager.h>
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<DeviceManager::InteroceptorDeviceSpec>>
|
||||||
std::vector<DeviceManager::InteroceptorDeviceSpec>
|
|
||||||
DeviceManager::interoceptorDeviceSpecs;
|
DeviceManager::interoceptorDeviceSpecs;
|
||||||
std::vector<DeviceManager::ExtrospectorDeviceSpec>
|
std::vector<std::unique_ptr<DeviceManager::ExtrospectorDeviceSpec>>
|
||||||
DeviceManager::extrospectorDeviceSpecs;
|
DeviceManager::extrospectorDeviceSpecs;
|
||||||
|
std::vector<std::reference_wrapper<DeviceManager::SensorDeviceSpec>>
|
||||||
|
DeviceManager::sensorDeviceSpecs;
|
||||||
|
|
||||||
std::ostream& operator<<(
|
std::ostream& operator<<(
|
||||||
std::ostream& os, const DeviceManager::SensorDeviceSpec& spec)
|
std::ostream& os, const DeviceManager::SensorDeviceSpec& spec)
|
||||||
@@ -35,11 +37,11 @@ const std::string DeviceManager::printDeviceSpecs(void)
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
|
||||||
for (const auto& spec : DeviceManager::interoceptorDeviceSpecs) {
|
for (const auto& spec : DeviceManager::interoceptorDeviceSpecs) {
|
||||||
oss << "Interoceptor " << spec;
|
oss << "Interoceptor " << *spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& spec : DeviceManager::extrospectorDeviceSpecs) {
|
for (const auto& spec : DeviceManager::extrospectorDeviceSpecs) {
|
||||||
oss << "Extrospector " << spec;
|
oss << "Extrospector " << *spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
return oss.str();
|
return oss.str();
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
#include <deviceManager/deviceManager.h>
|
#include <deviceManager/deviceManager.h>
|
||||||
|
|
||||||
#ifndef yylex
|
#ifndef yylex
|
||||||
@@ -70,23 +72,25 @@ sensor_spec:
|
|||||||
|
|
||||||
interoceptor_spec:
|
interoceptor_spec:
|
||||||
KEYWORD_SPECTYPE_INTEROSPECTOR PIPE spec_body {
|
KEYWORD_SPECTYPE_INTEROSPECTOR PIPE spec_body {
|
||||||
DeviceManager::InteroceptorDeviceSpec *spec =
|
auto spec = std::make_unique<DeviceManager::InteroceptorDeviceSpec>(
|
||||||
static_cast<DeviceManager::InteroceptorDeviceSpec *>($3);
|
*static_cast<DeviceManager::InteroceptorDeviceSpec *>($3));
|
||||||
|
|
||||||
spec->sensorType = $1;
|
spec->sensorType = $1;
|
||||||
DeviceManager::interoceptorDeviceSpecs.push_back(*spec);
|
DeviceManager::interoceptorDeviceSpecs.push_back(std::move(spec));
|
||||||
delete spec;
|
DeviceManager::sensorDeviceSpecs.push_back(*spec);
|
||||||
|
delete $3;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
extrospector_spec:
|
extrospector_spec:
|
||||||
KEYWORD_SPECTYPE_EXTROSPECTOR PIPE spec_body {
|
KEYWORD_SPECTYPE_EXTROSPECTOR PIPE spec_body {
|
||||||
DeviceManager::ExtrospectorDeviceSpec *spec =
|
auto spec = std::make_unique<DeviceManager::ExtrospectorDeviceSpec>(
|
||||||
static_cast<DeviceManager::ExtrospectorDeviceSpec *>($3);
|
*static_cast<DeviceManager::ExtrospectorDeviceSpec *>($3));
|
||||||
|
|
||||||
spec->sensorType = $1;
|
spec->sensorType = $1;
|
||||||
DeviceManager::extrospectorDeviceSpecs.push_back(*spec);
|
DeviceManager::extrospectorDeviceSpecs.push_back(std::move(spec));
|
||||||
delete spec;
|
DeviceManager::sensorDeviceSpecs.push_back(*spec);
|
||||||
|
delete $3;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
#include <opts.h>
|
#include <opts.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -51,8 +52,12 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::string allDeviceSpecs;
|
std::string allDeviceSpecs;
|
||||||
static std::vector<InteroceptorDeviceSpec> interoceptorDeviceSpecs;
|
static std::vector<std::unique_ptr<InteroceptorDeviceSpec>>
|
||||||
static std::vector<ExtrospectorDeviceSpec> extrospectorDeviceSpecs;
|
interoceptorDeviceSpecs;
|
||||||
|
static std::vector<std::unique_ptr<ExtrospectorDeviceSpec>>
|
||||||
|
extrospectorDeviceSpecs;
|
||||||
|
static std::vector<std::reference_wrapper<SensorDeviceSpec>>
|
||||||
|
sensorDeviceSpecs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICEMANAGER_H
|
#endif // DEVICEMANAGER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user