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

Method CreateWME

Core/ClientSML/src/sml_ClientWorkingMemory.cpp:165–206  ·  view source on GitHub ↗

Create a new WME of the appropriate type based on this information.

Source from the content-addressed store, hash-verified

163
164// Create a new WME of the appropriate type based on this information.
165WMElement* WorkingMemory::CreateWME(IdentifierSymbol* pParentSymbol, char const* pID, char const* pAttribute, char const* pValue, char const* pType, long long timeTag)
166{
167 // Value is an identifier
168 if (strcmp(pType, sml_Names::kTypeID) == 0)
169 {
170 IdentifierSymbol* pSharedIdentifierSymbol = this->FindIdentifierSymbol(pValue);
171 Identifier* pNewIdentifier = 0;
172 if (pSharedIdentifierSymbol != NULL)
173 {
174 pNewIdentifier = new Identifier(GetAgent(), pParentSymbol, pID, pAttribute, pSharedIdentifierSymbol, timeTag);
175 }
176 else
177 {
178 pNewIdentifier = new Identifier(GetAgent(), pParentSymbol, pID, pAttribute, pValue, timeTag) ;
179 }
180 return pNewIdentifier;
181 }
182
183 // Value is a string
184 if (strcmp(pType, sml_Names::kTypeString) == 0)
185 {
186 return new StringElement(GetAgent(), pParentSymbol, pID, pAttribute, pValue, timeTag) ;
187 }
188
189 // Value is an int
190 if (strcmp(pType, sml_Names::kTypeInt) == 0)
191 {
192 int64_t value = 0;
193 from_c_string(value, pValue);
194 return new IntElement(GetAgent(), pParentSymbol, pID, pAttribute, value, timeTag) ;
195 }
196
197 // Value is a float
198 if (strcmp(pType, sml_Names::kTypeDouble) == 0)
199 {
200 double value = 0;
201 from_c_string(value, pValue);
202 return new FloatElement(GetAgent(), pParentSymbol, pID, pAttribute, value, timeTag) ;
203 }
204
205 return NULL ;
206}
207
208void WorkingMemory::RecordAddition(WMElement* pWME)
209{

Callers

nothing calls this directly

Calls 3

FindIdentifierSymbolMethod · 0.95
GetAgentFunction · 0.70
from_c_stringFunction · 0.50

Tested by

no test coverage detected