Rename DSL: deviceSpec => deviceAttachmentSpec

This language is used broadly to specify how to attach (and thus
also how to detach) devices to/from Salmanoff. The next bit of work
we'll do is split off the DSL parsing from the management of the
list of parsed binary attached spec objects.

We'll be creating a PipeDeviceAttachmentParser, and later on when
we support URDF, we'll create a URDFDeviceAttachmentParser.
This commit is contained in:
2025-08-29 15:16:11 -04:00
parent 8f41e164a2
commit 6ef86eea05
10 changed files with 89 additions and 78 deletions
+3 -3
View File
@@ -11,11 +11,11 @@
namespace smo {
namespace device {
std::vector<std::shared_ptr<InteroceptorDeviceSpec>>
std::vector<std::shared_ptr<InteroceptorDevAttachmentSpec>>
DeviceManager::interoceptorDeviceSpecs;
std::vector<std::shared_ptr<ExtrospectorDeviceSpec>>
std::vector<std::shared_ptr<ExtrospectorDevAttachmentSpec>>
DeviceManager::extrospectorDeviceSpecs;
std::vector<std::shared_ptr<SenseDeviceSpec>>
std::vector<std::shared_ptr<DeviceAttachmentSpec>>
DeviceManager::senseDeviceSpecs;
const std::string DeviceManager::stringifyDeviceSpecs(void)
+20 -19
View File
@@ -7,7 +7,7 @@
#include <stdexcept>
#include <memory>
#include <functional>
#include <user/senseDeviceSpec.h>
#include <user/deviceAttachmentSpec.h>
#include <deviceManager/deviceManager.h>
#ifndef yylex
@@ -46,9 +46,9 @@ void yyerror(const char *message)
%union {
char* str;
char chr;
smo::device::SenseDeviceSpec* sensorSpec;
smo::device::InteroceptorDeviceSpec* interoceptorSpec;
smo::device::ExtrospectorDeviceSpec* extrospectorSpec;
smo::device::DeviceAttachmentSpec* sensorSpec;
smo::device::InteroceptorDevAttachmentSpec* interoceptorSpec;
smo::device::ExtrospectorDevAttachmentSpec* extrospectorSpec;
std::vector<std::pair<std::string,std::string>>* paramVector;
std::pair<std::string,std::string>* param;
}
@@ -83,8 +83,8 @@ sensor_spec:
interoceptor_spec:
KEYWORD_SPECTYPE_INTEROSPECTOR PIPE spec_body {
auto spec = std::make_shared<smo::device::InteroceptorDeviceSpec>(
*static_cast<smo::device::InteroceptorDeviceSpec *>($3));
auto spec = std::make_shared<smo::device::InteroceptorDevAttachmentSpec>(
*static_cast<smo::device::InteroceptorDevAttachmentSpec *>($3));
spec->sensorType = $1;
smo::device::DeviceManager::interoceptorDeviceSpecs.push_back(spec);
@@ -96,8 +96,8 @@ interoceptor_spec:
extrospector_spec:
KEYWORD_SPECTYPE_EXTROSPECTOR PIPE spec_body {
auto spec = std::make_shared<smo::device::ExtrospectorDeviceSpec>(
*static_cast<smo::device::ExtrospectorDeviceSpec *>($3));
auto spec = std::make_shared<smo::device::ExtrospectorDevAttachmentSpec>(
*static_cast<smo::device::ExtrospectorDevAttachmentSpec *>($3));
spec->sensorType = $1;
smo::device::DeviceManager::extrospectorDeviceSpecs.push_back(spec);
@@ -108,17 +108,18 @@ extrospector_spec:
;
spec_body:
STRING PIPE STRING LPAREN opt_params RPAREN PIPE STRING LPAREN opt_params RPAREN PIPE STRING {
$$ = new smo::device::SenseDeviceSpec();
$$->sensorType = '\0';
$$->implexor = std::string($1);
$$->api = std::string($3);
$$->apiParams = std::move(*$5);
$$->provider = std::string($8);
$$->providerParams = std::move(*$10);
$$->deviceSelector = std::string($13);
delete $5;
delete $10;
STRING PIPE STRING PIPE STRING LPAREN opt_params RPAREN PIPE STRING LPAREN opt_params RPAREN PIPE STRING {
$$ = new smo::device::DeviceAttachmentSpec();
$$->deviceIdentifier = std::string($1);
$$->sensorType = '\0'; // This will be set by the parent rule
$$->implexor = std::string($3);
$$->api = std::string($5);
$$->apiParams = std::move(*$7);
$$->provider = std::string($10);
$$->providerParams = std::move(*$12);
$$->deviceSelector = std::string($15);
delete $7;
delete $12;
}
;
@@ -7,7 +7,7 @@
#include <opts.h>
#include <utility>
#include <iostream>
#include <user/senseDeviceSpec.h>
#include <user/deviceAttachmentSpec.h>
namespace smo {
namespace device {
@@ -34,11 +34,11 @@ private:
public:
std::string allDeviceSpecs;
static std::vector<std::shared_ptr<InteroceptorDeviceSpec>>
static std::vector<std::shared_ptr<InteroceptorDevAttachmentSpec>>
interoceptorDeviceSpecs;
static std::vector<std::shared_ptr<ExtrospectorDeviceSpec>>
static std::vector<std::shared_ptr<ExtrospectorDevAttachmentSpec>>
extrospectorDeviceSpecs;
static std::vector<std::shared_ptr<SenseDeviceSpec>>
static std::vector<std::shared_ptr<DeviceAttachmentSpec>>
senseDeviceSpecs;
};
+3 -3
View File
@@ -8,7 +8,7 @@
#include <optional>
#include <functional>
#include <senseApis/senseApiLib.h>
#include <user/senseDeviceSpec.h>
#include <user/deviceAttachmentSpec.h>
namespace smo {
namespace sense_api {
@@ -39,9 +39,9 @@ public:
void attachAllSenseDevicesFromSpecs(void);
void attachSenseDevice(
const std::shared_ptr<device::SenseDeviceSpec>& spec);
const std::shared_ptr<device::DeviceAttachmentSpec>& spec);
void detachSenseDevice(
const std::shared_ptr<device::SenseDeviceSpec>& spec);
const std::shared_ptr<device::DeviceAttachmentSpec>& spec);
void detachAllSenseDevices(void);
std::string stringifyLibs() const;
+2 -2
View File
@@ -232,7 +232,7 @@ void SenseApiManager::finalizeAllSenseApiLibs(void)
}
void SenseApiManager::attachSenseDevice(
const std::shared_ptr<device::SenseDeviceSpec>& spec
const std::shared_ptr<device::DeviceAttachmentSpec>& spec
)
{
auto libOpt = getSenseApiLibByApiName(spec->api);
@@ -253,7 +253,7 @@ void SenseApiManager::attachSenseDevice(
}
void SenseApiManager::detachSenseDevice(
const std::shared_ptr<device::SenseDeviceSpec>& spec
const std::shared_ptr<device::DeviceAttachmentSpec>& spec
)
{
auto libOpt = getSenseApiLibByApiName(spec->api);