XnStatus XnActualPropertiesHash::CopyFrom(const XnActualPropertiesHash& other) { XnStatus nRetVal = XN_STATUS_OK; Clear(); strncpy(m_strName, other.m_strName, XN_DEVICE_MAX_STRING_LENGTH); for (ConstIterator it = other.begin(); it != other.end(); ++it) { switch (it.Value()->GetType()) { case XN_PROPERTY_TYPE_INTEGER: { XnActualIntProperty* pProp = (XnActualIntProperty*)it.Value(); nRetVal = Add(pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_REAL: { XnActualRealProperty* pProp = (XnActualRealProperty*)it.Value(); nRetVal = Add(pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_STRING: { XnActualStringProperty* pProp = (XnActualStringProperty*)it.Value(); nRetVal = Add(pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } case XN_PROPERTY_TYPE_GENERAL: { XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)it.Value(); nRetVal = Add(pProp->GetName(), pProp->GetValue()); XN_IS_STATUS_OK(nRetVal); break; } default: XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d\n", it.Value()->GetType()); } } return (XN_STATUS_OK); }
XnStatus XnSensorProductionNode::NotifyExState(XnNodeNotifications* pNotifications, void* pCookie) { XnStatus nRetVal = XN_STATUS_OK; // get all properties XN_PROPERTY_SET_CREATE_ON_STACK(props); nRetVal = m_pSensor->GetAllProperties(&props, FALSE, GetModuleName()); XN_IS_STATUS_OK(nRetVal); XnActualPropertiesHash* pPropsHash = props.pData->begin().Value(); // filter properties (remove the ones already exposed as OpenNI interfaces) FilterProperties(pPropsHash); const XnChar* astrIntProps[200] = {0}; const XnChar* astrRealProps[200] = {0}; const XnChar* astrStringProps[200] = {0}; const XnChar* astrGeneralProps[200] = {0}; XnUInt32 nIntProps = 0; XnUInt32 nRealProps = 0; XnUInt32 nStringProps = 0; XnUInt32 nGeneralProps = 0; // enumerate over properties for (XnActualPropertiesHash::Iterator it = pPropsHash->begin(); it != pPropsHash->end(); ++it) { XnProperty* pProp = it.Value(); switch (pProp->GetType()) { case XN_PROPERTY_TYPE_INTEGER: { XnActualIntProperty* pIntProp = (XnActualIntProperty*)pProp; pNotifications->OnNodeIntPropChanged(pCookie, GetInstanceName(), pProp->GetName(), pIntProp->GetValue()); astrIntProps[nIntProps++] = pProp->GetName(); } break; case XN_PROPERTY_TYPE_REAL: { XnActualRealProperty* pRealProp = (XnActualRealProperty*)pProp; pNotifications->OnNodeRealPropChanged(pCookie, GetInstanceName(), pProp->GetName(), pRealProp->GetValue()); astrRealProps[nRealProps++] = pProp->GetName(); } break; case XN_PROPERTY_TYPE_STRING: { XnActualStringProperty* pStrProp = (XnActualStringProperty*)pProp; pNotifications->OnNodeStringPropChanged(pCookie, GetInstanceName(), pProp->GetName(), pStrProp->GetValue()); astrStringProps[nStringProps++] = pProp->GetName(); } break; case XN_PROPERTY_TYPE_GENERAL: { XnActualGeneralProperty* pGenProp = (XnActualGeneralProperty*)pProp; pNotifications->OnNodeGeneralPropChanged(pCookie, GetInstanceName(), pProp->GetName(), pGenProp->GetValue().nDataSize, pGenProp->GetValue().pData); astrGeneralProps[nGeneralProps++] = pProp->GetName(); } break; default: XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DEVICE_SENSOR, "Unknown property type: %d", pProp->GetType()); } } // TODO: also register to these properties, and if changed, notify. // store notifications object m_pNotifications = pNotifications; m_pCookie = pCookie; return (XN_STATUS_OK); }