OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SchemeSmobAF.cc
Go to the documentation of this file.
1 /*
2  * opencog/guile/SchemeSmobAF.cc
3  *
4  * Scheme small objects (SMOBS) for AttentionalFocus and AttentionalFocusBoundary.
5  *
6  * Copyright (C) 2014 Cosmo Harrigan
7  * All Rights Reserved
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License v3 as
11  * published by the Free Software Foundation and including the exceptions
12  * at http://opencog.org/wiki/Licenses
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program; if not, write to:
21  * Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 #ifdef HAVE_GUILE
26 
27 #include <cstddef>
28 #include <libguile.h>
29 
31 
32 using namespace opencog;
33 
39 {
40  AtomSpace* atomspace = ss_get_env_as("cog-af-boundary");
41  return scm_from_short(atomspace->get_attentional_focus_boundary());
42 }
43 
47 SCM SchemeSmob::ss_set_af_boundary (SCM sboundary)
48 {
49  AtomSpace* atomspace = ss_get_env_as("cog-set-af-boundary!");
50  if (scm_is_false(scm_integer_p(sboundary)))
51  scm_wrong_type_arg_msg("cog-set-af-boundary", 1, sboundary,
52  "integer opencog AttentionalFocus Boundary");
53 
54  short bdy = scm_to_short(sboundary);
55  return scm_from_short(atomspace->set_attentional_focus_boundary(bdy));
56 }
57 
62 {
63  AtomSpace* atomspace = ss_get_env_as("cog-af");
64 
65  HandleSeq attentionalFocus;
66  atomspace->get_handle_set_in_attentional_focus(back_inserter(attentionalFocus));
67  size_t isz = attentionalFocus.size();
68  if (0 == isz) return SCM_EOL;
69 
70  SCM head = SCM_EOL;
71  for (size_t i = 0; i < isz; i++) {
72  Handle hi = attentionalFocus[i];
73  SCM smob = handle_to_scm(hi);
74  head = scm_cons(smob, head);
75  }
76 
77  return head;
78 }
79 
80 #endif /* HAVE_GUILE */
static SCM ss_set_af_boundary(SCM)
Definition: SchemeSmobAF.cc:47
static SCM ss_af_boundary(void)
Definition: SchemeSmobAF.cc:38
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
AttentionValue::sti_t set_attentional_focus_boundary(AttentionValue::sti_t s)
Definition: AtomSpace.h:548
AttentionValue::sti_t get_attentional_focus_boundary() const
Definition: AtomSpace.h:538
static SCM ss_af(void)
Definition: SchemeSmobAF.cc:61
static SCM handle_to_scm(Handle)
OutputIterator get_handle_set_in_attentional_focus(OutputIterator result) const
Definition: AtomSpace.h:526
static AtomSpace * ss_get_env_as(const char *)