XN_DDK_API XnStatus XnPropertySetRemoveModule(XnPropertySet* pSet, const XnChar* strModuleName) { XnStatus nRetVal = XN_STATUS_OK; XN_VALIDATE_INPUT_PTR(pSet); XN_VALIDATE_INPUT_PTR(strModuleName); XnActualPropertiesHash* pModule = NULL; nRetVal = XnPropertySetDataDetachModule(pSet->pData, strModuleName, &pModule); XN_IS_STATUS_OK(nRetVal); // now free its memory XN_DELETE(pModule); return (XN_STATUS_OK); }
XnStatus XnDeviceFileReader::ReadInitialState(XnPropertySet *pSet) { XnStatus nRetVal = XN_STATUS_OK; if (m_nFileVersion < 4) { if (m_pBCData == NULL) { nRetVal = BCInit(); XN_IS_STATUS_OK(nRetVal); } return BCReadInitialState(pSet); } // first read first object - modules properties - using base nRetVal = XnStreamReaderDevice::ReadInitialState(pSet); XN_IS_STATUS_OK(nRetVal); // now continue reading until we get to first data XnPackedDataType nType; XnBool bStateEnd = FALSE; XnUInt64 nPositionBefore; while (!bStateEnd) { nRetVal = GetIOStream()->Tell(&nPositionBefore); XN_IS_STATUS_OK(nRetVal); nRetVal = GetDataPacker()->ReadNextObject(&nType); XN_IS_STATUS_OK(nRetVal); switch (nType) { case XN_PACKED_NEW_STREAM: { XnChar strType[XN_DEVICE_MAX_STRING_LENGTH]; XnChar strName[XN_DEVICE_MAX_STRING_LENGTH]; XN_PROPERTY_SET_CREATE_ON_STACK(props); nRetVal = GetDataPacker()->ReadNewStream(strType, strName, &props); XN_IS_STATUS_OK(nRetVal); XnActualPropertiesHash* pStreamProps; nRetVal = XnPropertySetDataDetachModule(props.pData, strName, &pStreamProps); XN_IS_STATUS_OK(nRetVal); nRetVal = XnPropertySetDataAttachModule(pSet->pData, strName, pStreamProps); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_INT_PROPERTY: { XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; XnUInt64 nValue; nRetVal = GetDataPacker()->ReadProperty(strModule, strProp, &nValue); XN_IS_STATUS_OK(nRetVal); XnActualPropertiesHash* pModule = NULL; nRetVal = pSet->pData->Get(strModule, pModule); XN_IS_STATUS_OK(nRetVal); XnProperty* pProp = NULL; nRetVal = pModule->Get(strProp, pProp); XN_IS_STATUS_OK(nRetVal); XnActualIntProperty* pIntProp = (XnActualIntProperty*)pProp; nRetVal = pIntProp->UnsafeUpdateValue(nValue); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_REAL_PROPERTY: { XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; XnDouble dValue; nRetVal = GetDataPacker()->ReadProperty(strModule, strProp, &dValue); XN_IS_STATUS_OK(nRetVal); XnActualPropertiesHash* pModule; nRetVal = pSet->pData->Get(strModule, pModule); XN_IS_STATUS_OK(nRetVal); XnProperty* pProp; nRetVal = pModule->Get(strProp, pProp); XN_IS_STATUS_OK(nRetVal); XnActualRealProperty* pRealProp = (XnActualRealProperty*)pProp; nRetVal = pRealProp->UnsafeUpdateValue(dValue); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_STRING_PROPERTY: { XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; nRetVal = GetDataPacker()->ReadProperty(strModule, strProp, strValue); XN_IS_STATUS_OK(nRetVal); XnActualPropertiesHash* pModule; nRetVal = pSet->pData->Get(strModule, pModule); XN_IS_STATUS_OK(nRetVal); XnProperty* pProp; nRetVal = pModule->Get(strProp, pProp); XN_IS_STATUS_OK(nRetVal); XnActualStringProperty* pStringProp = (XnActualStringProperty*)pProp; nRetVal = pStringProp->UnsafeUpdateValue(strValue); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_GENERAL_PROPERTY: { XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH]; XnChar strProp[XN_DEVICE_MAX_STRING_LENGTH]; XnGeneralBuffer gbValue; nRetVal = GetDataPacker()->ReadProperty(strModule, strProp, &gbValue); XN_IS_STATUS_OK(nRetVal); XnActualPropertiesHash* pModule; nRetVal = pSet->pData->Get(strModule, pModule); XN_IS_STATUS_OK(nRetVal); XnProperty* pProp; nRetVal = pModule->Get(strProp, pProp); XN_IS_STATUS_OK(nRetVal); XnActualGeneralProperty* pIntProp = (XnActualGeneralProperty*)pProp; nRetVal = pIntProp->UnsafeUpdateValue(gbValue); XN_IS_STATUS_OK(nRetVal); break; } default: // reached end of initial state. go back to beginning of this object nRetVal = GetIOStream()->Seek(nPositionBefore); XN_IS_STATUS_OK(nRetVal); // stop reading bStateEnd = TRUE; } } // objects loop return (XN_STATUS_OK); }