OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PersistSCM.cc
Go to the documentation of this file.
1 /*
2  * opencog/persist/guile/PersistSCM.cc
3  *
4  * Copyright (c) 2008 by OpenCog Foundation
5  * Copyright (c) 2008, 2009, 2013, 2015 Linas Vepstas <linasvepstas@gmail.com>
6  * All Rights Reserved
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Affero General Public License v3 as
10  * published by the Free Software Foundation and including the exceptions
11  * at http://opencog.org/wiki/Licenses
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with this program; if not, write to:
20  * Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
26 
27 #include "PersistSCM.h"
28 
29 using namespace opencog;
30 
32 {
33  static bool is_init = false;
34  if (is_init) return;
35  is_init = true;
36  scm_with_guile(init_in_guile, this);
37 }
38 
39 void* PersistSCM::init_in_guile(void* self)
40 {
41  scm_c_define_module("opencog persist", init_in_module, self);
42  scm_c_use_module("opencog persist");
43  return NULL;
44 }
45 
47 {
48  PersistSCM* self = (PersistSCM*) data;
49  self->init();
50 }
51 
52 void PersistSCM::init(void)
53 {
54  define_scheme_primitive("fetch-atom",
55  &PersistSCM::fetch_atom, this, "persist");
56  define_scheme_primitive("fetch-incoming-set",
57  &PersistSCM::fetch_incoming_set, this, "persist");
58  define_scheme_primitive("store-atom",
59  &PersistSCM::store_atom, this, "persist");
60  define_scheme_primitive("load-atoms-of-type",
61  &PersistSCM::load_type, this, "persist");
62  define_scheme_primitive("barrier",
63  &PersistSCM::barrier, this, "persist");
64 }
65 
66 // =====================================================================
67 
69 {
70  AtomSpace *as = SchemeSmob::ss_get_env_as("fetch-atom");
71  h = as->fetch_atom(h);
72  return h;
73 }
74 
76 {
77  // The "false" flag here means that the fetch is NOT recursive.
78  AtomSpace *as = SchemeSmob::ss_get_env_as("fetch-incoming-set");
79  h = as->fetch_incoming_set(h, false);
80  return h;
81 }
82 
88 {
89  AtomSpace *as = SchemeSmob::ss_get_env_as("store-atom");
90  as->store_atom(h);
91  return h;
92 }
93 
95 {
96  AtomSpace *as = SchemeSmob::ss_get_env_as("load-atoms-of-type");
98 }
99 
101 {
102  AtomSpace *as = SchemeSmob::ss_get_env_as("barrier");
103  as->barrier();
104 }
105 
107 {
108  static PersistSCM patty;
109 }
void barrier(void)
Definition: PersistSCM.cc:100
static void init_in_module(void *)
Definition: PersistSCM.cc:46
void fetch_all_atoms_of_type(Type t)
Definition: AtomSpace.h:219
void opencog_persist_init(void)
Definition: PersistSCM.cc:106
Handle fetch_atom(Handle)
Definition: PersistSCM.cc:68
Handle store_atom(Handle)
Definition: PersistSCM.cc:87
void barrier(void)
Definition: AtomSpace.h:186
unsigned short Type
type of Atoms, represented as short integer (16 bits)
Definition: types.h:40
void store_atom(Handle h)
Definition: AtomSpace.cc:245
static void * init_in_guile(void *)
Definition: PersistSCM.cc:39
Handle fetch_atom(Handle h)
Definition: AtomSpace.cc:253
static AtomSpace * ss_get_env_as(const char *)
void load_type(Type)
Definition: PersistSCM.cc:94
Handle fetch_incoming_set(Handle, bool)
Definition: AtomSpace.cc:321
Handle fetch_incoming_set(Handle)
Definition: PersistSCM.cc:75