Aktualizr
C++ SOTA Client
filelist.h
1 #ifndef OPCUABRIDGE_FILELIST_H_
2 #define OPCUABRIDGE_FILELIST_H_
3 
4 #include "imageblock.h"
5 
6 #include <unordered_set>
7 #include <utility>
8 
9 namespace boost {
10 namespace filesystem {
11 class path;
12 } // namespace filesystem
13 } // namespace boost
14 
15 namespace opcuabridge {
16 
17 class FileList {
18  public:
19  typedef BinaryDataType block_type;
20 
21  FileList() = default;
22  virtual ~FileList() = default;
23 
24  block_type& getBlock() { return block_; }
25  const block_type& getBlock() const { return block_; }
26  void setBlock(const block_type& block) { block_ = block; }
27  INITSERVERNODESET_BIN_FUNCTION_DEFINITION(FileList, &block_) // InitServerNodeset(UA_Server*)
28  CLIENTREAD_BIN_FUNCTION_DEFINITION(&block_) // ClientRead(UA_Client*)
29  CLIENTWRITE_BIN_FUNCTION_DEFINITION(&block_) // ClientWrite(UA_Client*)
30 
31  void setOnBeforeReadCallback(MessageOnBeforeReadCallback<FileList>::type cb) { on_before_read_cb_ = std::move(cb); }
32  void setOnAfterWriteCallback(MessageOnAfterWriteCallback<FileList>::type cb) { on_after_write_cb_ = std::move(cb); }
33 
34  protected:
35  block_type block_;
36 
37  MessageOnBeforeReadCallback<FileList>::type on_before_read_cb_;
38  MessageOnAfterWriteCallback<FileList>::type on_after_write_cb_;
39 
40  private:
41  static const char* node_id_;
42  static const char* bin_node_id_;
43 
44  Json::Value wrapMessage() const {
45  Json::Value v;
46  return v;
47  }
48  void unwrapMessage(const Json::Value& v) {}
49 
50  WRAPMESSAGE_FUCTION_DEFINITION(FileList)
51  UNWRAPMESSAGE_FUCTION_DEFINITION(FileList)
52  READ_FUNCTION_FRIEND_DECLARATION(FileList)
53  WRITE_FUNCTION_FRIEND_DECLARATION(FileList)
54  INTERNAL_FUNCTIONS_FRIEND_DECLARATION(FileList)
55 
56 #ifdef OPCUABRIDGE_ENABLE_SERIALIZATION
57  SERIALIZE_FUNCTION_FRIEND_DECLARATION
58 
59  DEFINE_SERIALIZE_METHOD() { SERIALIZE_FIELD(ar, "block_", block_); }
60 #endif // OPCUABRIDGE_ENABLE_SERIALIZATION
61 };
62 
63 typedef const FileList::block_type::value_type* FileSetEntry;
64 
66  typedef FileSetEntry argument_type;
67  typedef std::size_t result_type;
68 
69  result_type operator()(argument_type const& e) const;
70 };
71 
73  typedef FileSetEntry argument_type;
74 
75  bool operator()(const argument_type& lhs, const argument_type& rhs) const;
76 };
77 
78 typedef std::unordered_set<FileSetEntry, FileSetEntryHash, FileSetEntryEqual> FileUnorderedSet;
79 
80 std::size_t UpdateFileList(FileList* /*filelist*/, const boost::filesystem::path& /*repo_dir_path*/);
81 void UpdateFileUnorderedSet(FileUnorderedSet* /*file_unordered_set*/, const FileList& /*file_list*/);
82 
83 } // namespace opcuabridge
84 
85 #endif // OPCUABRIDGE_FILELIST_H_
Definition: common.h:20
Definition: filelist.h:72
Definition: filelist.h:65