ArrayDatum get_children( const index node_id, const DictionaryDatum& params, const bool include_remotes ) { Subnet* subnet = dynamic_cast< Subnet* >( kernel().node_manager.get_node( node_id ) ); if ( subnet == NULL ) { throw SubnetExpected(); } LocalChildList localnodes( *subnet ); ArrayDatum result; std::vector< MPIManager::NodeAddressingData > globalnodes; if ( params->empty() ) { kernel().mpi_manager.communicate( localnodes, globalnodes, include_remotes ); } else { kernel().mpi_manager.communicate( localnodes, globalnodes, params, include_remotes ); } result.reserve( globalnodes.size() ); for ( std::vector< MPIManager::NodeAddressingData >::iterator n = globalnodes.begin(); n != globalnodes.end(); ++n ) { result.push_back( new IntegerDatum( n->get_gid() ) ); } return result; }
ArrayDatum get_nodes( const index node_id, const DictionaryDatum& params, const bool include_remotes, const bool return_gids_only ) { Subnet* subnet = dynamic_cast< Subnet* >( kernel().node_manager.get_node( node_id ) ); if ( subnet == NULL ) throw SubnetExpected(); LocalNodeList localnodes( *subnet ); std::vector< MPIManager::NodeAddressingData > globalnodes; if ( params->empty() ) { kernel().mpi_manager.communicate( localnodes, globalnodes, include_remotes ); } else { kernel().mpi_manager.communicate( localnodes, globalnodes, params, include_remotes ); } ArrayDatum result; result.reserve( globalnodes.size() ); for ( std::vector< MPIManager::NodeAddressingData >::iterator n = globalnodes.begin(); n != globalnodes.end(); ++n ) { if ( return_gids_only ) { result.push_back( new IntegerDatum( n->get_gid() ) ); } else { DictionaryDatum* node_info = new DictionaryDatum( new Dictionary ); ( **node_info )[ names::global_id ] = n->get_gid(); ( **node_info )[ names::vp ] = n->get_vp(); ( **node_info )[ names::parent ] = n->get_parent_gid(); result.push_back( node_info ); } } return result; }