|
8 | 8 |
|
9 | 9 | #include <functional> |
10 | 10 | #include <memory> |
11 | | -#include <vector> |
12 | 11 | #include <string> |
| 12 | +#include <vector> |
13 | 13 |
|
14 | 14 | #include "common/buffer.hpp" |
15 | 15 | #include "common/outcome.hpp" |
16 | | -#include "storage/ipld/ipld_link.hpp" |
17 | 16 | #include "storage/ipld/ipld_block.hpp" |
| 17 | +#include "storage/ipld/ipld_link.hpp" |
18 | 18 |
|
19 | 19 | namespace fc::storage::ipld { |
| 20 | + /** |
| 21 | + * @interface MerkleDAG service node |
| 22 | + */ |
| 23 | + class IPLDNode : public virtual IPLDBlock { |
| 24 | + public: |
| 25 | + virtual ~IPLDNode() = default; |
20 | 26 | /** |
21 | | - * @interface MerkleDAG service node |
| 27 | + * @brief Total size of the data including the total sizes of references |
| 28 | + * @return Cumulative size in bytes |
22 | 29 | */ |
23 | | - class IPLDNode : public virtual IPLDBlock { |
24 | | - public: |
25 | | - |
26 | | - virtual ~IPLDNode() = default; |
27 | | - /** |
28 | | - * @brief Total size of the data including the total sizes of references |
29 | | - * @return Cumulative size in bytes |
30 | | - */ |
31 | | - virtual size_t size() const = 0; |
| 30 | + virtual size_t size() const = 0; |
32 | 31 |
|
33 | | - /** |
34 | | - * @brief Assign Node's content |
35 | | - * @param input - data bytes |
36 | | - * @return operation result |
37 | | - */ |
38 | | - virtual void assign(common::Buffer input) = 0; |
| 32 | + /** |
| 33 | + * @brief Assign Node's content |
| 34 | + * @param input - data bytes |
| 35 | + * @return operation result |
| 36 | + */ |
| 37 | + virtual void assign(common::Buffer input) = 0; |
39 | 38 |
|
40 | | - /** |
41 | | - * @brief Get Node data |
42 | | - * @return content bytes |
43 | | - */ |
44 | | - virtual const common::Buffer &content() const = 0; |
| 39 | + /** |
| 40 | + * @brief Get Node data |
| 41 | + * @return content bytes |
| 42 | + */ |
| 43 | + virtual const common::Buffer &content() const = 0; |
45 | 44 |
|
46 | | - /** |
47 | | - * @brief Add link to the child node |
48 | | - * @param name - name of the child node |
49 | | - * @param node - child object to link |
50 | | - * @return operation result |
51 | | - */ |
52 | | - virtual outcome::result<void> addChild(const std::string &name, |
53 | | - std::shared_ptr<const IPLDNode> node) = 0; |
| 45 | + /** |
| 46 | + * @brief Add link to the child node |
| 47 | + * @param name - name of the child node |
| 48 | + * @param node - child object to link |
| 49 | + * @return operation result |
| 50 | + */ |
| 51 | + virtual outcome::result<void> addChild( |
| 52 | + const std::string &name, std::shared_ptr<const IPLDNode> node) = 0; |
54 | 53 |
|
55 | | - /** |
56 | | - * @brief Get particular link to the child node |
57 | | - * @param name - id of the link |
58 | | - * @return Requested link of error, if link not found |
59 | | - */ |
60 | | - virtual outcome::result<std::reference_wrapper<const IPLDLink>> getLink( |
61 | | - const std::string &name) const = 0; |
| 54 | + /** |
| 55 | + * @brief Get particular link to the child node |
| 56 | + * @param name - id of the link |
| 57 | + * @return Requested link of error, if link not found |
| 58 | + */ |
| 59 | + virtual outcome::result<std::reference_wrapper<const IPLDLink>> getLink( |
| 60 | + const std::string &name) const = 0; |
62 | 61 |
|
63 | | - /** |
64 | | - * @brief Remove link to the child node |
65 | | - * @param name - name of the child node |
66 | | - * @return operation result |
67 | | - */ |
68 | | - virtual void removeLink(const std::string &name) = 0; |
| 62 | + /** |
| 63 | + * @brief Remove link to the child node |
| 64 | + * @param name - name of the child node |
| 65 | + * @return operation result |
| 66 | + */ |
| 67 | + virtual void removeLink(const std::string &name) = 0; |
69 | 68 |
|
70 | | - /** |
71 | | - * @brief Insert link to the child node |
72 | | - * @param link - object to add |
73 | | - */ |
74 | | - virtual void addLink(const IPLDLink &link) = 0; |
| 69 | + /** |
| 70 | + * @brief Insert link to the child node |
| 71 | + * @param link - object to add |
| 72 | + */ |
| 73 | + virtual void addLink(const IPLDLink &link) = 0; |
75 | 74 |
|
76 | | - virtual std::vector<std::reference_wrapper<const IPLDLink>> getLinks() |
| 75 | + virtual std::vector<std::reference_wrapper<const IPLDLink>> getLinks() |
77 | 76 | const = 0; |
78 | | - }; |
| 77 | + }; |
79 | 78 |
|
80 | | - /** |
81 | | - * @class Possible Node errors |
82 | | - */ |
83 | | - enum class IPLDNodeError : int { LINK_NOT_FOUND, INVALID_RAW_DATA }; |
84 | | -} // namespace fc::storage::ipfs::merkledag |
| 79 | + /** |
| 80 | + * @class Possible Node errors |
| 81 | + */ |
| 82 | + enum class IPLDNodeError { LINK_NOT_FOUND = 1, INVALID_RAW_DATA }; |
| 83 | +} // namespace fc::storage::ipld |
85 | 84 |
|
86 | 85 | OUTCOME_HPP_DECLARE_ERROR(fc::storage::ipld, IPLDNodeError) |
87 | 86 |
|
|
0 commit comments