1 #ifndef OPCUABRIDGE_FILEDATA_H_ 2 #define OPCUABRIDGE_FILEDATA_H_ 6 #include <boost/filesystem.hpp> 13 explicit FileData(boost::filesystem::path base_path) : base_path_(std::move(base_path)) {}
16 const boost::filesystem::path& getBasePath()
const {
return base_path_; }
17 void setBasePath(
const boost::filesystem::path& base_path) { base_path_ = base_path; }
18 const boost::filesystem::path& getFilePath()
const {
return file_path_; }
19 void setFilePath(
const boost::filesystem::path& file_path) { file_path_ = file_path; }
21 std::string getFullFilePath()
const override {
return (getBasePath() / getFilePath()).native(); }
23 INITSERVERNODESET_FILE_FUNCTION_DEFINITION(
FileData)
24 CLIENTWRITE_FILE_FUNCTION_DEFINITION()
26 void setOnBeforeReadCallback(MessageOnBeforeReadCallback<FileData>::type cb) { on_before_read_cb_ = std::move(cb); }
27 void setOnAfterWriteCallback(MessageOnAfterWriteCallback<FileData>::type cb) { on_after_write_cb_ = std::move(cb); }
30 boost::filesystem::path base_path_;
31 boost::filesystem::path file_path_;
33 MessageOnBeforeReadCallback<FileData>::type on_before_read_cb_;
34 MessageOnAfterWriteCallback<FileData>::type on_after_write_cb_;
37 static const char* node_id_;
38 static const char* bin_node_id_;
40 Json::Value wrapMessage()
const {
42 v[
"filename"] = getFilePath().native();
45 void unwrapMessage(Json::Value v) { setFilePath(v[
"filename"].asString()); }
47 WRAPMESSAGE_FUCTION_DEFINITION(
FileData)
48 UNWRAPMESSAGE_FUCTION_DEFINITION(
FileData)
49 READ_FUNCTION_FRIEND_DECLARATION(
FileData)
50 WRITE_FUNCTION_FRIEND_DECLARATION(
FileData)
51 INTERNAL_FUNCTIONS_FRIEND_DECLARATION(
FileData)
55 #endif // OPCUABRIDGE_FILEDATA_H_