OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
opencog::AssignLink Class Reference

#include <AssignLink.h>

+ Inheritance diagram for opencog::AssignLink:
+ Collaboration diagram for opencog::AssignLink:

Public Member Functions

 AssignLink (const HandleSeq &, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 AssignLink (Type t, const HandleSeq &, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 AssignLink (Link &l)
 
virtual Handle execute (AtomSpace *=NULL) const
 
- Public Member Functions inherited from opencog::Atom
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)
 

Protected Member Functions

void init (const HandleSeq &)
 
- Protected Member Functions inherited from opencog::Atom
 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

Type _link_type
 
HandleSeq _outset
 
size_t _osetz
 
- Protected Attributes inherited from opencog::Atom
UUID _uuid
 
AtomTable_atomTable
 
Type _type
 
char _flags
 
TruthValuePtr _truthValue
 
AttentionValuePtr _attentionValue
 
std::mutex _mtx
 
InSetPtr _incoming_set
 

Additional Inherited Members

- Protected Types inherited from opencog::Atom
typedef std::shared_ptr< InSetInSetPtr
 

Detailed Description

The InsertLink is used to create atoms at some defered time in the future, while still being able to describe and talk about them at the present time. The issue that it is solving is this: when an atom is explicitly named, it also becomes a member of the AtomSpace; that is, it is brought into existance by naming it. The usual mechanism for deferring the creation of an atom is to place a VariableNode in it; theatom is then created later, when the Variable is given a value. The InsertLink provides an alternative mechanism, without requiring the use of VariableNodes.

The InsertLink is a kind of executable link; that it, upon execution, it transforms into another link. It should have the following form:

InsertLink TypeNode "SomeLink" SomeAtom OtherAtom

Upon execution, this will result in the following being created:

SomeLink SomeAtom OtherAtom

The RemoveLink is like the InsertLink, except that it causes the indicated form to be deleted (removed from the atomspace). If the RemoveLink contains variables, and those variables are free, then all matching paterns will be deleted from the AtomSpace.

The InsertLink vaguely resembles the ProLog predicate "assert()" with respect to what it does to the atomspace database. The RemoveLink behaves like the ProLog "retract()" predicate.

The AssignLink combines the Insert and Remove into one. Since the format does not allow a close specification of the exact link to be removed, it will remove all atoms fitting the general pattern, i.e. those links having the indicated link type, the same first atom (SomeAtom, above), and the same arity. It will not remove those links containing variables, as these are not concrete (closed), but open. It will do this before performing the Insert.

To be precise:

AssignLink
    TypeNode "SomeLink"
    SomeAtom
    OtherAtom

is identical to saying:

RemoveLink
    TypeNode "SomeLink"
    SomeAtom
    VariableNode "$free"

InsertLink
    TypeNode "SomeLink"
    SomeAtom
    OtherAtom

Definition at line 97 of file AssignLink.h.

Constructor & Destructor Documentation

AssignLink::AssignLink ( const HandleSeq oset,
TruthValuePtr  tv = TruthValue::DEFAULT_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)

Definition at line 35 of file AssignLink.cc.

References opencog::FreeLink::init().

AssignLink::AssignLink ( Type  t,
const HandleSeq oset,
TruthValuePtr  tv = TruthValue::DEFAULT_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)

Member Function Documentation

Handle AssignLink::execute ( AtomSpace as = NULL) const
virtual
void AssignLink::init ( const HandleSeq oset)
protected

Member Data Documentation

Type opencog::AssignLink::_link_type
protected

Definition at line 101 of file AssignLink.h.

size_t opencog::AssignLink::_osetz
protected

Definition at line 103 of file AssignLink.h.

HandleSeq opencog::AssignLink::_outset
protected

Definition at line 102 of file AssignLink.h.


The documentation for this class was generated from the following files: