add filewatch
This commit is contained in:
parent
0e358157f2
commit
fcafb1bd7e
19
external/CMakeLists.txt
vendored
19
external/CMakeLists.txt
vendored
@ -20,3 +20,22 @@ if (NOT TARGET solanaceae_plugin)
|
|||||||
FetchContent_MakeAvailable(solanaceae_plugin)
|
FetchContent_MakeAvailable(solanaceae_plugin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT TARGET filewatch)
|
||||||
|
FetchContent_Declare(filewatch
|
||||||
|
GIT_REPOSITORY https://github.com/ThomasMonkman/filewatch.git
|
||||||
|
GIT_TAG master
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
|
||||||
|
# does not provide a proper cmake
|
||||||
|
FetchContent_GetProperties(filewatch)
|
||||||
|
if(NOT filewatch_POPULATED)
|
||||||
|
FetchContent_Populate(filewatch)
|
||||||
|
|
||||||
|
add_library(filewatch INTERFACE
|
||||||
|
${filewatch_SOURCE_DIR}/FileWatch.hpp
|
||||||
|
)
|
||||||
|
target_include_directories(filewatch INTERFACE ${filewatch_SOURCE_DIR})
|
||||||
|
target_compile_features(filewatch INTERFACE cxx_std_11)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
@ -13,6 +13,7 @@ target_include_directories(solanaceae_factorio PUBLIC .)
|
|||||||
target_compile_features(solanaceae_factorio PUBLIC cxx_std_17)
|
target_compile_features(solanaceae_factorio PUBLIC cxx_std_17)
|
||||||
target_link_libraries(solanaceae_factorio PUBLIC
|
target_link_libraries(solanaceae_factorio PUBLIC
|
||||||
solanaceae_message3
|
solanaceae_message3
|
||||||
|
filewatch
|
||||||
)
|
)
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
|
@ -5,7 +5,13 @@
|
|||||||
|
|
||||||
#include "./log_parse.hpp"
|
#include "./log_parse.hpp"
|
||||||
|
|
||||||
Factorio::Factorio(Contact3Registry& cr, RegistryMessageModel& rmm) : _cr(cr), _rmm(rmm) {
|
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.subscribe(this, RegistryMessageModel_Event::message_construct);
|
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,3 +22,7 @@ bool Factorio::onEvent(const Message::Events::MessageConstruct& e) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onFileEvent(const std::string& path, const filewatch::Event change_type) {
|
||||||
|
std::cout << "file even " << filewatch::event_to_string(change_type) << " on '" << path << "'\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -2,15 +2,24 @@
|
|||||||
|
|
||||||
#include <solanaceae/message3/registry_message_model.hpp>
|
#include <solanaceae/message3/registry_message_model.hpp>
|
||||||
|
|
||||||
|
#include <FileWatch.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class Factorio : public RegistryMessageModelEventI {
|
class Factorio : public RegistryMessageModelEventI {
|
||||||
Contact3Registry& _cr;
|
Contact3Registry& _cr;
|
||||||
RegistryMessageModel& _rmm;
|
RegistryMessageModel& _rmm;
|
||||||
|
|
||||||
|
filewatch::FileWatch<std::string> _fw;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Factorio(Contact3Registry& cr, RegistryMessageModel& rmm);
|
Factorio(Contact3Registry& cr, RegistryMessageModel& rmm);
|
||||||
virtual ~Factorio(void);
|
virtual ~Factorio(void);
|
||||||
|
|
||||||
protected: // rmm
|
protected: // rmm
|
||||||
bool onEvent(const Message::Events::MessageConstruct& e) override;
|
bool onEvent(const Message::Events::MessageConstruct& e) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onFileEvent(const std::string& path, const filewatch::Event change_type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user