OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AssignLink.h
Go to the documentation of this file.
1 /*
2  * opencog/atoms/AssignLink.h
3  *
4  * Copyright (C) 2015 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_ASSIGN_LINK_H
24 #define _OPENCOG_ASSIGN_LINK_H
25 
26 #include <map>
27 
29 
30 namespace opencog
31 {
36 class AssignLink : public FunctionLink
98 {
99 protected:
100  void init(const HandleSeq&);
103  size_t _osetz;
104 
105 public:
106  AssignLink(const HandleSeq&,
109 
110  AssignLink(Type t, const HandleSeq&,
113 
114  AssignLink(Link &l);
115 
116  // Return a pointer to the atom being specified.
117  virtual Handle execute(AtomSpace* = NULL) const;
118 };
119 
120 typedef std::shared_ptr<AssignLink> AssignLinkPtr;
121 static inline AssignLinkPtr AssignLinkCast(const Handle& h)
122  { AtomPtr a(h); return std::dynamic_pointer_cast<AssignLink>(a); }
124  { return std::dynamic_pointer_cast<AssignLink>(a); }
125 
126 // XXX temporary hack ...
127 #define createAssignLink std::make_shared<AssignLink>
128 
129 class InsertLink : public AssignLink
130 {
131 protected:
132 
133 public:
134  InsertLink(const HandleSeq&,
137 
138  InsertLink(Link &l);
139 
140  // Return a pointer to the atom being specified.
141  virtual Handle execute(AtomSpace* = NULL) const;
142 };
143 
144 typedef std::shared_ptr<InsertLink> InsertLinkPtr;
145 static inline InsertLinkPtr InsertLinkCast(const Handle& h)
146  { AtomPtr a(h); return std::dynamic_pointer_cast<InsertLink>(a); }
148  { return std::dynamic_pointer_cast<InsertLink>(a); }
149 
150 // XXX temporary hack ...
151 #define createInsertLink std::make_shared<InsertLink>
152 
153 class RemoveLink : public AssignLink
154 {
155 protected:
156 
157 public:
158  RemoveLink(const HandleSeq&,
161 
162  RemoveLink(Link &l);
163 
164  // Return a pointer to the atom being specified.
165  virtual Handle execute(AtomSpace* = NULL) const;
166 };
167 
168 typedef std::shared_ptr<RemoveLink> RemoveLinkPtr;
169 static inline RemoveLinkPtr RemoveLinkCast(const Handle& h)
170  { AtomPtr a(h); return std::dynamic_pointer_cast<RemoveLink>(a); }
172  { return std::dynamic_pointer_cast<RemoveLink>(a); }
173 
174 // XXX temporary hack ...
175 #define createRemoveLink std::make_shared<RemoveLink>
176 
178 }
179 
180 #endif // _OPENCOG_ASSIGN_LINK_H
static AssignLinkPtr AssignLinkCast(const Handle &h)
Definition: AssignLink.h:121
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
std::shared_ptr< Atom > AtomPtr
Definition: Handle.h:48
std::shared_ptr< TruthValue > TruthValuePtr
Definition: TruthValue.h:85
std::shared_ptr< AttentionValue > AttentionValuePtr
std::shared_ptr< AssignLink > AssignLinkPtr
Definition: AssignLink.h:120
static RemoveLinkPtr RemoveLinkCast(const Handle &h)
Definition: AssignLink.h:169
static InsertLinkPtr InsertLinkCast(const Handle &h)
Definition: AssignLink.h:145
static TruthValuePtr DEFAULT_TV()
Definition: TruthValue.cc:52
static AttentionValuePtr DEFAULT_AV()
to be used as default attention value
std::shared_ptr< InsertLink > InsertLinkPtr
Definition: AssignLink.h:144
unsigned short Type
type of Atoms, represented as short integer (16 bits)
Definition: types.h:40
std::shared_ptr< RemoveLink > RemoveLinkPtr
Definition: AssignLink.h:168