Esempio n. 1
0
XN_DDK_API XnStatus XnPropertySetCloneModule(const XnPropertySet* pSource, XnPropertySet* pDest, const XnChar* strModule, const XnChar* strNewName)
{
	XnStatus nRetVal = XN_STATUS_OK;

	XnActualPropertiesHash* pModuleProps = NULL;
	nRetVal = pSource->pData->Get(strModule, pModuleProps);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = XnPropertySetAddModule(pDest, strNewName);
	XN_IS_STATUS_OK(nRetVal);

	for (XnActualPropertiesHash::ConstIterator it = pModuleProps->Begin(); it != pModuleProps->End(); ++it)
	{
		XnProperty* pProp = it->Value();
		switch (pProp->GetType())
		{
		case XN_PROPERTY_TYPE_INTEGER:
			{
				XnActualIntProperty* pIntProp = (XnActualIntProperty*)pProp;
				nRetVal = XnPropertySetAddIntProperty(pDest, strNewName, pIntProp->GetName(), pIntProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_REAL:
			{
				XnActualRealProperty* pRealProp = (XnActualRealProperty*)pProp;
				nRetVal = XnPropertySetAddRealProperty(pDest, strNewName, pRealProp->GetName(), pRealProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_STRING:
			{
				XnActualStringProperty* pStrProp = (XnActualStringProperty*)pProp;
				nRetVal = XnPropertySetAddStringProperty(pDest, strNewName, pStrProp->GetName(), pStrProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		case XN_PROPERTY_TYPE_GENERAL:
			{
				XnActualGeneralProperty* pGenProp = (XnActualGeneralProperty*)pProp;
				nRetVal = XnPropertySetAddGeneralProperty(pDest, strNewName, pGenProp->GetName(), &pGenProp->GetValue());
				XN_IS_STATUS_OK(nRetVal);
				break;
			}
		default:
			XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d", pProp->GetType());
		}
	}

	return (XN_STATUS_OK);
}
Esempio n. 2
0
XnStatus XnDataPacker::ReadPropertySetImpl(XnPropertySet* pPropertySet)
{
    XnStatus nRetVal = XN_STATUS_OK;

    XN_VALIDATE_OBJECT_TYPE(XN_PACKED_PROPERTY_SET);

    XnChar strModule[XN_DEVICE_MAX_STRING_LENGTH];

    // read property set marker
    MoveToNextObject();

    while (m_pCurrentHeader->nType != XN_PACKED_PROPERTY_SET_MODULES_END_MARKER)
    {
        nRetVal = ReadString(strModule);
        XN_IS_STATUS_OK(nRetVal);

        nRetVal = XnPropertySetAddModule(pPropertySet, strModule);
        XN_IS_STATUS_OK(nRetVal);
    }

    // read properties
    XnChar strName[XN_DEVICE_MAX_STRING_LENGTH];

    // read the modules end marker
    MoveToNextObject();

    while (m_pCurrentHeader->nType != XN_PACKED_PROPERTY_SET_PROPERTIES_END_MARKER)
    {
        // read property and add it to set
        switch (m_pCurrentHeader->nType)
        {
        case XN_PACKED_INT_PROPERTY:
        {
            XnUInt64 nValue;
            nRetVal = ReadPropertyImpl(strModule, strName, &nValue);
            XN_IS_STATUS_OK(nRetVal);
            nRetVal = XnPropertySetAddIntProperty(pPropertySet, strModule, strName, nValue);
            XN_IS_STATUS_OK(nRetVal);
            break;
        }
        case XN_PACKED_REAL_PROPERTY:
        {
            XnDouble dValue;
            nRetVal = ReadPropertyImpl(strModule, strName, &dValue);
            XN_IS_STATUS_OK(nRetVal);
            nRetVal = XnPropertySetAddRealProperty(pPropertySet, strModule, strName, dValue);
            XN_IS_STATUS_OK(nRetVal);
            break;
        }
        case XN_PACKED_STRING_PROPERTY:
        {
            XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH];
            nRetVal = ReadPropertyImpl(strModule, strName, strValue);
            XN_IS_STATUS_OK(nRetVal);
            nRetVal = XnPropertySetAddStringProperty(pPropertySet, strModule, strName, strValue);
            XN_IS_STATUS_OK(nRetVal);
            break;
        }
        case XN_PACKED_GENERAL_PROPERTY:
        {
            XnGeneralBuffer gbValue;
            nRetVal = ReadPropertyImpl(strModule, strName, &gbValue);
            XN_IS_STATUS_OK(nRetVal);
            nRetVal = XnPropertySetAddGeneralProperty(pPropertySet, strModule, strName, &gbValue);
            XN_IS_STATUS_OK(nRetVal);
            break;
        }
        default:
            XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Stream contains an object of type %d in the middle of a property set!", m_pCurrentHeader->nType);
        }
    } // props loop

    // read properties end marker
    MoveToNextObject();

    return (XN_STATUS_OK);
}