本文整理汇总了C++中CNode::get_children方法的典型用法代码示例。如果您正苦于以下问题:C++ CNode::get_children方法的具体用法?C++ CNode::get_children怎么用?C++ CNode::get_children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNode
的用法示例。
在下文中一共展示了CNode::get_children方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove
void CStateTable::remove( const CNode &node )
{
/* remove self from path map */
const string &path = node.get_path();
if( m_nodes.count( path ) != 1 )
{
INTEGRA_TRACE_ERROR << "missing key in state table: " << path;
}
else
{
m_nodes.erase( path );
}
/* remove self from id map */
internal_id id = node.get_id();
if( m_nodes_by_id.count( id ) != 1 )
{
INTEGRA_TRACE_ERROR << "missing key in state table: " << id;
}
else
{
m_nodes_by_id.erase( id );
}
/* remove node endpoints */
const node_endpoint_map node_endpoints = node.get_node_endpoints();
for( node_endpoint_map::const_iterator i = node_endpoints.begin(); i != node_endpoints.end(); i++ )
{
const INodeEndpoint *node_endpoint = i->second;
const string &path = node_endpoint->get_path();
if( m_node_endpoints.count( path ) != 1 )
{
INTEGRA_TRACE_ERROR << "missing key in state table: " << path;
}
else
{
m_node_endpoints.erase( path );
}
}
/* remove child nodes */
const node_map &children = node.get_children();
for( node_map::const_iterator i = children.begin(); i != children.end(); i++ )
{
remove( *CNode::downcast_writable( i->second ) );
}
}
示例2: activate_tree
void CContainerLogic::activate_tree( CServer &server, const CNode &node, bool activate, path_list &activated_nodes )
{
/*
sets 'active' endpoint on any descendants that are not containers
If any node in ancestor chain are not active, sets descendants to not active
If all node in ancestor chain are active, sets descendants to active
Additionally, the function pushes 'activated_nodes' - a list of pointers to
nodes which were activated by the function.
The caller can use this list to perform additional logic
*/
const INodeEndpoint *active_endpoint = node.get_node_endpoint( endpoint_active );
if( dynamic_cast< CContainerLogic * > ( &node.get_logic() ) )
{
/* if node is a container, update 'activate' according to it's active flag */
assert( active_endpoint );
activate &= ( ( int ) *active_endpoint->get_value() != 0 );
}
else
{
/* if node is not a container, update it's active flag (if it has one) according to 'activate' */
if( active_endpoint )
{
CIntegerValue value( activate ? 1 : 0 );
if( !active_endpoint->get_value()->is_equal( value ) )
{
server.process_command( ISetCommand::create( active_endpoint->get_path(), value ), CCommandSource::SYSTEM );
if( activate )
{
activated_nodes.push_back( node.get_path() );
}
}
}
}
const node_map &children = node.get_children();
for( node_map::const_iterator i = children.begin(); i != children.end(); i++ )
{
activate_tree( server, *CNode::downcast( i->second ), activate, activated_nodes );
}
}