separate out the log parsing, will throw events
This commit is contained in:
@ -5,6 +5,8 @@ project(solanaceae)
|
||||
add_library(solanaceae_factorio
|
||||
./log_parse.hpp
|
||||
./log_parse.cpp
|
||||
./factorio_log_parser.hpp
|
||||
./factorio_log_parser.cpp
|
||||
./factorio.hpp
|
||||
./factorio.cpp
|
||||
)
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include <solanaceae/message3/components.hpp>
|
||||
#include <solanaceae/contact/components.hpp>
|
||||
|
||||
#include "./log_parse.hpp"
|
||||
|
||||
Factorio::Factorio(Contact3Registry& cr, RegistryMessageModel& rmm) :
|
||||
_cr(cr),
|
||||
_rmm(rmm),
|
||||
_fw("test.txt", [this](const auto& path, const auto event){ this->onFileEvent(path, event);})
|
||||
_rmm(rmm)
|
||||
{
|
||||
|
||||
|
||||
@ -22,7 +19,3 @@ bool Factorio::onEvent(const Message::Events::MessageConstruct& e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Factorio::onFileEvent(const std::string& path, const filewatch::Event change_type) {
|
||||
std::cout << "file even " << filewatch::event_to_string(change_type) << " on '" << path << "'\n";
|
||||
}
|
||||
|
||||
|
@ -2,24 +2,15 @@
|
||||
|
||||
#include <solanaceae/message3/registry_message_model.hpp>
|
||||
|
||||
#include <FileWatch.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
class Factorio : public RegistryMessageModelEventI {
|
||||
Contact3Registry& _cr;
|
||||
RegistryMessageModel& _rmm;
|
||||
|
||||
filewatch::FileWatch<std::string> _fw;
|
||||
|
||||
public:
|
||||
Factorio(Contact3Registry& cr, RegistryMessageModel& rmm);
|
||||
virtual ~Factorio(void);
|
||||
|
||||
protected: // rmm
|
||||
bool onEvent(const Message::Events::MessageConstruct& e) override;
|
||||
|
||||
protected:
|
||||
void onFileEvent(const std::string& path, const filewatch::Event change_type);
|
||||
};
|
||||
|
||||
|
19
src/factorio_log_parser.cpp
Normal file
19
src/factorio_log_parser.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "./factorio_log_parser.hpp"
|
||||
|
||||
#include "./log_parse.hpp"
|
||||
|
||||
FactorioLogParser::FactorioLogParser(void) :
|
||||
_fw("test.txt", [this](const auto& path, const auto event){ this->onFileEvent(path, event);})
|
||||
{
|
||||
}
|
||||
|
||||
FactorioLogParser::~FactorioLogParser(void) {
|
||||
}
|
||||
|
||||
void FactorioLogParser::onFileEvent(const std::string& path, const filewatch::Event change_type) {
|
||||
std::cout << "file even " << filewatch::event_to_string(change_type) << " on '" << path << "'\n";
|
||||
|
||||
// on create, close open log file and reopen and skip to end
|
||||
// on mod (?), read line, parse
|
||||
}
|
||||
|
17
src/factorio_log_parser.hpp
Normal file
17
src/factorio_log_parser.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <FileWatch.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
class FactorioLogParser {
|
||||
filewatch::FileWatch<std::string> _fw;
|
||||
|
||||
public:
|
||||
FactorioLogParser(void);
|
||||
virtual ~FactorioLogParser(void);
|
||||
|
||||
protected:
|
||||
void onFileEvent(const std::string& path, const filewatch::Event change_type);
|
||||
};
|
||||
|
Reference in New Issue
Block a user