| 442 | } |
| 443 | |
| 444 | XnStatus XnModuleLoader::AddExportedNode(XnVersion& moduleOpenNIVersion, XnModuleExportedProductionNodeInterface* pExportedInterface, const XnChar* strConfigDir) |
| 445 | { |
| 446 | XnStatus nRetVal = XN_STATUS_OK; |
| 447 | |
| 448 | // Validate we have all mandatory functions |
| 449 | XN_VALIDATE_FUNC_NOT_NULL(pExportedInterface, GetDescription); |
| 450 | XN_VALIDATE_FUNC_NOT_NULL(pExportedInterface, EnumerateProductionTrees); |
| 451 | XN_VALIDATE_FUNC_NOT_NULL(pExportedInterface, Create); |
| 452 | XN_VALIDATE_FUNC_NOT_NULL(pExportedInterface, Destroy); |
| 453 | XN_VALIDATE_FUNC_NOT_NULL(pExportedInterface, GetInterface.General); |
| 454 | |
| 455 | XnLoadedGenerator loaded; |
| 456 | xnOSMemSet(&loaded, 0, sizeof(loaded)); |
| 457 | loaded.ExportedInterface = *pExportedInterface; |
| 458 | |
| 459 | // Get Description |
| 460 | pExportedInterface->GetDescription(&loaded.Description); |
| 461 | |
| 462 | XnChar strDescription[512]; |
| 463 | xnProductionNodeDescriptionToString(&loaded.Description, strDescription, 512); |
| 464 | |
| 465 | xnLogVerbose(XN_MASK_MODULE_LOADER, "Found exported production node. %s", strDescription); |
| 466 | if (m_loadingMode == LOADING_MODE_PRINT) |
| 467 | { |
| 468 | printf("\t%s\n", strDescription); |
| 469 | } |
| 470 | |
| 471 | // make sure it's not in the list |
| 472 | XnLoadedGeneratorsHash::ConstIterator it = m_AllGenerators.Find(loaded.Description); |
| 473 | if (it != m_AllGenerators.End()) |
| 474 | { |
| 475 | XN_LOG_WARNING_RETURN(XN_STATUS_INVALID_GENERATOR, XN_MASK_MODULE_LOADER, "A Generator with the same description already exists!"); |
| 476 | } |
| 477 | |
| 478 | // Now load specific interface |
| 479 | XnProductionNodeInterfaceContainer* pInterfaceContainer = NULL; |
| 480 | |
| 481 | nRetVal = LoadSpecificInterface(moduleOpenNIVersion, loaded.Description.Type, pExportedInterface, pInterfaceContainer); |
| 482 | XN_IS_STATUS_OK(nRetVal); |
| 483 | |
| 484 | loaded.pInterface = pInterfaceContainer; |
| 485 | |
| 486 | if (strConfigDir != NULL) |
| 487 | { |
| 488 | loaded.strConfigDir = xnOSStrDup(strConfigDir); |
| 489 | } |
| 490 | |
| 491 | // Add it to list |
| 492 | if (m_loadingMode == LOADING_MODE_LOAD) |
| 493 | { |
| 494 | nRetVal = m_AllGenerators.Set(loaded.Description, loaded); |
| 495 | if (nRetVal != XN_STATUS_OK) |
| 496 | { |
| 497 | xnOSFree(loaded.strConfigDir); |
| 498 | XN_DELETE(pInterfaceContainer); |
| 499 | return (nRetVal); |
| 500 | } |
| 501 | } |
nothing calls this directly
no test coverage detected