Aktualizr
C++ SOTA Client
opcuabridgeclient.h
1 #ifndef OPCUABRIDGE_CLIENT_H_
2 #define OPCUABRIDGE_CLIENT_H_
3 
4 #include <string>
5 
6 #include "opcuabridge.h"
7 
8 struct UA_Client;
9 
10 namespace boost {
11 namespace filesystem {
12 class path;
13 } // namespace filesystem
14 } // namespace boost
15 
16 namespace Uptane {
17 class SecondaryConfig;
18 } // namespace Uptane
19 
20 namespace opcuabridge {
21 
23  public:
24  explicit SelectEndPoint(const Uptane::SecondaryConfig& /*sconfig*/);
25 
26  const std::string& getUrl() const { return url_; }
27 
28  private:
29  struct DiscoveredEndPointCacheEntry {
30  Uptane::EcuSerial serial;
32  std::string opcua_server_url;
33  };
34 
35  struct DiscoveredEndPointCacheEntryHash {
36  typedef DiscoveredEndPointCacheEntry argument_type;
37  typedef std::size_t result_type;
38 
39  result_type operator()(argument_type const& e) const;
40  };
41 
42  struct DiscoveredEndPointCacheEntryEqual {
43  typedef DiscoveredEndPointCacheEntry argument_type;
44 
45  bool operator()(const argument_type& lhs, const argument_type& rhs) const;
46  };
47 
48  typedef std::unordered_set<DiscoveredEndPointCacheEntry, DiscoveredEndPointCacheEntryHash,
49  DiscoveredEndPointCacheEntryEqual>
50  DiscoveredEndPointCache;
51 
52  bool endPointConfirmed(const std::string& opcua_server_url, const Uptane::SecondaryConfig& /*sconfig*/) const;
53  std::string makeOpcuaServerUri(const std::string& address) const;
54  void considerLdsRegisteredEndPoints(const std::string& opcua_lds_url);
55 
56  thread_local static DiscoveredEndPointCache discovered_end_points_cache_;
57 
58  std::string url_;
59 };
60 
61 class Client {
62  public:
63  explicit Client(const SelectEndPoint& /*selector*/) noexcept;
64  explicit Client(const std::string& url) noexcept;
65  ~Client();
66 
67  Client(const Client&) = delete;
68  Client& operator=(const Client&) = delete;
69 
70  explicit operator bool() const;
71 
72  Configuration recvConfiguration() const;
73  VersionReport recvVersionReport() const;
74  OriginalManifest recvOriginalManifest() const;
75  bool sendMetadataFiles(std::vector<MetadataFile>& /*files*/) const;
76  bool syncDirectoryFiles(const boost::filesystem::path& /*repo_dir*/) const;
77 
78  private:
79  UA_Client* client_;
80 };
81 
82 } // namespace opcuabridge
83 
84 #endif // OPCUABRIDGE_CLIENT_H_
Definition: common.h:20
Base data types that are used in The Update Framework (TUF), part of UPTANE.