10 #ifdef HAVE_LIBMEMCACHED
17 #include <opencog/memcache/AtomCache.h>
19 using namespace opencog;
26 fprintf(stderr,
"Error: No atom found\n");
32 fprintf(stderr,
"Error, type mis-match, a=%d b=%d\n", a->
getType(), b->
getType());
35 if (a->getArity() != b->getArity())
37 fprintf(stderr,
"Error, arity mis-match, a=%d b=%d\n", a->getArity(), b->getArity());
40 if (0 < a->getArity())
42 std::vector<Handle> outa = a->getOutgoingSet();
43 std::vector<Handle> outb = b->getOutgoingSet();
44 for (
int i =0; i< a->getArity(); i++)
46 if (outa[i] != outb[i])
48 fprintf(stderr,
"Error, outgoing set mis-match, "
49 "i=%d a=%lx b=%lx\n", i, outa[i], outb[i]);
58 fprintf(stderr,
"Error, truth value miscompare, "
59 "ma=%f mb=%f ca=%f cb=%f\n",
71 void single_atom_test(std::string
id)
73 AtomCache *store =
new AtomCache(
"localhost", 21201);
76 Atom *a =
new Node(SCHEMA_NODE,
id +
"someNode");
86 Atom *b = store->getAtom(h);
92 printf(
"atom compare success\n");
97 Atom *a2 =
new Node(SCHEMA_NODE,
id +
"otherNode");
101 std::vector<Handle> hvec;
113 printf(
"link compare success\n");
119 void add_to_table(
AtomTable *table, std::string
id)
122 Atom *a =
new Node(SCHEMA_NODE,
id +
"fromNode");
127 Atom *a2 =
new Node(SCHEMA_NODE,
id +
"toNode");
132 Atom *a3 =
new Node(SCHEMA_NODE,
id +
"third wheel");
137 std::vector<Handle> hvec;
150 single_atom_test(
"aaa ");
151 single_atom_test(
"bbb ");
152 single_atom_test(
"ccc ");
153 single_atom_test(
"ddd ");
154 single_atom_test(
"eee ");
163 printf(
"Printing table:\n");
170 AtomCache *store =
new AtomCache(
"localhost", 21201);
173 add_to_table(table,
"aaa ");
174 add_to_table(table,
"bbb ");
175 add_to_table(table,
"ccc ");
176 add_to_table(table,
"ddd ");
177 add_to_table(table,
"eee ");
179 store->store(*table);
virtual count_t getCount() const =0
a TruthValue that stores a mean and the number of observations (strength and confidence) ...
Handle add(AtomPtr, bool async)
void setTruthValue(TruthValuePtr)
Sets the TruthValue object of the atom.
TruthValuePtr getTruthValue()
int atomCompare(Atom *a, Atom *b)
virtual strength_t getMean() const =0
static void addAtom(AtomPtr atom)