Files
salmanoff/include/user/senseDeviceSpec.h
T
hayodea aaae3dcbb2 DevSpec: Grammar now parses params as key[=[val]]
* Updated docs to reflect this.
* This was important in allowing us to write the xcbXorg connection
 code.
2025-01-14 14:17:05 -04:00

78 lines
1.8 KiB
C++

#ifndef SENSORDEVICESPEC_H
#define SENSORDEVICESPEC_H
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
namespace hk {
namespace device {
class SenseDeviceSpec
{
public:
friend std::ostream& operator<<(
std::ostream& os, const SenseDeviceSpec& spec)
{
os << spec.stringify();
return os;
}
bool operator==(const SenseDeviceSpec& other) const
{
return sensorType == other.sensorType &&
provider == other.provider &&
deviceSelector == other.deviceSelector;
}
public:
char sensorType;
std::string implexor;
std::string api;
std::vector<std::pair<std::string,std::string>> apiParams;
std::string provider;
std::vector<std::pair<std::string,std::string>> providerParams;
std::string deviceSelector;
std::string stringify() const
{
std::ostringstream os;
os << "Device: " << sensorType << ", Implexor: "
<< implexor << ", API: " << api << ", API Params: (";
for (const auto& param : apiParams)
{
os << param.first;
if (!param.second.empty()) {
os << "=" << param.second;
}
os << " ";
}
os << "), Provider: " << provider << ", Provider Params: (";
for (const auto& param : providerParams)
{
os << param.first;
if (!param.second.empty()) {
os << "=" << param.second;
}
os << " ";
}
os << "), Device Selector: " << deviceSelector << std::endl;
return os.str();
}
};
class InteroceptorDeviceSpec : public SenseDeviceSpec
{
};
class ExtrospectorDeviceSpec : public SenseDeviceSpec
{
};
} // namespace device
} // namespace hk
#endif // SENSORDEVICESPEC_H