hops
MessageRecorder.hpp
Go to the documentation of this file.
1 #ifndef HOPS_MESSAGERECORDER_HPP
2 #define HOPS_MESSAGERECORDER_HPP
3 
4 #include "../../FileWriter/FileWriter.hpp"
9 #include "../../Utility/Data.hpp"
10 
11 #include <string>
12 #include <vector>
13 
14 namespace hops {
15  template<typename MarkovChainImpl>
16  class MessageRecorder : public MarkovChainImpl {
17  public:
18  explicit MessageRecorder(const MarkovChainImpl &markovChainImpl) : MarkovChainImpl(markovChainImpl) {}
19 
20  void installDataObject(ChainData& chainData) {
22  MarkovChainImpl::installDataObject(chainData);
23  }
24  }
25 
26  void writeRecordsToFile(const FileWriter *const fileWriter) const {
27  fileWriter->write("messages", records);
29  MarkovChainImpl::writeRecordsToFile(fileWriter);
30  }
31  };
32 
33  void storeRecord() {
34  records.emplace_back(latestMessage);
35  latestMessage = "";
37  MarkovChainImpl::storeRecord();
38  }
39  }
40 
41  void addMessage(const std::string &message) {
42  latestMessage += message;
43  }
44 
45  void clearRecords() {
46  records.clear();
47  }
48 
49  private:
50  std::vector<std::string> records;
51  std::string latestMessage;
52  };
53 }
54 
55 #endif //HOPS_MESSAGERECORDER_HPP
hops::MessageRecorder
Definition: MessageRecorder.hpp:16
hops::MessageRecorder::addMessage
void addMessage(const std::string &message)
Definition: MessageRecorder.hpp:41
IsInstallDataObjectAvailable.hpp
IsClearRecordsAvailable.hpp
IsStoreRecordAvailable.hpp
hops::IsInstallDataObjectAvailable
Definition: IsInstallDataObjectAvailable.hpp:9
hops::IsWriteRecordsToFileAvailable
Definition: IsWriteRecordsToFileAvailable.hpp:9
hops::FileWriter::write
virtual void write(const std::string &description, const std::vector< float > &records) const =0
Writes records.
hops::MessageRecorder::installDataObject
void installDataObject(ChainData &chainData)
Definition: MessageRecorder.hpp:20
hops::ChainData
Definition: ChainData.hpp:12
hops::IsStoreRecordAvailable
Definition: IsStoreRecordAvailable.hpp:8
hops::MessageRecorder::storeRecord
void storeRecord()
Definition: MessageRecorder.hpp:33
hops::FileWriter
Definition: FileWriter.hpp:9
hops
Definition: CsvReader.hpp:8
hops::MessageRecorder::clearRecords
void clearRecords()
Definition: MessageRecorder.hpp:45
hops::MessageRecorder::writeRecordsToFile
void writeRecordsToFile(const FileWriter *const fileWriter) const
Definition: MessageRecorder.hpp:26
string
NAME string(REPLACE ".cpp" "_bin" example_name ${example_filename}) if($
Definition: hops/Third-party/HighFive/src/examples/CMakeLists.txt:6
hops::MessageRecorder::MessageRecorder
MessageRecorder(const MarkovChainImpl &markovChainImpl)
Definition: MessageRecorder.hpp:18
IsWriteRecordsToFileAvailable.hpp