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

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <chrono>
  3. #include <vector>
  4. #include <iostream>
  5. #include "PublisherType.h"
  6. using namespace std::chrono;
  7. typedef unsigned int u_int;
  8. class PublisherData
  9. {
  10. private:
  11. u_int publisherID;
  12. const PublisherType publisherType;
  13. system_clock::time_point time_generated;
  14. std::vector<float> values;
  15. public:
  16. //constructors
  17. PublisherData(const int _publisherID, PublisherType pubType, float value);
  18. PublisherData(const int _publisherID, PublisherType pubType, std::vector<float> _values);
  19. PublisherData();
  20. //void updateTime() { this->time_generated = system_clock::now(); }
  21. inline void addData(const float data) { values.push_back(data); }
  22. u_int getID() { return publisherID; }
  23. std::vector<float>& getValues() { return values; };
  24. //getter/setter
  25. PublisherType getType()const { return publisherType; }
  26. system_clock::time_point getTimeGenerated()const { return time_generated; }
  27. void setTimeGenerated(const std::chrono::system_clock::time_point t) { time_generated = t; }
  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. };