Understanding why enumeration failed

Sometimes an application enumerates for a specific node, and gets zero results. Aside for the obvious reason where no module implementing this node type is installed, other reasons may occur - a module might be installed but have no license, or a needed hardware device is currently disconnected.

OpenNI enables the application to get a full list of modules that failed to enumerate, and why each one failed. The list of 'failed' modules is obtained by using the xn::EnumerationErrors object.

For example, the following code tries to create a xn::HandsGenerator node, and if enumeration failed, checks all errors:

xn::EnumerationErrors errors;
xn::HandsGenerator handsGen;
nRetVal = context.CreateAnyProductionTree(XN_NODE_TYPE_HANDS, NULL, handsGen, &errors);
if (nRetVal == XN_STATUS_NO_NODE_PRESENT)
{
// Iterate over enumeration errors, and print each one
for (xn::EnumerationErrors::Iterator it = errors.Begin(); it != errors.End(); ++it)
{
XnChar strDesc[512];
xnProductionNodeDescriptionToString(&it.Description(), strDesc, 512);
printf("%s failed to enumerate: %s\n", xnGetStatusString(it.Error()));
}
return (nRetVal);
}
else if (nRetVal != XN_STATUS_OK)
{
printf("Create failed: %s\n", xnGetStatusString(nRetVal));
return (nRetVal);
}
XN_STATUS_OK
#define XN_STATUS_OK
Definition XnStatus.h:37
xnGetStatusString
XN_C_API const XnChar *XN_C_DECL xnGetStatusString(const XnStatus Status)
XN_NODE_TYPE_HANDS
@ XN_NODE_TYPE_HANDS
Definition XnTypes.h:133
xn::EnumerationErrors::Iterator
Definition XnCppWrapper.h:8432
xn::EnumerationErrors
Definition XnCppWrapper.h:8407
xn::EnumerationErrors::Begin
Iterator Begin() const
Gets an iterator to the first item in an enumeration errors list.
Definition XnCppWrapper.h:8505
xn::EnumerationErrors::End
Iterator End() const
Returns an iterator referring to the past-the-end element in an enumeration errors list....
Definition XnCppWrapper.h:8515
xn::HandsGenerator
Definition XnCppWrapper.h:6064
xnProductionNodeDescriptionToString
XN_C_API XnStatus XN_C_DECL xnProductionNodeDescriptionToString(const XnProductionNodeDescription *pDescription, XnChar *csResult, XnUInt32 nSize)