Пример #1
0
XnStatus xnXmlReadQuery(const TiXmlElement* pQueryElem, XnNodeQuery* pQuery)
{
	XnStatus nRetVal = XN_STATUS_OK;

	// vendor
	const TiXmlElement* pVendor = pQueryElem->FirstChildElement("Vendor");
	if (pVendor != NULL)
	{
		xnNodeQuerySetVendor(pQuery, pVendor->GetText());
	}

	// name
	const TiXmlElement* pName = pQueryElem->FirstChildElement("Name");
	if (pName != NULL)
	{
		xnNodeQuerySetName(pQuery, pName->GetText());
	}

	// Min version
	const TiXmlElement* pMinVersion = pQueryElem->FirstChildElement("MinVersion");
	if (pMinVersion != NULL)
	{
		XnVersion minVersion;
		nRetVal = xnReadVersionFromXml(pMinVersion, &minVersion);
		XN_IS_STATUS_OK(nRetVal);

		xnNodeQuerySetMinVersion(pQuery, &minVersion);
	}

	// Max version
	const TiXmlElement* pMaxVersion = pQueryElem->FirstChildElement("MaxVersion");
	if (pMaxVersion != NULL)
	{
		XnVersion maxVersion;
		nRetVal = xnReadVersionFromXml(pMaxVersion, &maxVersion);
		XN_IS_STATUS_OK(nRetVal);

		xnNodeQuerySetMaxVersion(pQuery, &maxVersion);
	}

	// Capabilities
	const TiXmlElement* pCapabilities = pQueryElem->FirstChildElement("Capabilities");
	if (pCapabilities != NULL)
	{
		const TiXmlElement* pCap = pCapabilities->FirstChildElement("Capability");
		while (pCap != NULL)
		{
			xnNodeQueryAddSupportedCapability(pQuery, pCap->GetText());
			pCap = pCap->NextSiblingElement("Capability");
		}
	}

	// Map Output Modes
	const TiXmlElement* pOutputModes = pQueryElem->FirstChildElement("MapOutputModes");
	if (pOutputModes != NULL)
	{
		const TiXmlElement* pMode = pOutputModes->FirstChildElement("MapOutputMode");
		while (pMode != NULL)
		{
			XnMapOutputMode Mode;
			nRetVal = xnXmlReadMapOutputMode(pMode, &Mode);
			XN_IS_STATUS_OK(nRetVal);

			xnNodeQueryAddSupportedMapOutputMode(pQuery, &Mode);

			pMode = pMode->NextSiblingElement("MapOutputMode");
		}
	}

	// Min User Position
	const TiXmlElement* pMinUserPositions = pQueryElem->FirstChildElement("MinUserPositions");
	if (pMinUserPositions != NULL)
	{
		XnInt nMinUserPositions;
		nRetVal = xnXmlReadTextAsInt(pMinUserPositions, &nMinUserPositions);
		XN_IS_STATUS_OK(nRetVal);

		xnNodeQuerySetSupportedMinUserPositions(pQuery, nMinUserPositions);
	}

	// Existing Node Only
	XnBool bExistingOnly = FALSE;
	const TiXmlElement* pExistingOnly = pQueryElem->FirstChildElement("ExistingNodeOnly");
	if (pExistingOnly != NULL)
	{
		xnNodeQuerySetExistingNodeOnly(pQuery, TRUE);
		bExistingOnly = TRUE;
	}

	// Non Existing Node Only
	const TiXmlElement* pNonExistingOnly = pQueryElem->FirstChildElement("NonExistingNodeOnly");
	if (pNonExistingOnly != NULL)
	{
		if (bExistingOnly)
		{
			xnLogError(XN_MASK_OPEN_NI, "Cannot specify both <ExistingNodeOnly> and <NonExistingNodeOnly> in query");
			XN_ASSERT(FALSE);
			return XN_STATUS_INVALID_OPERATION;
		}
		xnNodeQuerySetNonExistingNodeOnly(pQuery, TRUE);
	}

	// Needed Nodes
	const TiXmlElement* pNeededNodes = pQueryElem->FirstChildElement("NeededNodes");
	if (pNeededNodes != NULL)
	{
		const TiXmlElement* pNode = pNeededNodes->FirstChildElement("Node");
		while (pNode != NULL)
		{
			xnNodeQueryAddNeededNode(pQuery, pNode->GetText());

			pNode = pNode->NextSiblingElement("Node");
		}
	}

	// Creation info
	const TiXmlElement* pCreationInfo = pQueryElem->FirstChildElement("CreationInfo");
	if (pCreationInfo != NULL)
	{
		xnNodeQuerySetCreationInfo(pQuery, pCreationInfo->GetText());
	}

	return (XN_STATUS_OK);
}
Пример #2
0
XnStatus xnXmlReadQuery(const TiXmlElement* pQueryElem, XnNodeQuery* pQuery)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	// vendor
	const TiXmlElement* pVendor = pQueryElem->FirstChildElement("Vendor");
	if (pVendor != NULL)
	{
		xnNodeQuerySetVendor(pQuery, pVendor->GetText());
	}

	// name
	const TiXmlElement* pName = pQueryElem->FirstChildElement("Name");
	if (pName != NULL)
	{
		xnNodeQuerySetName(pQuery, pName->GetText());
	}

	// Min version
	const TiXmlElement* pMinVersion = pQueryElem->FirstChildElement("MinVersion");
	if (pMinVersion != NULL)
	{
		XnVersion minVersion;
		nRetVal = xnReadVersionFromXml(pMinVersion, &minVersion);
		XN_IS_STATUS_OK(nRetVal);

		xnNodeQuerySetMinVersion(pQuery, &minVersion);
	}

	// Max version
	const TiXmlElement* pMaxVersion = pQueryElem->FirstChildElement("MaxVersion");
	if (pMaxVersion != NULL)
	{
		XnVersion maxVersion;
		nRetVal = xnReadVersionFromXml(pMaxVersion, &maxVersion);
		XN_IS_STATUS_OK(nRetVal);

		xnNodeQuerySetMinVersion(pQuery, &maxVersion);
	}

	// Capabilities
	const TiXmlElement* pCapabilities = pQueryElem->FirstChildElement("Capabilities");
	if (pCapabilities != NULL)
	{
		const TiXmlElement* pCap = pCapabilities->FirstChildElement("Capability");
		while (pCap != NULL)
		{
			xnNodeQueryAddSupportedCapability(pQuery, pCap->GetText());
			pCap = pCap->NextSiblingElement("Capability");
		}
	}

	// Map Output Modes
	const TiXmlElement* pOutputModes = pQueryElem->FirstChildElement("MapOutputModes");
	if (pOutputModes != NULL)
	{
		const TiXmlElement* pMode = pOutputModes->FirstChildElement("MapOutputMode");
		while (pMode != NULL)
		{
			XnMapOutputMode Mode;
			nRetVal = xnXmlReadMapOutputMode(pMode, &Mode);
			XN_IS_STATUS_OK(nRetVal);

			xnNodeQueryAddSupportedMapOutputMode(pQuery, &Mode);

			pMode = pMode->NextSiblingElement("MapOutputMode");
		}
	}

	// Min User Position
	const TiXmlElement* pMinUserPositions = pQueryElem->FirstChildElement("MinUserPositions");
	if (pMinUserPositions != NULL)
	{
		XnInt nMinUserPositions;
		nRetVal = xnXmlReadTextAsInt(pMinUserPositions, &nMinUserPositions);
		XN_IS_STATUS_OK(nRetVal);

		xnNodeQuerySetSupportedMinUserPositions(pQuery, nMinUserPositions);
	}

	// Needed Nodes
	const TiXmlElement* pNeededNodes = pQueryElem->FirstChildElement("NeededNodes");
	if (pNeededNodes != NULL)
	{
		const TiXmlElement* pNode = pNeededNodes->FirstChildElement("Node");
		while (pNode != NULL)
		{
			xnNodeQueryAddNeededNode(pQuery, pNode->GetText());

			pNode = pNode->NextSiblingElement("Node");
		}
	}

	// Creation info
	const TiXmlElement* pCreationInfo = pQueryElem->FirstChildElement("CreationInfo");
	if (pCreationInfo != NULL)
	{
		xnNodeQuerySetCreationInfo(pQuery, pCreationInfo->GetText());
	}

	return (XN_STATUS_OK);
}