Exemple #1
0
ArrayDatum
get_connections( const DictionaryDatum& dict )
{
  dict->clear_access_flags();

  ArrayDatum array = kernel().connection_builder_manager.get_connections( dict );

  ALL_ENTRIES_ACCESSED( *dict, "GetConnections", "Unread dictionary entries: " );

  return array;
}
void
ModelManager::set_node_defaults_( index model_id,
  const DictionaryDatum& params )
{
  params->clear_access_flags();

  get_model( model_id )->set_status( params );

  ALL_ENTRIES_ACCESSED( *params,
    "ModelManager::set_node_defaults_",
    "Unread dictionary entries: " );
}
void
NodeManager::set_status_single_node_( Node& target,
  const DictionaryDatum& d,
  bool clear_flags )
{
  // proxies have no properties
  if ( not target.is_proxy() )
  {
    if ( clear_flags )
    {
      d->clear_access_flags();
    }
    target.set_status_base( d );

    // TODO: Not sure this check should be at single neuron level; advantage is
    // it stops after first failure.
    ALL_ENTRIES_ACCESSED(
      *d, "NodeManager::set_status", "Unread dictionary entries: " );
  }
}
void
ModelManager::set_synapse_defaults_( index model_id,
  const DictionaryDatum& params )
{
  params->clear_access_flags();
  assert_valid_syn_id( model_id );

  BadProperty* tmp_exception = NULL;
#ifdef _OPENMP
#pragma omp parallel
  {
    index t = kernel().vp_manager.get_thread_id();
#else // clang-format off
  for ( index t = 0; t < kernel().vp_manager.get_num_threads(); ++t )
  {
#endif // clang-format on
#pragma omp critical
    {
      try
      {
        prototypes_[ t ][ model_id ]->set_status( params );
      }
      catch ( BadProperty& e )
      {
        if ( tmp_exception == NULL )
        {
          tmp_exception = new BadProperty(
            String::compose( "Setting status of prototype '%1': %2",
              prototypes_[ t ][ model_id ]->get_name(),
              e.message() ) );
        }
      }
    }
  }

  if ( tmp_exception != NULL )
  {
    BadProperty e = *tmp_exception;
    delete tmp_exception;
    throw e;
  }

  ALL_ENTRIES_ACCESSED( *params,
    "ModelManager::set_synapse_defaults_",
    "Unread dictionary entries: " );
}

// TODO: replace int with index and return value -1 with invalid_index, also
// change all pertaining code
int
ModelManager::get_model_id( const Name name ) const
{
  const Name model_name( name );
  for ( int i = 0; i < ( int ) models_.size(); ++i )
  {
    assert( models_[ i ] != NULL );
    if ( model_name == models_[ i ]->get_name() )
      return i;
  }
  return -1;
}


DictionaryDatum
ModelManager::get_connector_defaults( synindex syn_id ) const
{
  assert_valid_syn_id( syn_id );

  DictionaryDatum dict( new Dictionary() );

  for ( thread t = 0;
        t < static_cast< thread >( kernel().vp_manager.get_num_threads() );
        ++t )
    prototypes_[ t ][ syn_id ]->get_status(
      dict ); // each call adds to num_connections

  ( *dict )[ "num_connections" ] =
    kernel().connection_manager.get_num_connections( syn_id );

  return dict;
}