当前位置: 首页>>代码示例>>C++>>正文


C++ Notification::SetGroupIdx方法代码示例

本文整理汇总了C++中Notification::SetGroupIdx方法的典型用法代码示例。如果您正苦于以下问题:C++ Notification::SetGroupIdx方法的具体用法?C++ Notification::SetGroupIdx怎么用?C++ Notification::SetGroupIdx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notification的用法示例。


在下文中一共展示了Notification::SetGroupIdx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AssociationCommandVec

//-----------------------------------------------------------------------------
// <Group::OnGroupChanged>
// Change the group contents and notify the watchers
//-----------------------------------------------------------------------------
void Group::OnGroupChanged
(
	vector<InstanceAssociation> const& _associations
)
{
	bool notify = false;

	// If the number of associations is different, we'll save 
	// ourselves some work and clear the old set now.
	if( _associations.size() != m_associations.size() )
	{
		m_associations.clear();
		notify = true;
	}
	else
	{
		// Handle initial group creation case
		if ( _associations.size() == 0 && m_associations.size() == 0 )
		{
			notify = true;
		}
	}

	// Add the new associations. 
	uint8 oldSize = (uint8)m_associations.size();

	uint8 i;
	for( i=0; i<_associations.size(); ++i )
	{
		m_associations[_associations[i]] = AssociationCommandVec();
	}

	if( (!notify) && ( oldSize != m_associations.size() ) )
	{
		// The number of nodes in the original and new groups is the same, but
		// the number of associations has grown. There must be different nodes 
		// in the original and new sets of nodes in the group.  The easiest way
		// to sort this out is to clear the associations and add the new nodes again.
		m_associations.clear();
		for( i=0; i<_associations.size(); ++i )
		{
			m_associations[_associations[i]] = AssociationCommandVec();
		}
		notify = true;
	}

	if( notify )
	{
		// If the node supports COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION, we need to request the command data.
		if( Driver* driver = Manager::Get()->GetDriver( m_homeId ) )
		{
			if( Node* node = driver->GetNodeUnsafe( m_nodeId ) )
			{
				if( AssociationCommandConfiguration* cc = static_cast<AssociationCommandConfiguration*>( node->GetCommandClass( AssociationCommandConfiguration::StaticGetCommandClassId() ) ) )
				{
					for( map<InstanceAssociation,AssociationCommandVec,classcomp>::iterator it = m_associations.begin(); it != m_associations.end(); ++it )
					{
						cc->RequestCommands( m_groupIdx, it->first.m_nodeId );
					}
				}
			}
		}

		// Send notification that the group contents have changed
		Notification* notification = new Notification( Notification::Type_Group );
		notification->SetHomeAndNodeIds( m_homeId, m_nodeId );
		notification->SetGroupIdx( m_groupIdx );
		Manager::Get()->GetDriver( m_homeId )->QueueNotification( notification ); 
		// Update routes on remote node if necessary
		bool update = false;
		Options::Get()->GetOptionAsBool( "PerformReturnRoutes", &update );
		if( update )
		{
			Driver *drv = Manager::Get()->GetDriver( m_homeId );
			if (drv)
				drv->UpdateNodeRoutes( m_nodeId );
		}
	}
}
开发者ID:1337bacon,项目名称:open-zwave,代码行数:83,代码来源:Group.cpp


注:本文中的Notification::SetGroupIdx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。