OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace commits / f452cbb

Set up the parent AtomSpaces.
f452cbb6f2c1a87b758febc80a336334b0146496
by Linas Vepštas <linasvepstas@gmail.com> · 2026-01-21T01:41:17.000Z

Changed files (2) +34 -27

opencog/atomspace/AtomSpace.cc +28 -24
……@@ -109,30 +109,6 @@ AtomSpace::AtomSpace(const HandleSeq& bases) :
109109 _nameserver(nameserver()),
110110 addedTypeConnection(0)
111111{
112 for (const Handle& base : bases)
113 {
114 if (_nameserver.isA(base->get_type(), ATOM_SPACE))
115 {
116 _environ.push_back(AtomSpaceCast(base));
117 continue;
118 }
119 if (base->is_executable())
120 {
121 ValuePtr vp(base->execute());
122 AtomSpacePtr as(AtomSpaceCast(vp));
123 if (nullptr == as)
124 throw RuntimeException(TRACE_INFO,
125 "AtomSpace - executable base not an AtomSpace! Got %s",
126 vp->to_string().c_str());
127 _environ.push_back(as);
128 continue;
129 }
130
131 throw RuntimeException(TRACE_INFO,
132 "AtomSpace - bases must be AtomSpaces! Got %s",
133 base->to_string().c_str());
134 }
135
136112 if (0 < bases.size()) _copy_on_write = true;
137113 init();
138114}
……@@ -143,8 +119,36 @@ AtomSpace::~AtomSpace()
143119 clear_all_atoms();
144120}
145121
122// Set up a vector points to the parent AtomSpaces.
146123void AtomSpace::do_install(void)
147124{
125 if (0 == _environ.size())
126 {
127 for (const Handle& base : _outgoing)
128 {
129 if (_nameserver.isA(base->get_type(), ATOM_SPACE))
130 {
131 _environ.push_back(AtomSpaceCast(base));
132 continue;
133 }
134 if (base->is_executable())
135 {
136 ValuePtr vp(base->execute());
137 AtomSpacePtr as(AtomSpaceCast(vp));
138 if (nullptr == as)
139 throw RuntimeException(TRACE_INFO,
140 "AtomSpace - executable base not an AtomSpace! Got %s",
141 vp->to_string().c_str());
142 _environ.push_back(as);
143 continue;
144 }
145
146 throw RuntimeException(TRACE_INFO,
147 "AtomSpace - bases must be AtomSpaces! Got %s",
148 base->to_string().c_str());
149 }
150 }
151
148152 // XXX FIXME. I think this is installing into the wrong AtomSpace.
149153 // Maybe. I'm confused. But no unit test seems to fail as a result
150154 // of this, so I dunno. Go figure.
opencog/atomspace/AtomSpace.h +6 -3
……@@ -73,9 +73,12 @@ class AtomSpace : public Frame
7373 /// This AtomSpace will behave like the set-union of the base
7474 /// atomspaces in the `_environ`: it exposes all Atoms in those
7575 /// bases, plus also anything in this AtomSpace.
76 // Both _environ and _outgoing contain exactly the same pointers;
77 // we keep two distinct lists to avoid the CPU overhead of casting
78 // between the two different pointer types (its significant).
76 //
77 // This _environ vector is similar to _outgoing but not the same.
78 // The _outgoing vector can contain regular Atoms (not AtomSpaces)
79 // that are executable, and, when executed, return AtomSpaces. The
80 // result of this execution is stored in _environ; the original
81 // Atoms are in _outgoing.
7982 std::vector<AtomSpacePtr> _environ;
8083 void do_install();
8184