| 2101 | ////////////////////////////////////////////////////////// |
| 2102 | |
| 2103 | void smem_install_memory(agent* thisAgent, Symbol* state, smem_lti_id lti_id, Symbol* lti, bool activate_lti, soar_module::symbol_triple_list& meta_wmes, soar_module::symbol_triple_list& retrieval_wmes, smem_install_type install_type = wm_install, uint64_t depth = 1, std::set<smem_lti_id>* visited = NULL) |
| 2104 | { |
| 2105 | //////////////////////////////////////////////////////////////////////////// |
| 2106 | thisAgent->smem_timers->ncb_retrieval->start(); |
| 2107 | //////////////////////////////////////////////////////////////////////////// |
| 2108 | |
| 2109 | // get the ^result header for this state |
| 2110 | Symbol* result_header = NULL; |
| 2111 | if (install_type == wm_install) |
| 2112 | { |
| 2113 | result_header = state->id->smem_result_header; |
| 2114 | } |
| 2115 | |
| 2116 | // get identifier if not known |
| 2117 | bool lti_created_here = false; |
| 2118 | if (lti == NIL && install_type == wm_install) |
| 2119 | { |
| 2120 | soar_module::sqlite_statement* q = thisAgent->smem_stmts->lti_letter_num; |
| 2121 | |
| 2122 | q->bind_int(1, lti_id); |
| 2123 | q->execute(); |
| 2124 | |
| 2125 | lti = smem_lti_soar_make(thisAgent, lti_id, static_cast<char>(q->column_int(0)), static_cast<uint64_t>(q->column_int(1)), result_header->id->level); |
| 2126 | |
| 2127 | q->reinitialize(); |
| 2128 | |
| 2129 | lti_created_here = true; |
| 2130 | } |
| 2131 | |
| 2132 | // activate lti |
| 2133 | if (activate_lti) |
| 2134 | { |
| 2135 | smem_lti_activate(thisAgent, lti_id, true); |
| 2136 | } |
| 2137 | |
| 2138 | // point retrieved to lti |
| 2139 | if (install_type == wm_install) |
| 2140 | { |
| 2141 | smem_buffer_add_wme(thisAgent, meta_wmes, result_header, thisAgent->smem_sym_retrieved, lti); |
| 2142 | } |
| 2143 | if (lti_created_here) |
| 2144 | { |
| 2145 | // if the identifier was created above we need to |
| 2146 | // remove a single ref count AFTER the wme |
| 2147 | // is added (such as to not deallocate the symbol |
| 2148 | // prematurely) |
| 2149 | symbol_remove_ref(thisAgent, lti); |
| 2150 | } |
| 2151 | |
| 2152 | bool triggered = false; |
| 2153 | |
| 2154 | // if no children, then retrieve children |
| 2155 | // merge may override this behavior |
| 2156 | if (((thisAgent->smem_params->merge->get_value() == smem_param_container::merge_add) || |
| 2157 | ((lti->id->impasse_wmes == NIL) && |
| 2158 | (lti->id->input_wmes == NIL) && |
| 2159 | (lti->id->slots == NIL))) |
| 2160 | || (install_type == fake_install)) //(The final bit is if this is being called by the remove command.) |
no test coverage detected