DevMgr: Make vectors hold sh_ptr and not uniq_ptr
This allows us to mirror the contents of the two lists into the unified list much more easily.
This commit is contained in:
@@ -34,32 +34,6 @@ void yyerror(const char *message)
|
||||
+ std::string(message));
|
||||
}
|
||||
|
||||
void mirrorDeviceSpecs() {
|
||||
for (const auto& interoSpec : DeviceManager::interoceptorDeviceSpecs) {
|
||||
auto it = std::find_if(
|
||||
DeviceManager::senseDeviceSpecs.begin(),
|
||||
DeviceManager::senseDeviceSpecs.end(),
|
||||
[&interoSpec](const SenseDeviceSpec& spec) {
|
||||
return spec == *interoSpec;
|
||||
});
|
||||
if (it == DeviceManager::senseDeviceSpecs.end()) {
|
||||
DeviceManager::senseDeviceSpecs.push_back(*interoSpec);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& extroSpec : DeviceManager::extrospectorDeviceSpecs) {
|
||||
auto it = std::find_if(
|
||||
DeviceManager::senseDeviceSpecs.begin(),
|
||||
DeviceManager::senseDeviceSpecs.end(),
|
||||
[&extroSpec](const SenseDeviceSpec& spec) {
|
||||
return spec == *extroSpec;
|
||||
});
|
||||
if (it == DeviceManager::senseDeviceSpecs.end()) {
|
||||
DeviceManager::senseDeviceSpecs.push_back(*extroSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%union {
|
||||
@@ -84,7 +58,7 @@ void mirrorDeviceSpecs() {
|
||||
%%
|
||||
|
||||
file: /* NOTHING */
|
||||
| sensor_specs { mirrorDeviceSpecs(); }
|
||||
| sensor_specs
|
||||
;
|
||||
|
||||
sensor_specs:
|
||||
@@ -99,22 +73,26 @@ sensor_spec:
|
||||
|
||||
interoceptor_spec:
|
||||
KEYWORD_SPECTYPE_INTEROSPECTOR PIPE spec_body {
|
||||
auto spec = std::make_unique<InteroceptorDeviceSpec>(
|
||||
auto spec = std::make_shared<InteroceptorDeviceSpec>(
|
||||
*static_cast<InteroceptorDeviceSpec *>($3));
|
||||
|
||||
spec->sensorType = $1;
|
||||
DeviceManager::interoceptorDeviceSpecs.push_back(std::move(spec));
|
||||
DeviceManager::interoceptorDeviceSpecs.push_back(spec);
|
||||
DeviceManager::senseDeviceSpecs.push_back(spec);
|
||||
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
||||
extrospector_spec:
|
||||
KEYWORD_SPECTYPE_EXTROSPECTOR PIPE spec_body {
|
||||
auto spec = std::make_unique<ExtrospectorDeviceSpec>(
|
||||
auto spec = std::make_shared<ExtrospectorDeviceSpec>(
|
||||
*static_cast<ExtrospectorDeviceSpec *>($3));
|
||||
|
||||
spec->sensorType = $1;
|
||||
DeviceManager::extrospectorDeviceSpecs.push_back(std::move(spec));
|
||||
DeviceManager::extrospectorDeviceSpecs.push_back(spec);
|
||||
DeviceManager::senseDeviceSpecs.push_back(spec);
|
||||
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user