31#include <unordered_map>
33#include "observable.h"
34#include "comm_navmsg.h"
39enum class CommStatus { Ok, NotImplemented, NotSupported, NameInUse };
50 virtual void Notify(std::shared_ptr<const NavMsg> message) = 0;
58 :
public std::enable_shared_from_this<AbstractCommDriver> {
62 virtual bool SendMessage(std::shared_ptr<const NavMsg> msg,
63 std::shared_ptr<const NavAddr> addr) = 0;
81 virtual std::pair<CommStatus, std::string>
Clone() {
83 return std::pair<CommStatus, std::string>(CommStatus::NotImplemented,
"");
86 std::string Key()
const {
return NavAddr::BusToString(bus) +
"!@!" +
iface; }
88 const NavAddr::Bus bus;
92 virtual std::unordered_map<std::string, std::string> GetAttributes()
const {
return attributes;}
94 std::unordered_map<std::string, std::string> attributes;
98 attributes[
"protocol"] = NavAddr::BusToString(bus);
101 attributes[
"protocol"] = NavAddr::BusToString(bus);
Common interface for all drivers.
virtual void SetListener(DriverListener &l)
Set the entity which will receive incoming data.
const std::string iface
Physical device for 0183, else a unique string.
virtual std::pair< CommStatus, std::string > Clone()
Create a new virtual interface using a new instance of this driver.
virtual void Activate()=0
Register driver in the driver Registry.
Interface implemented by transport layer and possible other parties like test code which should handl...
virtual void Notify(std::shared_ptr< const NavMsg > message)=0
Handle a received message.
virtual void Notify(const AbstractCommDriver &driver)=0
Handle driver status change.