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

Method UpdateString

Core/ClientSML/src/sml_ClientWorkingMemory.cpp:947–997  ·  view source on GitHub ↗

* @brief Update the value of an existing WME. * The value is not actually sent to the kernel * until "Commit" is called. *************************************************************/

Source from the content-addressed store, hash-verified

945* until "Commit" is called.
946*************************************************************/
947void WorkingMemory::UpdateString(StringElement* pWME, char const* pValue)
948{
949 if (!pWME || !pValue)
950 {
951 return ;
952 }
953
954 assert(m_Agent == pWME->GetAgent()) ;
955
956 // If the value hasn't changed and we're set to not blink the wme (remove/add it again)
957 // then there's no work to do.
958 if (!m_Agent->IsBlinkIfNoChange())
959 {
960 if (strcmp(pWME->GetValue(), pValue) == 0)
961 {
962 return ;
963 }
964 }
965
966 // Changing the value logically is a remove and then an add
967
968 // Get the tag of the value to remove
969 long long removeTimeTag = pWME->GetTimeTag() ;
970
971 // Change the value and the time tag (this is equivalent to us deleting the old object
972 // and then creating a new one).
973 pWME->SetValue(pValue) ;
974 pWME->GenerateNewTimeTag() ;
975
976#ifdef SML_DIRECT
977 if (GetConnection()->IsDirectConnection())
978 {
979 EmbeddedConnection* pConnection = static_cast<EmbeddedConnection*>(GetConnection());
980 pConnection->DirectRemoveWME(m_AgentSMLHandle, removeTimeTag);
981
982 pConnection->DirectAddWME_String(m_AgentSMLHandle, pWME->GetIdentifierName(), pWME->GetAttribute(), pValue, pWME->GetTimeTag());
983
984 // Return immediately, without adding it to the commit list.
985 return ;
986 }
987#endif
988
989 // Add it to the list of changes that need to be sent to Soar.
990 m_DeltaList.UpdateWME(removeTimeTag, pWME) ;
991
992 // Commit immediately if we're configured that way (makes life simpler for the client)
993 if (IsAutoCommitEnabled())
994 {
995 Commit() ;
996 }
997}
998
999void WorkingMemory::UpdateInt(IntElement* pWME, long long value)
1000{

Callers 2

UpdateMethod · 0.80
UpdateMethod · 0.80

Calls 9

GenerateNewTimeTagMethod · 0.80
DirectRemoveWMEMethod · 0.80
DirectAddWME_StringMethod · 0.80
GetConnectionFunction · 0.70
IsAutoCommitEnabledFunction · 0.70
GetAgentMethod · 0.45
SetValueMethod · 0.45
IsDirectConnectionMethod · 0.45
GetAttributeMethod · 0.45

Tested by

no test coverage detected