|
12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #pragma once
- #include <memory>
- #include <vector>
- #include <map>
- #include <chrono>
- #include <optional>
- #include <regex>
- #include <atomic>
- #include "PublisherData.h"
-
- constexpr auto READ_BUFFER_SIZE = 4096;
-
- typedef std::map<unsigned int, std::vector<PublisherData>> data_key_map;
-
- using namespace std::chrono;
-
- class DataModel
- {
- public:
- //Sigleton Methods
- static std::unique_ptr<DataModel>& Instance();
- static void Destroy();
- static void Create();
-
- void savePublishedData(PublisherData data);
-
- data_key_map& getSavedPublishedData() { return savedPublishedData; };
-
- //saves collected data after a certain amount of time points
- void checkIfToFlush(bool keepDataLocally = false);
-
- private:
- //static instance which can be accessed by calling DataModel::Instance()
- static std::unique_ptr<DataModel> instance;
-
- //Data from publishers, one elemt in outer vector for one id
- //Each id consists of a vector of PublisherData (use map to make the id become a unique key)
- data_key_map savedPublishedData;
-
- //ostream operators (read and write dataModel data from streams)
- friend std::ostream& operator<<(std::ostream& os, DataModel& dataModel);
- friend std::istream& operator>>(std::istream& is, DataModel& dataModel);
- };
|