Digitalisierte Elektroverteilung zur permanenten Verbraucherüberwachung
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PublisherData.h 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <chrono>
  3. #include <vector>
  4. #include <iostream>
  5. #include "PublisherType.h"
  6. using namespace std::chrono;
  7. class PublisherData
  8. {
  9. private:
  10. unsigned int publisherID;
  11. const PublisherType publisherType;
  12. system_clock::time_point time_generated;
  13. std::vector<float> values;
  14. public:
  15. //constructors
  16. PublisherData(const int _publisherID, PublisherType pubType, float value);
  17. PublisherData(const int _publisherID, PublisherType pubType, std::vector<float> _values);
  18. PublisherData();
  19. //void updateTime() { this->time_generated = system_clock::now(); }
  20. inline void addData(const float data) { values.push_back(data); }
  21. std::string toString()const;
  22. unsigned int getID() { return publisherID; }
  23. void setID(unsigned int id) { this->publisherID = id; };
  24. std::vector<float>& getValues() { return values; };
  25. //getter/setter
  26. PublisherType getType()const { return publisherType; }
  27. system_clock::time_point getTimeGenerated()const { return time_generated; }
  28. bool hasData()const { return values.size() == 0 ? false : true; }
  29. //operator
  30. friend std::ostream& operator<<(std::ostream&, const PublisherData&);
  31. friend std::istream& operator>>(std::istream&, PublisherData&);
  32. };