OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DefaultPatternMatchCB.h
Go to the documentation of this file.
1 /*
2  * DefaultPatternMatchCB.h
3  *
4  * Copyright (C) 2009, 2014, 2015 Linas Vepstas <linasvepstas@gmail.com>
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  * Created by Linas Vepstas January 2009
23  */
24 
25 #ifndef _OPENCOG_DEFAULT_PATTERN_MATCH_H
26 #define _OPENCOG_DEFAULT_PATTERN_MATCH_H
27 
33 
34 namespace opencog {
35 
55 {
56  public:
58  virtual void set_pattern(const Variables&, const Pattern&);
59 
60  virtual bool node_match(const Handle&, const Handle&);
61  virtual bool variable_match(const Handle&, const Handle&);
62  virtual bool link_match(const LinkPtr&, const LinkPtr&);
63  virtual bool post_link_match(const LinkPtr&, const LinkPtr&);
64 
65  virtual bool clause_match(const Handle&, const Handle&);
69  virtual bool optional_clause_match(const Handle& pattrn,
70  const Handle& grnd);
71 
76  virtual bool evaluate_sentence(const Handle& pat,
77  const std::map<Handle,Handle>& gnds)
78  { return eval_sentence(pat, gnds); }
79 
80  virtual const std::set<Type>& get_connectives(void)
81  {
82  return _connectives;
83  }
84 
85  bool optionals_present(void) { return _optionals_present; }
86  protected:
87 
89 
91  const std::set<Handle>* _dynamic = NULL;
92  bool _have_evaluatables = false;
93 
94  // Temp atomspace used for test-groundings of virtual links.
97 
98  // Crisp-logic evaluation of evaluatable terms
99  std::set<Type> _connectives;
100  bool eval_term(const Handle& pat,
101  const std::map<Handle,Handle>& gnds);
102  bool eval_sentence(const Handle& pat,
103  const std::map<Handle,Handle>& gnds);
104 
105  bool _optionals_present = false;
107 };
108 
109 } // namespace opencog
110 
111 #endif // _OPENCOG_DEFAULT_PATTERN_MATCH_H
virtual void set_pattern(const Variables &, const Pattern &)
virtual bool evaluate_sentence(const Handle &pat, const std::map< Handle, Handle > &gnds)
virtual bool variable_match(const Handle &, const Handle &)
std::map< Handle, const std::set< Type > > VariableTypeMap
Definition: Pattern.h:43
std::shared_ptr< Link > LinkPtr
Definition: Atom.h:53
virtual bool post_link_match(const LinkPtr &, const LinkPtr &)
virtual bool link_match(const LinkPtr &, const LinkPtr &)
bool eval_term(const Handle &pat, const std::map< Handle, Handle > &gnds)
virtual bool clause_match(const Handle &, const Handle &)
const std::set< Handle > * _dynamic
const VariableTypeMap * _type_restrictions
virtual const std::set< Type > & get_connectives(void)
virtual bool node_match(const Handle &, const Handle &)
bool eval_sentence(const Handle &pat, const std::map< Handle, Handle > &gnds)
virtual bool optional_clause_match(const Handle &pattrn, const Handle &grnd)