* Replaces the object being pointed. */
| 1723 | * Replaces the object being pointed. |
| 1724 | */ |
| 1725 | inline void SetHandle(XnNodeHandle hNode) |
| 1726 | { |
| 1727 | if (m_hNode == hNode) |
| 1728 | { |
| 1729 | // Optimization: do nothing |
| 1730 | return; |
| 1731 | } |
| 1732 | |
| 1733 | // check currently held node. If we're holding a node, release it |
| 1734 | if (m_hNode != NULL) |
| 1735 | { |
| 1736 | XnContext* pContext = xnGetRefContextFromNodeHandle(m_hNode); |
| 1737 | xnContextUnregisterFromShutdown(pContext, m_hShuttingDownCallback); |
| 1738 | xnContextRelease(pContext); |
| 1739 | xnProductionNodeRelease(m_hNode); |
| 1740 | } |
| 1741 | |
| 1742 | // check new node handle, if it points to a node, add ref to it |
| 1743 | if (hNode != NULL) |
| 1744 | { |
| 1745 | XnStatus nRetVal = xnProductionNodeAddRef(hNode); |
| 1746 | XN_ASSERT(nRetVal == XN_STATUS_OK); |
| 1747 | XN_REFERENCE_VARIABLE(nRetVal); |
| 1748 | |
| 1749 | XnContext* pContext = xnGetRefContextFromNodeHandle(hNode); |
| 1750 | |
| 1751 | nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback); |
| 1752 | XN_ASSERT(nRetVal == XN_STATUS_OK); |
| 1753 | |
| 1754 | xnContextRelease(pContext); |
| 1755 | } |
| 1756 | |
| 1757 | m_hNode = hNode; |
| 1758 | } |
| 1759 | |
| 1760 | inline void TakeOwnership(XnNodeHandle hNode) |
| 1761 | { |
no test coverage detected