1 #include "Communicator.h" 2 #include "hardwareinterface/EncoderAdapter.h" 3 #include "messages/EncoderMessage.h" 7 this->sensorManager = sensorManager;
8 this->messageMap =
new std::map<Hardware, IMessage*>;
9 this->hardwareInterfaceMap =
new std::map<Hardware, IHardwareInterface*>;
10 this->hardwareInterfaces =
new std::list<IHardwareInterface*>;
14 delete this->sensorManager;
15 delete this->messageMap;
16 delete this->hardwareInterfaceMap;
21 if(this->hardwareInterfaceMap->count(hardware) != 0) {
25 this->hardwareInterfaceMap->insert(std::make_pair(hardware, interface));
26 this->hardwareInterfaces->push_back(interface);
32 this->messageMap->insert(std::make_pair(msg->
getHardware(), msg));
43 void Communicator::write() {
45 for (std::map<Hardware,IMessage*>::iterator it=messageMap->begin(); it!=messageMap->end(); ++it) {
47 interface->write(it->second);
53 void Communicator::read() {
54 std::list<IMessage*>* messages =
new std::list<IMessage*>;
57 std::list<IMessage*>* msgs = interface->read();
58 while(!msgs->empty()) {
60 messages->push_back(msg);
Communicator(ISensorManager *sensorManager)
virtual void updateSensors(std::list< IMessage * > *messages)=0
void registerHardware(Hardware hardware, IHardwareInterface *interface)
void queueMessage(IMessage *message)