* @brief Creates a connection to the Soar kernel that is embedded * within the same process as the caller. * (This method is protected - clients should use the two methods above that are more explicitly named). * * @param ClientThread If true, Soar will run in the client's thread and the client must periodically call over to the * kernel to check for incoming
| 747 | * If an error occurs a Kernel object is still returned. Call "HadError()" and "GetLastErrorDescription()" on it. |
| 748 | *************************************************************/ |
| 749 | Kernel* Kernel::CreateEmbeddedConnection(bool clientThread, bool optimized, int portToListenOn) |
| 750 | { |
| 751 | ErrorCode errorCode = 0 ; |
| 752 | |
| 753 | /* -- Create Soar_Instance and Output_Manager singletons -- */ |
| 754 | Soar_Instance* lSoarInstance = instantiate_singletons(); |
| 755 | Connection* pConnection = Connection::CreateEmbeddedConnection(clientThread, optimized, portToListenOn, &errorCode) ; |
| 756 | |
| 757 | // Even if pConnection is NULL, we still build a kernel object, so we have |
| 758 | // a clean way to pass the error code back to the caller. |
| 759 | Kernel* pKernel = new Kernel(pConnection) ; |
| 760 | |
| 761 | // Transfer any errors over to the kernel object, so the caller can retrieve them. |
| 762 | pKernel->SetError(errorCode) ; |
| 763 | |
| 764 | // Register for "calls" from the kernel. |
| 765 | if (pConnection) |
| 766 | { |
| 767 | lSoarInstance->init_Soar_Instance(pKernel); |
| 768 | |
| 769 | pConnection->RegisterCallback(ReceivedCall, pKernel, sml_Names::kDocType_Call, true) ; |
| 770 | |
| 771 | pKernel->InitializeTimeTagCounter() ; |
| 772 | |
| 773 | pKernel->InitEvents() ; |
| 774 | } |
| 775 | |
| 776 | return pKernel ; |
| 777 | } |
| 778 | |
| 779 | int Kernel::GetListenerPort() |
| 780 | { |
nothing calls this directly
no test coverage detected