Create a new WME of the appropriate type based on this information.
| 163 | |
| 164 | // Create a new WME of the appropriate type based on this information. |
| 165 | WMElement* 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 | |
| 208 | void WorkingMemory::RecordAddition(WMElement* pWME) |
| 209 | { |
nothing calls this directly
no test coverage detected