OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FreeLink.h
Go to the documentation of this file.
1 /*
2  * opencog/atoms/core/FreeLink.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_FREE_LINK_H
24 #define _OPENCOG_FREE_LINK_H
25 
27 #include <opencog/atomspace/Link.h>
28 
29 namespace opencog
30 {
59 class FreeLink : public Link
60 {
61 protected:
63  std::map<Handle, unsigned int> _index;
64 
65  void init(void);
66  void find_vars(std::set<Handle>&, const HandleSeq&);
67  void build_index(void);
68 
69  FreeLink(Type, const HandleSeq& oset,
72 
73  FreeLink(Type, const Handle& a,
76 
77  FreeLink(Type, const Handle& a, const Handle& b,
80 public:
81  FreeLink(const HandleSeq& oset,
84  FreeLink(const Handle& a,
87 
88  FreeLink(Link& l);
89  virtual ~FreeLink() {}
90 
91  const HandleSeq& get_vars(void) { return _varseq; }
92 
93  virtual Handle reduce(void);
94 };
95 
96 typedef std::shared_ptr<FreeLink> FreeLinkPtr;
97 static inline FreeLinkPtr FreeLinkCast(const Handle& h)
98  { AtomPtr a(h); return std::dynamic_pointer_cast<FreeLink>(a); }
100  { return std::dynamic_pointer_cast<FreeLink>(a); }
101 
102 // XXX temporary hack ...
103 #define createFreeLink std::make_shared<FreeLink>
104 
106 }
107 
108 #endif // _OPENCOG_FREE_LINK_H
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
static FreeLinkPtr FreeLinkCast(const Handle &h)
Definition: FreeLink.h:97
static TruthValuePtr NULL_TV()
Definition: TruthValue.cc:46
std::shared_ptr< FreeLink > FreeLinkPtr
Definition: FreeLink.h:96
static AttentionValuePtr DEFAULT_AV()
to be used as default attention value
unsigned short Type
type of Atoms, represented as short integer (16 bits)
Definition: types.h:40