31 #include <boost/bind.hpp>
38 #include <opencog/util/Logger.h>
39 #include <opencog/util/oc_assert.h>
52 using namespace opencog;
57 atomTable(parent? &parent->atomTable : NULL, this),
75 throw opencog::RuntimeException(TRACE_INFO,
76 "AtomSpace - Cannot copy an object of this class");
81 throw opencog::RuntimeException(TRACE_INFO,
82 "AtomSpace - Cannot copy an object of this class");
104 if (hexist)
return hexist;
108 Type t = atom->getType();
125 catch (
const DeleteException& ex) {
130 throw RuntimeException(TRACE_INFO,
"Not implemented!!!");
140 if (hexist)
return hexist;
159 if (hexist)
return hexist;
180 if (hexist)
return hexist;
188 if (not std::any_of(outgoing.begin(), outgoing.end(),
207 catch (
const DeleteException& ex) {
212 throw RuntimeException(TRACE_INFO,
"Not implemented!!!");
221 if (hexist)
return hexist;
229 if (not std::any_of(outgoing.begin(), outgoing.end(),
248 throw RuntimeException(TRACE_INFO,
"No backing store");
256 throw RuntimeException(TRACE_INFO,
"No backing store");
281 if (NULL == h.operator->()) {
287 if (NULL ==
a.operator->())
288 throw RuntimeException(TRACE_INFO,
289 "Asked backend for an unknown handle; UUID=%lu\n",
298 const HandleSeq& ogs = l->getOutgoingSet();
299 size_t arity = ogs.size();
300 for (
size_t i=0; i<arity; i++)
303 if (oh != ogs[i])
throw RuntimeException(TRACE_INFO,
304 "Unexpected handle mismatch! Expected %lu got %lu\n",
305 ogs[i].value(), oh.
value());
324 throw RuntimeException(TRACE_INFO,
"No backing store");
332 size_t isz = iset.size();
333 for (
size_t i=0; i<isz; i++) {
350 throw RuntimeException(TRACE_INFO,
"Not implemented!!!");
357 std::vector<Handle> allAtoms;
361 DPRINTF(
"atoms in allAtoms: %lu\n", allAtoms.size());
363 Logger::Level save = logger().getLevel();
364 logger().setLevel(Logger::DEBUG);
368 std::vector<Handle>::iterator i;
369 for (i = allAtoms.begin(); i != allAtoms.end(); ++i) {
375 assert(allAtoms.size() == 0);
377 logger().setLevel(save);
383 list<opencog::Handle> results;
386 if (h->getIncomingSetSize() == 0)
387 out << h->toString() << endl;
bool purge_atom(Handle h, bool recursive=false)
Handle add_node(Type t, const std::string &name="", bool async=false)
AtomSpace(const AtomSpace &)
BackingStore * backing_store
std::vector< Handle > HandleSeq
a list of handles
std::shared_ptr< Atom > AtomPtr
void registerBackingStore(BackingStore *)
virtual LinkPtr getLink(Type, const HandleSeq &) const =0
Handle add(AtomPtr, bool async)
bool holds(Handle &h) const
AtomSpace & operator=(const AtomSpace &)
std::shared_ptr< Link > LinkPtr
AtomPtrSet extract(Handle &handle, bool recursive=true)
void get_handles_by_type(HandleSeq &appendToHandles, Type type, bool subclass=false) const
void unregisterBackingStore(BackingStore *)
static const Handle UNDEFINED
Handle getHandle(Type, std::string) const
virtual bool ignoreType(Type t) const
Handle get_node(Type t, const std::string &name="")
bool remove_atom(Handle h, bool recursive=false)
virtual HandleSeq getIncomingSet(Handle) const =0
ostream & operator<<(ostream &out, const opencog::AtomSpace &as)
static LinkPtr LinkCast(const Handle &h)
std::shared_ptr< Node > NodePtr
Handle get_link(Type t, const HandleSeq &outgoing)
virtual AtomPtr getAtom(Handle) const =0
virtual bool ignoreAtom(Handle) const
unsigned short Type
type of Atoms, represented as short integer (16 bits)
void store_atom(Handle h)
Handle add_link(Type t, const HandleSeq &outgoing, bool async=false)
virtual NodePtr getNode(Type, const char *) const =0
Handle fetch_atom(Handle h)
virtual void storeAtom(Handle)=0
OutputIterator getHandlesByType(OutputIterator result, Type type, bool subclass=false, bool parent=true) const
void clear()
Clear the atomspace, remove all atoms.
Handle fetch_incoming_set(Handle, bool)
Handle add_atom(AtomPtr atom, bool async=false)