Wyatt  1.0.1
Communicator.h
1 #pragma once
2 
3 #include <string>
4 #include <queue>
5 #include <map>
6 #include <iostream>
7 #include <fstream>
8 
9 #include "messages/IMessage.h"
10 #include "sensors/ISensorManager.h"
11 #include "Hardware.h"
12 #include "Thread.h"
13 #include "hardwareinterface/IHardwareInterface.h"
14 #include "exceptions/DuplicateHardwareException.h"
15 #include <mutex>
16 
22 class Communicator : public Thread {
23 
24 public:
29  Communicator(ISensorManager* sensorManager);
30 
34  ~Communicator();
35 
42  void registerHardware(Hardware hardware, IHardwareInterface* interface);
43 
48  void queueMessage(IMessage* message);
49 
54  void queueMessage(std::list<IMessage*>* messages);
55 
60  void* run() override;
61 
62 private:
63  ISensorManager* sensorManager;
64  std::map<Hardware, IMessage*>* messageMap;
65  std::map<Hardware, IHardwareInterface*>* hardwareInterfaceMap;
66  std::list<IHardwareInterface*>* hardwareInterfaces;
67 
68  std::mutex m_lock;
69 
73  void write();
74 
78  void read();
79 
80 };
Communicator(ISensorManager *sensorManager)
Definition: Communicator.cpp:6
void registerHardware(Hardware hardware, IHardwareInterface *interface)
void queueMessage(IMessage *message)
Definition: Thread.h:32
void * run() override