void connect_answer_to_question(sc_addr question, sc_addr answer) { sc_addr arc; arc = sc_memory_arc_new(sc_type_arc_common | sc_type_const, question, answer); SYSTEM_ELEMENT(arc); arc = sc_memory_arc_new(sc_type_arc_pos_const_perm, keynode_nrel_answer, arc); SYSTEM_ELEMENT(arc); }
void appendIntoAnswer(sc_addr answer, sc_addr el) { sc_addr arc; if (sc_helper_check_arc(answer, el, sc_type_arc_pos_const_perm) == SC_TRUE) return; arc = sc_memory_arc_new(sc_type_arc_pos_const_perm, answer, el); SYSTEM_ELEMENT(arc); }
void finish_question(sc_addr question) { sc_iterator3 *it = nullptr; sc_addr arc; it = sc_iterator3_f_a_f_new(keynode_question_initiated, sc_type_arc_pos_const_perm, question); while (sc_iterator3_next(it)) sc_memory_element_free(sc_iterator3_value(it, 1)); sc_iterator3_free(it); arc = sc_memory_arc_new(sc_type_arc_pos_const_perm, keynode_question_finished, question); SYSTEM_ELEMENT(arc); }
sc_result search_full_pattern(sc_addr pattern, sc_addr answer, sc_bool sys_off) { sc_type_result params; sc_addr addr2, arc; sc_type_result_vector result; sc_type_result::iterator it; sc_uint i; sc_result res = SC_RESULT_OK; GHashTable *table; if (SC_RESULT_OK != system_sys_search_only_full(pattern, params, &result)) { return SC_RESULT_ERROR; } if (result.size() > 0) { res = SC_RESULT_OK; } else { free_result_vector(&result); return SC_RESULT_ERROR; } table = g_hash_table_new(NULL, NULL); for (i = 0; i < result.size(); i++) { for (it = result[i]->begin() ; it != result[i]->end(); it++) { addr2 = (*it).second; if (FALSE == g_hash_table_contains(table, GINT_TO_POINTER(SC_ADDR_LOCAL_TO_INT(addr2)))) { g_hash_table_add(table, GINT_TO_POINTER(SC_ADDR_LOCAL_TO_INT(addr2))); if (sys_off == SC_TRUE && IS_SYSTEM_ELEMENT(addr2)) continue; arc = sc_memory_arc_new(s_default_ctx, sc_type_arc_pos_const_perm, answer, addr2); SYSTEM_ELEMENT(arc); } } } free_result_vector(&result); g_hash_table_destroy(table); return res; }
sc_addr create_answer_node() { sc_addr res = sc_memory_node_new(sc_type_const); SYSTEM_ELEMENT(res); return res; }