manager.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // manager.hpp
  3. //
  4. #ifndef MANAGER_HPP
  5. #define MANAGER_HPP
  6. #include "BasicDatatypes.hpp"
  7. #include "tools/SickThread.hpp"
  8. #include "tools/BasicDataBuffer.hpp"
  9. #include "devices/BasicDevice.hpp"
  10. #include "application/BasicApplication.hpp"
  11. #include <vector> // for std::vector
  12. //
  13. // The Manager.
  14. //
  15. class Manager
  16. {
  17. public:
  18. /// Default constructor.
  19. Manager();
  20. /// Destructor.
  21. ~Manager();
  22. bool addApplication(Sourcetype appType, std::string appName, UINT16 wantedId = 0xFFFF);
  23. bool addApplication(application::BasicApplication* app, UINT16 wantedId = 0xFFFF);
  24. bool addAndRunDevice(Sourcetype deviceType, std::string deviceName, UINT16 wantedId = 0xFFFF);
  25. bool addAndRunDevice(devices::BasicDevice* device, std::string deviceName, UINT16 wantedId = 0xFFFF);
  26. bool importApplications();
  27. bool runAllDevices();
  28. void stopAllDevices();
  29. void setDeviceData(BasicData* data); // Datenquelle: Hier laden die Devices ihre Daten ab
  30. devices::BasicDevice* getDeviceById(UINT32 id);
  31. devices::BasicDevice* getFirstDeviceByType(Sourcetype type);
  32. private:
  33. bool m_beVerbose;
  34. UINT16 getNextSourceId();
  35. UINT16 m_nextSourceId; // Die als naechstes verwendete ID
  36. // Die Devices
  37. typedef std::vector<devices::BasicDevice*> DeviceList;
  38. DeviceList m_deviceList;
  39. // The applications
  40. typedef std::vector<application::BasicApplication*> ApplicationList;
  41. ApplicationList m_appList;
  42. // The buffer of the source
  43. BasicDataBuffer m_sourceBuffer;
  44. void sourceThreadFunction(bool& endThread, UINT16& waitTimeMs); // Die Verteiler-Funktion
  45. SickThread<Manager, &Manager::sourceThreadFunction> m_sourceThread; // Der Verteiler-Thread
  46. Mutex m_sourceBufferMutex; // Zugriffsschutz des Source-Buffers
  47. };
  48. #endif // #ifndef MANAGER_HPP