| 225 | } |
| 226 | |
| 227 | XnStatus xnConfigureProperty(XnNodeHandle hNode, const TiXmlElement* pOpcode) |
| 228 | { |
| 229 | XnStatus nRetVal = XN_STATUS_OK; |
| 230 | |
| 231 | const XnChar* strName; |
| 232 | nRetVal = xnXmlReadStringAttribute(pOpcode, "name", &strName); |
| 233 | XN_IS_STATUS_OK(nRetVal); |
| 234 | |
| 235 | const XnChar* strType; |
| 236 | nRetVal = xnXmlReadStringAttribute(pOpcode, "type", &strType); |
| 237 | XN_IS_STATUS_OK(nRetVal); |
| 238 | |
| 239 | if (strcmp(strType, "int") == 0) |
| 240 | { |
| 241 | XnInt nValue; |
| 242 | nRetVal = xnXmlReadIntAttribute(pOpcode, "value", &nValue); |
| 243 | XN_IS_STATUS_OK(nRetVal); |
| 244 | |
| 245 | nRetVal = xnSetIntProperty(hNode, strName, nValue); |
| 246 | if (nRetVal != XN_STATUS_OK) |
| 247 | { |
| 248 | xnLogError(XN_MASK_OPEN_NI, "Failed to set property '%s' from xml: %s", strName, xnGetStatusString(nRetVal)); |
| 249 | return nRetVal; |
| 250 | } |
| 251 | } |
| 252 | else if (strcmp(strType, "real") == 0) |
| 253 | { |
| 254 | XnDouble dValue; |
| 255 | nRetVal = xnXmlReadRealAttribute(pOpcode, "value", &dValue); |
| 256 | XN_IS_STATUS_OK(nRetVal); |
| 257 | |
| 258 | nRetVal = xnSetRealProperty(hNode, strName, dValue); |
| 259 | if (nRetVal != XN_STATUS_OK) |
| 260 | { |
| 261 | xnLogError(XN_MASK_OPEN_NI, "Failed to set property '%s' from xml: %s", strName, xnGetStatusString(nRetVal)); |
| 262 | return nRetVal; |
| 263 | } |
| 264 | } |
| 265 | else if (strcmp(strType, "string") == 0) |
| 266 | { |
| 267 | const XnChar* strValue; |
| 268 | nRetVal = xnXmlReadStringAttribute(pOpcode, "value", &strValue); |
| 269 | XN_IS_STATUS_OK(nRetVal); |
| 270 | |
| 271 | nRetVal = xnSetStringProperty(hNode, strName, strValue); |
| 272 | if (nRetVal != XN_STATUS_OK) |
| 273 | { |
| 274 | xnLogError(XN_MASK_OPEN_NI, "Failed to set property '%s' from xml: %s", strName, xnGetStatusString(nRetVal)); |
| 275 | return nRetVal; |
| 276 | } |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Invalid property type: %s", strType); |
| 281 | } |
| 282 | |
| 283 | return (XN_STATUS_OK); |
| 284 | } |
no test coverage detected