MCPcopy Create free account
hub / github.com/SoarGroup/Soar / CreateEmbeddedConnection

Method CreateEmbeddedConnection

Core/ClientSML/src/sml_ClientKernel.cpp:749–777  ·  view source on GitHub ↗

* @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

Source from the content-addressed store, hash-verified

747* If an error occurs a Kernel object is still returned. Call "HadError()" and "GetLastErrorDescription()" on it.
748*************************************************************/
749Kernel* 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
779int Kernel::GetListenerPort()
780{

Callers

nothing calls this directly

Calls 6

instantiate_singletonsFunction · 0.85
init_Soar_InstanceMethod · 0.80
RegisterCallbackMethod · 0.80
InitEventsMethod · 0.80
SetErrorMethod · 0.45

Tested by

no test coverage detected