| … | … | @@ -37,7 +37,7 @@ using namespace opencog; |
| 37 | 37 | // ==================================================================== |
| 38 | 38 | |
| 39 | 39 | StorageNode::StorageNode(Type t, std::string uri) : |
| 40 | | Node(t, uri) |
| 40 | ObjectCRTP<StorageNode>(t, std::move(uri)) |
| 41 | 41 | { |
| 42 | 42 | if (not nameserver().isA(t, STORAGE_NODE)) |
| 43 | 43 | throw RuntimeException(TRACE_INFO, "Bad inheritance!"); |
| … | … | @@ -47,103 +47,6 @@ StorageNode::~StorageNode() |
| 47 | 47 | { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | | HandleSeq StorageNode::getMessages() const |
| 51 | | { |
| 52 | | static const HandleSeq msgs = []() { |
| 53 | | HandleSeq m({ |
| 54 | | createNode(PREDICATE_NODE, "*-open-*"), |
| 55 | | createNode(PREDICATE_NODE, "*-close-*"), |
| 56 | | createNode(PREDICATE_NODE, "*-load-atomspace-*"), |
| 57 | | createNode(PREDICATE_NODE, "*-store-atomspace-*"), |
| 58 | | createNode(PREDICATE_NODE, "*-load-atoms-of-type-*"), |
| 59 | | createNode(PREDICATE_NODE, "*-store-atom-*"), |
| 60 | | createNode(PREDICATE_NODE, "*-store-value-*"), |
| 61 | | createNode(PREDICATE_NODE, "*-update-value-*"), |
| 62 | | |
| 63 | | createNode(PREDICATE_NODE, "*-fetch-atom-*"), |
| 64 | | createNode(PREDICATE_NODE, "*-fetch-value-*"), |
| 65 | | createNode(PREDICATE_NODE, "*-fetch-incoming-set-*"), |
| 66 | | createNode(PREDICATE_NODE, "*-fetch-incoming-by-type-*"), |
| 67 | | createNode(PREDICATE_NODE, "*-fetch-query-*"), |
| 68 | | |
| 69 | | createNode(PREDICATE_NODE, "*-delete-*"), |
| 70 | | createNode(PREDICATE_NODE, "*-delete-recursive-*"), |
| 71 | | createNode(PREDICATE_NODE, "*-barrier-*"), |
| 72 | | |
| 73 | | createNode(PREDICATE_NODE, "*-store-frames-*"), |
| 74 | | createNode(PREDICATE_NODE, "*-delete-frame-*"), |
| 75 | | createNode(PREDICATE_NODE, "*-erase-*"), |
| 76 | | |
| 77 | | createNode(PREDICATE_NODE, "*-proxy-open-*"), |
| 78 | | createNode(PREDICATE_NODE, "*-proxy-close-*"), |
| 79 | | createNode(PREDICATE_NODE, "*-set-proxy-*"), |
| 80 | | |
| 81 | | // Used only in getValue |
| 82 | | createNode(PREDICATE_NODE, "*-load-frames-*"), |
| 83 | | createNode(PREDICATE_NODE, "*-connected?-*"), |
| 84 | | createNode(PREDICATE_NODE, "*-load-frames-*"), |
| 85 | | createNode(PREDICATE_NODE, "*-monitor-*") |
| 86 | | }); |
| 87 | | // Mark each message predicate as a message, once at load time. |
| 88 | | for (const Handle& h : m) |
| 89 | | h->markIsMessage(); |
| 90 | | return m; |
| 91 | | }(); |
| 92 | | |
| 93 | | // Copy list above into the local AtomSpace. If this is not done, |
| 94 | | // then (cog-execute! (IsMessage (Predicate "*-open-*"))) will fail. |
| 95 | | HandleSeq lms; |
| 96 | | for (const Handle& m : msgs) |
| 97 | | lms.emplace_back(_atom_space->add(m)); |
| 98 | | return lms; |
| 99 | | } |
| 100 | | |
| 101 | | bool StorageNode::usesMessage(const Handle& key) const |
| 102 | | { |
| 103 | | static const std::unordered_set<uint32_t> msgset({ |
| 104 | | dispatch_hash("*-open-*"), |
| 105 | | dispatch_hash("*-close-*"), |
| 106 | | dispatch_hash("*-load-atomspace-*"), |
| 107 | | dispatch_hash("*-store-atomspace-*"), |
| 108 | | dispatch_hash("*-load-atoms-of-type-*"), |
| 109 | | dispatch_hash("*-store-atom-*"), |
| 110 | | dispatch_hash("*-store-value-*"), |
| 111 | | dispatch_hash("*-update-value-*"), |
| 112 | | |
| 113 | | dispatch_hash("*-fetch-atom-*"), |
| 114 | | dispatch_hash("*-fetch-value-*"), |
| 115 | | dispatch_hash("*-fetch-incoming-set-*"), |
| 116 | | dispatch_hash("*-fetch-incoming-by-type-*"), |
| 117 | | dispatch_hash("*-fetch-query-*"), |
| 118 | | |
| 119 | | dispatch_hash("*-delete-*"), |
| 120 | | dispatch_hash("*-delete-recursive-*"), |
| 121 | | dispatch_hash("*-barrier-*"), |
| 122 | | |
| 123 | | dispatch_hash("*-store-frames-*"), |
| 124 | | dispatch_hash("*-delete-frame-*"), |
| 125 | | dispatch_hash("*-erase-*"), |
| 126 | | |
| 127 | | dispatch_hash("*-proxy-open-*"), |
| 128 | | dispatch_hash("*-proxy-close-*"), |
| 129 | | dispatch_hash("*-set-proxy-*") |
| 130 | | }); |
| 131 | | |
| 132 | | // Messages used in getValue only don't need to be published here, |
| 133 | | // because only the setValue ones need the COW, R/O work-around. |
| 134 | | // ("*-load-frames-*") |
| 135 | | // ("*-connected?-*") |
| 136 | | // ("*-load-frames-*") |
| 137 | | // ("*-monitor-*") |
| 138 | | |
| 139 | | if (PREDICATE_NODE != key->get_type()) return false; |
| 140 | | |
| 141 | | const std::string& pred = key->get_name(); |
| 142 | | uint32_t dhsh = dispatch_hash(pred.c_str()); |
| 143 | | if (msgset.find(dhsh) != msgset.end()) return true; |
| 144 | | return false; |
| 145 | | } |
| 146 | | |
| 147 | 50 | void StorageNode::setValue(const Handle& key, const ValuePtr& value) |
| 148 | 51 | { |
| 149 | 52 | // The value must be stored only if it is not one of the values |