MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / RemoveQueues

Method RemoveQueues

cpp/src/Driver.cpp:639–689  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Clean up any messages to a node -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

637// Clean up any messages to a node
638//-----------------------------------------------------------------------------
639void Driver::RemoveQueues
640(
641 uint8 const _nodeId
642)
643{
644 if( m_currentMsg != NULL && m_currentMsg->GetTargetNodeId() == _nodeId )
645 {
646 RemoveCurrentMsg();
647 }
648
649 // Clear the send Queue
650 for( int32 i=0; i<MsgQueue_Count; ++i )
651 {
652 list<MsgQueueItem>::iterator it = m_msgQueue[i].begin();
653 while( it != m_msgQueue[i].end() )
654 {
655 bool remove = false;
656 MsgQueueItem const& item = *it;
657 if( MsgQueueCmd_SendMsg == item.m_command && _nodeId == item.m_msg->GetTargetNodeId() )
658 {
659 delete item.m_msg;
660 remove = true;
661 }
662 else if( MsgQueueCmd_QueryStageComplete == item.m_command && _nodeId == item.m_nodeId )
663 {
664 remove = true;
665 }
666 else if( MsgQueueCmd_Controller == item.m_command && _nodeId == item.m_cci->m_controllerCommandNode && m_currentControllerCommand != item.m_cci )
667 {
668 delete item.m_cci;
669 remove = true;
670 }
671 else if (MsgQueueCmd_ReloadNode == item.m_command && _nodeId == item.m_nodeId)
672 {
673 remove = true;
674 }
675 if( remove )
676 {
677 it = m_msgQueue[i].erase( it );
678 }
679 else
680 {
681 ++it;
682 }
683 }
684 if( m_msgQueue[i].empty() )
685 {
686 m_queueEvent[i]->Reset();
687 }
688 }
689}
690
691//-----------------------------------------------------------------------------
692// Configuration

Callers 1

~NodeMethod · 0.80

Calls 4

beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected