OpenCog Framework
Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
|
#include <Atom.h>
Classes | |
struct | InSet |
Public Member Functions | |
virtual | ~Atom () |
Type | getType () const |
bool | isType (Type t, bool subclass) const |
Handle | getHandle () |
AttentionValuePtr | getAttentionValue () |
void | setAttentionValue (AttentionValuePtr) |
Sets the AttentionValue object of the atom. More... | |
AttentionValue::sti_t | getSTI () |
Handy-dandy convenience getters for attention values. More... | |
AttentionValue::lti_t | getLTI () |
AttentionValue::vlti_t | getVLTI () |
void | setSTI (AttentionValue::sti_t stiValue) |
void | setLTI (AttentionValue::lti_t ltiValue) |
void | incVLTI () |
void | decVLTI () |
TruthValuePtr | getTruthValue () |
void | setTruthValue (TruthValuePtr) |
Sets the TruthValue object of the atom. More... | |
void | merge (TruthValuePtr) |
Handle | tvmerge (TruthValuePtr tv) |
size_t | getIncomingSetSize () |
Get the size of the incoming set. More... | |
IncomingSet | getIncomingSet () |
template<typename OutputIterator > | |
OutputIterator | getIncomingSet (OutputIterator result) |
template<class T > | |
bool | foreach_incoming (bool(T::*cb)(const Handle &), T *data) |
template<typename OutputIterator > | |
OutputIterator | getIncomingSetByType (OutputIterator result, Type type, bool subclass=false) |
IncomingSet | getIncomingSetByType (Type type, bool subclass=false) |
virtual std::string | toString (std::string indent="")=0 |
virtual std::string | toShortString (std::string indent="")=0 |
virtual bool | operator== (const Atom &) const =0 |
virtual bool | operator!= (const Atom &) const =0 |
Protected Types | |
typedef std::shared_ptr< InSet > | InSetPtr |
Protected Member Functions | |
Atom (Type t, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
void | keep_incoming_set () |
void | drop_incoming_set () |
void | insert_atom (LinkPtr) |
Add an atom to the incoming set. More... | |
void | remove_atom (LinkPtr) |
Remove an atom from the incoming set. More... | |
Protected Attributes | |
UUID | _uuid |
AtomTable * | _atomTable |
Type | _type |
char | _flags |
TruthValuePtr | _truthValue |
AttentionValuePtr | _attentionValue |
std::mutex | _mtx |
InSetPtr | _incoming_set |
Private Member Functions | |
void | setAtomTable (AtomTable *) |
Sets the AtomTable in which this Atom is inserted. More... | |
AtomTable * | getAtomTable () const |
Returns the AtomTable in which this Atom is inserted. More... | |
bool | isMarkedForRemoval () const |
bool | getFlag (int) const |
void | setFlag (int, bool) |
void | markForRemoval () |
Marks the atom for removal. More... | |
void | unsetRemovalFlag () |
Unsets removal flag. More... | |
void | chgVLTI (int unit) |
Friends | |
class | ::AtomUTest |
class | AtomStorage |
class | AtomTable |
class | ImportanceIndex |
class | Handle |
class | SavingLoading |
class | TLB |
class | CreateLink |
class | DeleteLink |
Atoms are the basic implementational unit in the system that represents nodes and links. In terms of inheritance, nodes and links are specialization of atoms, that is, they inherit all properties from atoms.
|
protected |
|
inlineprotected |
Constructor for this class. Protected; no user should call this directly. Only derived classes (Node, Link) can call this.
The | type of the atom. |
Outgoing | set of the atom, that is, the set of atoms this atom references. It must be an empty vector if the atom is a node. |
The | truthValue of the atom. note: This is not cloned as in setTruthValue. |
|
virtual |
Definition at line 62 of file Atom.cc.
References _atomTable, _type, _uuid, opencog::classserver(), drop_incoming_set(), getIncomingSet(), and getIncomingSetSize().
|
private |
Change the Very-Long-Term Importance
Definition at line 196 of file Atom.cc.
References createAV, getAttentionValue(), and setAttentionValue().
|
inline |
|
protected |
Stop tracking the incoming set for this atom. After this call, the incoming set for this atom can no longer be queried; it is erased.
Definition at line 279 of file Atom.cc.
References _incoming_set, and _mtx.
|
inline |
Invoke the callback on each atom in the incoming set of handle h, until one of them returns true, in which case iteration stopsm and true is returned. Otherwise the callback is called on all incomings and false is returned.
Definition at line 329 of file Atom.h.
References getIncomingSet().
|
inlineprivate |
Returns the AtomTable in which this Atom is inserted.
Definition at line 90 of file Atom.h.
References _atomTable.
AttentionValuePtr Atom::getAttentionValue | ( | ) |
Returns the AttentionValue object of the atom.
Definition at line 146 of file Atom.cc.
References _attentionValue, and _mtx.
|
private |
|
inline |
IncomingSet Atom::getIncomingSet | ( | ) |
Return the incoming set of this atom. The resulting incoming set consists of strong pointers, that is, to valid, non-null handles that were part of the incoming set at the time this call was made.
Definition at line 321 of file Atom.cc.
References _incoming_set, and _mtx.
|
inline |
Place incoming set into STL container of Handles. Example usage: std::vector<Handle> hvect; atom->getIncomingSet(back_inserter(hvect)); The resulting vector hvect will contain only valid handles that were actually part of the incoming set at the time of the call to this function.
Definition at line 309 of file Atom.h.
References _incoming_set, _mtx, and python.bindlink::result.
|
inline |
Returns the set of atoms with a given target handle in their outgoing set (atom type and its subclasses optionally). That is, returns the incoming set of Handle h, with some optional filtering.
The | handle that must be in the outgoing set of the atom. |
The | optional type of the atom. |
Whether | atom type subclasses should be considered. |
Definition at line 353 of file Atom.h.
References _incoming_set, _mtx, and python.bindlink::result.
IncomingSet Atom::getIncomingSetByType | ( | Type | type, |
bool | subclass = false |
||
) |
Functional version of getIncomingSetByType
Definition at line 337 of file Atom.cc.
References getIncomingSetByType(), and opencog::LinkCast().
size_t Atom::getIncomingSetSize | ( | ) |
Get the size of the incoming set.
Definition at line 310 of file Atom.cc.
References _incoming_set, and _mtx.
|
inline |
Definition at line 231 of file Atom.h.
References getAttentionValue().
|
inline |
Handy-dandy convenience getters for attention values.
Definition at line 226 of file Atom.h.
References getAttentionValue().
TruthValuePtr Atom::getTruthValue | ( | ) |
Returns the TruthValue object of the atom.
Definition at line 104 of file Atom.cc.
References _mtx, and _truthValue.
|
inline |
|
inline |
Definition at line 236 of file Atom.h.
References getAttentionValue().
|
inline |
|
protected |
Add an atom to the incoming set.
Definition at line 289 of file Atom.cc.
References _incoming_set, and _mtx.
|
private |
Returns whether this atom is marked for removal.
Definition at line 208 of file Atom.cc.
References _flags, and MARKED_FOR_REMOVAL.
|
inline |
Basic predicate
Definition at line 200 of file Atom.h.
References opencog::classserver(), getType(), and opencog::ClassServer::isA().
|
protected |
Start tracking the incoming set for this atom. An atom can't know what it's incoming set is, until this method is called. If this atom is added to any links before this call is made, those links won't show up in the incoming set.
We don't automatically track incoming sets for two reasons: 1) std::set takes up 48 bytes 2) adding and remoiving uses up cpu cycles. Thus, if the incoming set isn't needed, then don't bother tracking it.
Definition at line 270 of file Atom.cc.
References _incoming_set.
|
private |
Marks the atom for removal.
Definition at line 232 of file Atom.cc.
References _flags, and MARKED_FOR_REMOVAL.
void Atom::merge | ( | TruthValuePtr | tvn | ) |
merge truth value into this
Definition at line 122 of file Atom.cc.
References getTruthValue(), and setTruthValue().
|
pure virtual |
Returns whether two atoms are different.
Implemented in opencog::Link, and opencog::Node.
|
pure virtual |
Returns whether two atoms are equal.
Implemented in opencog::Link, and opencog::Node.
|
protected |
Remove an atom from the incoming set.
Definition at line 300 of file Atom.cc.
References _incoming_set, and _mtx.
|
private |
Sets the AtomTable in which this Atom is inserted.
Definition at line 239 of file Atom.cc.
References _atomTable, _uuid, opencog::Handle::UNDEFINED, and opencog::Handle::value().
void Atom::setAttentionValue | ( | AttentionValuePtr | av | ) |
Sets the AttentionValue object of the atom.
Definition at line 163 of file Atom.cc.
References _atomTable, _attentionValue, _avmtx, python.create_atoms_by_type::a, av, opencog::AtomTable::AVChangedSignal(), getAttentionValue(), getHandle(), opencog::ImportanceIndex::importanceBin(), and opencog::AtomTable::updateImportanceIndex().
|
private |
|
inline |
Change the Long-term Importance
Definition at line 254 of file Atom.h.
References createAV, getAttentionValue(), and setAttentionValue().
|
inline |
Change the Short-Term Importance
Definition at line 242 of file Atom.h.
References createAV, getAttentionValue(), and setAttentionValue().
void Atom::setTruthValue | ( | TruthValuePtr | newTV | ) |
Sets the TruthValue object of the atom.
Definition at line 81 of file Atom.cc.
References _atomTable, _mtx, _truthValue, getHandle(), getTruthValue(), and opencog::AtomTable::TVChangedSignal().
|
pure virtual |
|
pure virtual |
Returns a string representation of the node.
Implemented in opencog::Link, and opencog::Node.
|
inline |
|
private |
Unsets removal flag.
Definition at line 227 of file Atom.cc.
References _flags, and MARKED_FOR_REMOVAL.
|
friend |
|
friend |
|
friend |
|
protected |
|
protected |