| … | … | @@ -1,54 +0,0 @@ |
| 1 | /* | |
| 2 | * opencog/persist/api/DispathcHash.h | |
| 3 | * | |
| 4 | * Copyright (C) 2025 Linas Vepstas | |
| 5 | * All Rights Reserved | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU Affero General Public License v3 as | |
| 9 | * published by the Free Software Foundation and including the exceptions | |
| 10 | * at http://opencog.org/wiki/Licenses | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU Affero General Public License | |
| 18 | * along with this program; if not, write to: | |
| 19 | * Free Software Foundation, Inc., | |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 21 | */ | |
| 22 | ||
| 23 | #ifndef _OPENCOG_DISPATCH_HASH_H | |
| 24 | #define _OPENCOG_DISPATCH_HASH_H | |
| 25 | ||
| 26 | #include <string> | |
| 27 | ||
| 28 | namespace opencog | |
| 29 | { | |
| 30 | ||
| 31 | /// Implement Jenkins' One-at-a-Time hash. | |
| 32 | /// For these very short strings, I cannot think of a faster hash. | |
| 33 | /// The 4-byte-at-a-time hashes require knowng the string length :-( | |
| 34 | static constexpr uint32_t dispatch_hash(const char* s) | |
| 35 | { | |
| 36 | uint32_t hash = 0; | |
| 37 | ||
| 38 | for(; *s; ++s) | |
| 39 | { | |
| 40 | hash += *s; | |
| 41 | hash += (hash << 10); | |
| 42 | hash ^= (hash >> 6); | |
| 43 | } | |
| 44 | ||
| 45 | hash += (hash << 3); | |
| 46 | hash ^= (hash >> 11); | |
| 47 | hash += (hash << 15); | |
| 48 | ||
| 49 | return hash; | |
| 50 | } | |
| 51 | ||
| 52 | } // namespace opencog | |
| 53 | ||
| 54 | #endif // _OPENCOG_DISPATCH_HASH_H |
| … | … | @@ -27,7 +27,6 @@ |
| 27 | 27 | #include <opencog/atoms/value/BoolValue.h> |
| 28 | 28 | #include <opencog/atoms/value/StringValue.h> |
| 29 | 29 | #include <opencog/atoms/value/VoidValue.h> |
| 30 | #include "DispatchHash.h" | |
| 31 | 30 | #include "SensoryNode.h" |
| 32 | 31 | |
| 33 | 32 | using namespace opencog; |
| … | … | @@ -35,7 +34,7 @@ using namespace opencog; |
| 35 | 34 | // ==================================================================== |
| 36 | 35 | |
| 37 | 36 | SensoryNode::SensoryNode(Type t, const std::string&& uri) : |
| 38 | Node(t, std::move(uri)) | |
| 37 | ObjectCRTP<SensoryNode>(t, std::move(uri)) | |
| 39 | 38 | { |
| 40 | 39 | if (not nameserver().isA(t, SENSORY_NODE)) |
| 41 | 40 | throw RuntimeException(TRACE_INFO, "Bad inheritance!"); |
| … | … | @@ -45,11 +44,6 @@ SensoryNode::~SensoryNode() |
| 45 | 44 | { |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | std::string SensoryNode::monitor(void) const | |
| 49 | { | |
| 50 | return "This SensoryNode does not implement a monitor."; | |
| 51 | } | |
| 52 | ||
| 53 | 47 | void SensoryNode::barrier(AtomSpace* as) |
| 54 | 48 | { |
| 55 | 49 | if (nullptr == as) as = getAtomSpace(); |
| … | … | @@ -23,7 +23,7 @@ |
| 23 | 23 | #ifndef _OPENCOG_SENSORY_NODE_H |
| 24 | 24 | #define _OPENCOG_SENSORY_NODE_H |
| 25 | 25 | |
| 26 | #include <opencog/atoms/base/Node.h> | |
| 26 | #include <opencog/atoms/core/ObjectNode.h> | |
| 27 | 27 | #include <opencog/sensory/types/atom_types.h> |
| 28 | 28 | |
| 29 | 29 | namespace opencog |
| … | … | @@ -34,7 +34,7 @@ namespace opencog |
| 34 | 34 | |
| 35 | 35 | // Dispatcher for setValue, getValue. |
| 36 | 36 | // Also, holder of URL's. |
| 37 | class SensoryNode : public Node | |
| 37 | class SensoryNode : public ObjectCRTP<SensoryNode> | |
| 38 | 38 | { |
| 39 | 39 | friend class ReadStream; |
| 40 | 40 | friend class StringStream; |
| … | … | @@ -42,11 +42,6 @@ class SensoryNode : public Node |
| 42 | 42 | protected: |
| 43 | 43 | SensoryNode(Type, const std::string&&); |
| 44 | 44 | |
| 45 | /** | |
| 46 | * Return debug diagnostics and/or performance monitoring stats. | |
| 47 | */ | |
| 48 | virtual std::string monitor(void) const; | |
| 49 | ||
| 50 | 45 | /** |
| 51 | 46 | * Default API that sensory nodes must provide. Similar to |
| 52 | 47 | * the current StorageNode API. |