| 378 | } |
| 379 | |
| 380 | XnStatus XnModuleLoader::AddModule(XnOpenNIModuleInterface* pInterface, const XnChar* strConfigDir, const XnChar* strName) |
| 381 | { |
| 382 | XnStatus nRetVal = XN_STATUS_OK; |
| 383 | |
| 384 | // get OpenNI Version |
| 385 | XnVersion openNIVersion; |
| 386 | pInterface->pGetVersionFunc(&openNIVersion); |
| 387 | |
| 388 | if (m_loadingMode == LOADING_MODE_PRINT) |
| 389 | { |
| 390 | XnChar strOpenNIVersion[100]; |
| 391 | xnVersionToString(&openNIVersion, strOpenNIVersion, 100); |
| 392 | printf("(compiled with OpenNI %s):\n", strOpenNIVersion); |
| 393 | } |
| 394 | |
| 395 | // load Module |
| 396 | nRetVal = pInterface->pLoadFunc(); |
| 397 | if (nRetVal != XN_STATUS_OK) |
| 398 | { |
| 399 | xnLogWarning(XN_MASK_MODULE_LOADER, "'%s' load function failed. Error code: 0x%x", strName, nRetVal); |
| 400 | return (nRetVal); |
| 401 | } |
| 402 | |
| 403 | // take the number of generators |
| 404 | XnUInt32 nCount = pInterface->pGetCountFunc(); |
| 405 | |
| 406 | // allocate entry points array |
| 407 | XnModuleGetExportedInterfacePtr* aEntryPoints; |
| 408 | XN_VALIDATE_CALLOC(aEntryPoints, XnModuleGetExportedInterfacePtr, nCount); |
| 409 | |
| 410 | // fill it |
| 411 | nRetVal = pInterface->pGetEntryPointsFunc(aEntryPoints, nCount); |
| 412 | if (nRetVal != XN_STATUS_OK) |
| 413 | { |
| 414 | xnLogWarning(XN_MASK_MODULE_LOADER, "'%s' - failed to get exported nodes. Error code: 0x%x", strName, nRetVal); |
| 415 | xnOSFree(aEntryPoints); |
| 416 | return (nRetVal); |
| 417 | } |
| 418 | |
| 419 | // now add every exported node |
| 420 | for (XnUInt32 i = 0; i < nCount; ++i) |
| 421 | { |
| 422 | // get exported interface |
| 423 | XnModuleExportedProductionNodeInterface ExportedInterface; |
| 424 | aEntryPoints[i](&ExportedInterface); |
| 425 | |
| 426 | nRetVal = AddExportedNode(openNIVersion, &ExportedInterface, strConfigDir); |
| 427 | if (nRetVal == XN_STATUS_INVALID_GENERATOR) |
| 428 | { |
| 429 | // if it failed, then this specific generator is not loaded, but the rest should be loaded anyway. |
| 430 | xnLogWarning(XN_MASK_MODULE_LOADER, "Failed to add generator %d from module '%s'", i, strName); |
| 431 | } |
| 432 | else if (nRetVal != XN_STATUS_OK) |
| 433 | { |
| 434 | xnOSFree(aEntryPoints); |
| 435 | return (nRetVal); |
| 436 | } |
| 437 | } |
nothing calls this directly
no test coverage detected