MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / xnRegisterModule

Function xnRegisterModule

Source/OpenNI/XnModuleLoader.cpp:1490–1568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1488}
1489
1490XN_C_API XnStatus xnRegisterModule(const XnChar* strModule, const XnChar* strConfigDir)
1491{
1492 XnStatus nRetVal = XN_STATUS_OK;
1493
1494 XnChar strFullPath[XN_FILE_MAX_PATH];
1495 nRetVal = xnOSGetFullPathName(strModule, strFullPath, XN_FILE_MAX_PATH);
1496 XN_IS_STATUS_OK(nRetVal);
1497
1498 XnBool bExists = FALSE;
1499 nRetVal = xnOSDoesFileExist(strFullPath, &bExists);
1500 XN_IS_STATUS_OK(nRetVal);
1501
1502 if (!bExists)
1503 {
1504 XN_LOG_WARNING_RETURN(XN_STATUS_OS_FILE_NOT_FOUND, XN_MASK_OPEN_NI, "File '%s' does not exist!", strFullPath);
1505 }
1506
1507 XnChar strConfigFullPathBuffer[XN_FILE_MAX_PATH] = {0};
1508 const XnChar* strConfigFullPath = NULL;
1509
1510 if (strConfigDir != NULL)
1511 {
1512 nRetVal = xnOSGetFullPathName(strConfigDir, strConfigFullPathBuffer, XN_FILE_MAX_PATH);
1513 XN_IS_STATUS_OK(nRetVal);
1514 strConfigFullPath = strConfigFullPathBuffer;
1515
1516 bExists = FALSE;
1517 nRetVal = xnOSDoesDirecotyExist(strConfigFullPath, &bExists);
1518 XN_IS_STATUS_OK(nRetVal);
1519
1520 if (!bExists)
1521 {
1522 XN_LOG_WARNING_RETURN(XN_STATUS_OS_FILE_NOT_FOUND, XN_MASK_OPEN_NI, "Config directory '%s' does not exist!", strConfigFullPath);
1523 }
1524 }
1525
1526 // TODO: try to load it to make sure its valid
1527
1528 TiXmlDocument doc;
1529 nRetVal = loadModulesFile(doc);
1530 XN_IS_STATUS_OK(nRetVal);
1531
1532 // check if it's already there
1533 XnBool bFound = FALSE;
1534 TiXmlElement* pModule = doc.RootElement()->FirstChildElement(XN_MODULE_ELEMENT_NAME);
1535 while (pModule != NULL)
1536 {
1537 const XnChar* strPath;
1538 nRetVal = xnXmlReadStringAttribute(pModule, "path", &strPath);
1539 XN_IS_STATUS_OK(nRetVal);
1540
1541 if (strcmp(strPath, strFullPath) == 0)
1542 {
1543 bFound = TRUE;
1544 break;
1545 }
1546
1547 pModule = pModule->NextSiblingElement(XN_MODULE_ELEMENT_NAME);

Callers 1

mainFunction · 0.85

Calls 11

loadModulesFileFunction · 0.85
xnXmlReadStringAttributeFunction · 0.85
saveModulesFileFunction · 0.85
RootElementMethod · 0.80
SetAttributeMethod · 0.80
InsertEndChildMethod · 0.80
xnOSGetFullPathNameFunction · 0.50
xnOSDoesFileExistFunction · 0.50
xnOSDoesDirecotyExistFunction · 0.50
FirstChildElementMethod · 0.45
NextSiblingElementMethod · 0.45

Tested by

no test coverage detected