OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-sensory commits / 0762977

SensoryNode to inherit from ObjectNode
07629771cd0b5bb97110dd872b18eb8ab41f6d7e
by Linas Vepštas <linasvepstas@gmail.com> · 2026-01-17T22:32:11.000Z

Changed files (3) +3 -68

opencog/atoms/sensory/DispatchHash.h +0 -54
……@@ -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
28namespace 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 :-(
34static 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
opencog/atoms/sensory/SensoryNode.cc +1 -7
……@@ -27,7 +27,6 @@
2727#include <opencog/atoms/value/BoolValue.h>
2828#include <opencog/atoms/value/StringValue.h>
2929#include <opencog/atoms/value/VoidValue.h>
30#include "DispatchHash.h"
3130#include "SensoryNode.h"
3231
3332using namespace opencog;
……@@ -35,7 +34,7 @@ using namespace opencog;
3534// ====================================================================
3635
3736SensoryNode::SensoryNode(Type t, const std::string&& uri) :
38 Node(t, std::move(uri))
37 ObjectCRTP<SensoryNode>(t, std::move(uri))
3938{
4039 if (not nameserver().isA(t, SENSORY_NODE))
4140 throw RuntimeException(TRACE_INFO, "Bad inheritance!");
……@@ -45,11 +44,6 @@ SensoryNode::~SensoryNode()
4544{
4645}
4746
48std::string SensoryNode::monitor(void) const
49{
50 return "This SensoryNode does not implement a monitor.";
51}
52
5347void SensoryNode::barrier(AtomSpace* as)
5448{
5549 if (nullptr == as) as = getAtomSpace();
opencog/atoms/sensory/SensoryNode.h +2 -7
……@@ -23,7 +23,7 @@
2323#ifndef _OPENCOG_SENSORY_NODE_H
2424#define _OPENCOG_SENSORY_NODE_H
2525
26#include <opencog/atoms/base/Node.h>
26#include <opencog/atoms/core/ObjectNode.h>
2727#include <opencog/sensory/types/atom_types.h>
2828
2929namespace opencog
……@@ -34,7 +34,7 @@ namespace opencog
3434
3535// Dispatcher for setValue, getValue.
3636// Also, holder of URL's.
37class SensoryNode : public Node
37class SensoryNode : public ObjectCRTP<SensoryNode>
3838{
3939 friend class ReadStream;
4040 friend class StringStream;
……@@ -42,11 +42,6 @@ class SensoryNode : public Node
4242protected:
4343 SensoryNode(Type, const std::string&&);
4444
45 /**
46 * Return debug diagnostics and/or performance monitoring stats.
47 */
48 virtual std::string monitor(void) const;
49
5045 /**
5146 * Default API that sensory nodes must provide. Similar to
5247 * the current StorageNode API.