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


C++ DictionaryDatum类代码示例

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


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

示例1: cg_connect

  void cg_connect(ConnectionGeneratorDatum& cg, RangeSet& sources, std::vector<long>& source_gids, RangeSet& targets, std::vector<long>& target_gids, DictionaryDatum params_map, index syn)
  {
    cg_set_masks(cg, sources, targets);
    cg->start();

    int source, target, num_parameters = cg->arity();
    if (num_parameters == 0)
    {
      while (cg->next(source, target, NULL))
        ConnectionGeneratorModule::get_network().connect(source_gids.at(source), target_gids.at(target), syn);
    }
    else if (num_parameters == 2)
    {
      if (!params_map->known(names::weight) || !params_map->known(names::delay))
        throw BadProperty("The parameter map has to contain the indices of weight and delay.");  

      long w_idx = (*params_map)[names::weight];
      long d_idx = (*params_map)[names::delay];
      std::vector<double> params(2);

      while (cg->next(source, target, &params[0]))
        ConnectionGeneratorModule::get_network().connect(source_gids.at(source), target_gids.at(target), params[w_idx], params[d_idx], syn);
    }
    else
    {
      ConnectionGeneratorModule::get_network().message(SLIInterpreter::M_ERROR, "Connect", "Either two or no parameters in the Connection Set expected.");
      throw DimensionMismatch();  
    }
  }
开发者ID:QJonny,项目名称:CyNest,代码行数:29,代码来源:cg_connect.cpp

示例2: NameDatum

/**
 * This function is not thread save and has to be called inside a omp critical
 * region.
 */
int
nest::sli_neuron::execute_sli_protected( DictionaryDatum state, Name cmd )
{
  SLIInterpreter& i = get_engine();

  i.DStack->push( state ); // push state dictionary as top namespace
  size_t exitlevel = i.EStack.load();
  i.EStack.push( new NameDatum( cmd ) );
  int result = i.execute_( exitlevel );
  i.DStack->pop(); // pop neuron's namespace

  if ( state->known( "error" ) )
  {
    assert( state->known( names::global_id ) );
    index g_id = ( *state )[ names::global_id ];
    std::string model = getValue< std::string >( ( *state )[ names::model ] );
    std::string msg =
      String::compose( "Error in %1 with global id %2.", model, g_id );

    LOG( M_ERROR, cmd.toString().c_str(), msg.c_str() );
    LOG( M_ERROR, "execute_sli_protected", "Terminating." );

    kernel().simulation_manager.terminate();
  }

  return result;
}
开发者ID:HBPNeurorobotics,项目名称:nest-simulator,代码行数:31,代码来源:sli_neuron.cpp

示例3: cg_connect

void
cg_connect( ConnectionGeneratorDatum& cg,
  RangeSet& sources,
  std::vector< long >& source_gids,
  RangeSet& targets,
  std::vector< long >& target_gids,
  DictionaryDatum params_map,
  index syn )
{
  cg_set_masks( cg, sources, targets );
  cg->start();

  int source, target, num_parameters = cg->arity();
  if ( num_parameters == 0 )
  {
    // connect source to target
    while ( cg->next( source, target, NULL ) )
    {
      if ( kernel().node_manager.is_local_gid( target_gids.at( target ) ) )
      {
        Node* const target_node = kernel().node_manager.get_node( target_gids.at( target ) );
        const thread target_thread = target_node->get_thread();
        kernel().connection_builder_manager.connect(
          source_gids.at( source ), target_node, target_thread, syn );
      }
    }
  }
  else if ( num_parameters == 2 )
  {
    if ( !params_map->known( names::weight ) || !params_map->known( names::delay ) )
      throw BadProperty( "The parameter map has to contain the indices of weight and delay." );

    long w_idx = ( *params_map )[ names::weight ];
    long d_idx = ( *params_map )[ names::delay ];
    std::vector< double > params( 2 );

    // connect source to target with weight and delay
    while ( cg->next( source, target, &params[ 0 ] ) )
    {
      if ( kernel().node_manager.is_local_gid( target_gids.at( target ) ) )
      {
        Node* const target_node = kernel().node_manager.get_node( target_gids.at( target ) );
        const thread target_thread = target_node->get_thread();
        kernel().connection_builder_manager.connect( source_gids.at( source ),
          target_node,
          target_thread,
          syn,
          params[ d_idx ],
          params[ w_idx ] );
      }
    }
  }
  else
  {
    LOG( M_ERROR, "Connect", "Either two or no parameters in the Connection Set expected." );
    throw DimensionMismatch();
  }
}
开发者ID:gewaltig,项目名称:nest-simulator,代码行数:58,代码来源:cg_connect.cpp

示例4: UnknownModelName

ArrayDatum
ConnectionManager::get_connections( DictionaryDatum params ) const
{
  ArrayDatum connectome;

  const Token& source_t = params->lookup( names::source );
  const Token& target_t = params->lookup( names::target );
  const Token& syn_model_t = params->lookup( names::synapse_model );
  const TokenArray* source_a = 0;
  const TokenArray* target_a = 0;

  if ( not source_t.empty() )
    source_a = dynamic_cast< TokenArray const* >( source_t.datum() );
  if ( not target_t.empty() )
    target_a = dynamic_cast< TokenArray const* >( target_t.datum() );

  size_t syn_id = 0;

#ifdef _OPENMP
  std::string msg;
  msg = String::compose( "Setting OpenMP num_threads to %1.", net_.get_num_threads() );
  net_.message( SLIInterpreter::M_DEBUG, "ConnectionManager::get_connections", msg );
  omp_set_num_threads( net_.get_num_threads() );
#endif

  // First we check, whether a synapse model is given.
  // If not, we will iterate all.
  if ( not syn_model_t.empty() )
  {
    Name synmodel_name = getValue< Name >( syn_model_t );
    const Token synmodel = synapsedict_->lookup( synmodel_name );
    if ( !synmodel.empty() )
      syn_id = static_cast< size_t >( synmodel );
    else
      throw UnknownModelName( synmodel_name.toString() );
    get_connections( connectome, source_a, target_a, syn_id );
  }
  else
  {
    for ( syn_id = 0; syn_id < prototypes_[ 0 ].size(); ++syn_id )
    {
      ArrayDatum conn;
      get_connections( conn, source_a, target_a, syn_id );
      if ( conn.size() > 0 )
        connectome.push_back( new ArrayDatum( conn ) );
    }
  }

  return connectome;
}
开发者ID:zifeo,项目名称:nest-simulator,代码行数:50,代码来源:connection_manager.cpp

示例5: set_status

   /**
   * Set properties of this connection from position p in the properties
   * array given in dictionary.
   */
  void STDPRSNNSpikePairingConnectionHom::set_status(const DictionaryDatum & d, index p, ConnectorModel &cm)
  {
    ConnectionHetWD::set_status(d, p, cm);

     if (d->known("tau_pluss") ||
         d->known("lambds") ||
         d->known("alphas") ||
         d->known("mu_pluss") ||
         d->known("mu_minuss") ||
         d->known("Wmaxs") )
     {
       cm.network().message(SLIInterpreter::M_ERROR, "STDPRSNNSpikePairingConnectionHom::set_status()", "you are trying to set common properties via an individual synapse.");
     }
  }
开发者ID:QJonny,项目名称:CyNest,代码行数:18,代码来源:stdp_connection_rsnn_spikepairing_hom.cpp

示例6:

void
nest::weight_recorder::Parameters_::set( const DictionaryDatum& d )
{
  if ( d->known( names::senders ) )
  {
    senders_ = getValue< std::vector< long > >( d->lookup( names::senders ) );
    std::sort( senders_.begin(), senders_.end() );
  }

  if ( d->known( names::targets ) )
  {
    targets_ = getValue< std::vector< long > >( d->lookup( names::targets ) );
    std::sort( targets_.begin(), targets_.end() );
  }
}
开发者ID:apeyser,项目名称:nest-simulator,代码行数:15,代码来源:weight_recorder.cpp

示例7: get_children

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;
}
开发者ID:healther,项目名称:nest-simulator,代码行数:31,代码来源:nest.cpp

示例8: register_rng

void
register_rng( const std::string& name, DictionaryDatum& dict )
{
  Token rngfactory =
    new librandom::RngFactoryDatum( new librandom::BuiltinRNGFactory< NumberGenerator > );
  dict->insert_move( Name( name ), rngfactory );
}
开发者ID:JanneM,项目名称:nest-simulator,代码行数:7,代码来源:randomtest.cpp

示例9: BadProperty

void
nest::sinusoidal_poisson_generator::Parameters_::set( const DictionaryDatum& d,
  const sinusoidal_poisson_generator& n )
{
  if ( not n.is_model_prototype()
    && d->known( names::individual_spike_trains ) )
  {
    throw BadProperty(
      "The individual_spike_trains property can only be set as"
      " a model default using SetDefaults or upon CopyModel." );
  }

  updateValue< bool >(
    d, names::individual_spike_trains, individual_spike_trains_ );

  if ( updateValue< double >( d, names::rate, rate_ ) )
  {
    rate_ /= 1000.0; // scale to ms^-1
  }

  if ( updateValue< double >( d, names::frequency, om_ ) )
  {
    om_ *= 2.0 * numerics::pi / 1000.0;
  }

  if ( updateValue< double >( d, names::phase, phi_ ) )
  {
    phi_ *= numerics::pi / 180.0;
  }

  if ( updateValue< double >( d, names::amplitude, amplitude_ ) )
  {
    amplitude_ /= 1000.0;
  }
}
开发者ID:branbrain,项目名称:nest-simulator,代码行数:35,代码来源:sinusoidal_poisson_generator.cpp

示例10:

void
nest::spin_detector::set_status( const DictionaryDatum& d )
{
  if ( d->known( names::precise_times ) )
    user_set_precise_times_ = true;

  device_.set_status( d );
}
开发者ID:gewaltig,项目名称:nest-simulator,代码行数:8,代码来源:spin_detector.cpp

示例11: set_status_base

  void Node::set_status_base(const DictionaryDatum &dict)
  {
    assert(dict.valid());

    // We call the child's set_status first, so that the Node remains
    // unchanged if the child should throw an exception.
    set_status(dict);

    if(dict->known(names::frozen))
    {
      bool frozen_val=(*dict)[names::frozen];

      if( frozen_val == true )
	set(frozen);
      else
	unset(frozen);
    }
  }
开发者ID:kukin-konstantin,项目名称:nest_learning_models,代码行数:18,代码来源:node.cpp

示例12: get_status_dict_

DictionaryDatum
Node::get_status_base()
{
  DictionaryDatum dict = get_status_dict_();

  assert( dict.valid() );

  // add information available for all nodes
  ( *dict )[ names::local ] = is_local();
  ( *dict )[ names::model ] = LiteralDatum( get_name() );

  // add information available only for local nodes
  if ( is_local() )
  {
    ( *dict )[ names::global_id ] = get_gid();
    ( *dict )[ names::frozen ] = is_frozen();
    ( *dict )[ names::node_uses_wfr ] = node_uses_wfr();
    ( *dict )[ names::thread ] = get_thread();
    ( *dict )[ names::vp ] = get_vp();
    if ( parent_ )
    {
      ( *dict )[ names::parent ] = parent_->get_gid();

      // LIDs are only sensible for nodes with parents.
      // Add 1 as we count lids internally from 0, but from
      // 1 in the user interface.
      ( *dict )[ names::local_id ] = get_lid() + 1;
    }
  }

  ( *dict )[ names::thread_local_id ] = get_thread_lid();
  ( *dict )[ names::supports_precise_spikes ] = is_off_grid();

  // This is overwritten with a corresponding value in the
  // base classes for stimulating and recording devices, and
  // in other special node classes
  ( *dict )[ names::element_type ] = LiteralDatum( names::neuron );

  // now call the child class' hook
  get_status( dict );

  assert( dict.valid() );
  return dict;
}
开发者ID:branbrain,项目名称:nest-simulator,代码行数:44,代码来源:node.cpp

示例13: get_connections

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;
}
开发者ID:healther,项目名称:nest-simulator,代码行数:11,代码来源:nest.cpp

示例14: idx

void
nest::iaf_cond_alpha_mc::State_::set( const DictionaryDatum& d, const Parameters_& )
{
  // extract from sub-dictionaries
  for ( size_t n = 0; n < NCOMP; ++n )
    if ( d->known( comp_names_[ n ] ) )
    {
      DictionaryDatum dd = getValue< DictionaryDatum >( d, comp_names_[ n ] );
      updateValue< double >( dd, names::V_m, y_[ idx( n, V_M ) ] );
    }
}
开发者ID:gewaltig,项目名称:nest-simulator,代码行数:11,代码来源:iaf_cond_alpha_mc.cpp

示例15:

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: " );
}
开发者ID:golosio,项目名称:nest-simulator,代码行数:12,代码来源:model_manager.cpp


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