NEST main@caf0ae8
 
Loading...
Searching...
No Matches

Dictionary class for interface to Python and C++ API. More...

#include <dictionary.h>

Inheritance diagram for Dictionary:
[legend]
Collaboration diagram for Dictionary:
[legend]

Public Member Functions

 Dictionary ()
 
any_type & operator[] (const std::string &key)
 
any_type & operator[] (std::string &&key)
 
any_type & at (const std::string &key)
 
const any_type & at (const std::string &key) const
 
bool operator== (const Dictionary &other) const
 Check whether the dictionary is equal to another dictionary.
 
auto begin () const
 
auto end () const
 
auto size () const
 
auto empty () const
 
void clear ()
 
auto find (const std::string &key) const
 
bool known (const std::string &key) const
 Check whether there exists a value with specified key in the dictionary.
 
void mark_as_accessed (const std::string &key) const
 Mark to support checking for unaccessed entries.
 
bool has_been_accessed (const std::string &key) const
 Return true if mark_as_accessed has been called at least once for key.
 
void init_access_flags (const bool thread_local_dict=false) const
 Initialize access flags to prepare for later error checking with all_entries_accessed.
 
void all_entries_accessed (const std::string &where, const std::string &what, const bool thread_local_dict=false) const
 Confirm that all entries in dictionary have been accessed.
 
template<DictionaryEntryType T>
T get (const std::string &key) const
 Get the value at key in the specified type.
 
template<typename T >
std::vector< T > & get_or_create_vector (const std::string &key)
 Return reference to vector of type T stored under key.
 
template<typename T >
bool update_value (const std::string &key, T &value) const
 Update the specified non-vector value if there exists a value at key.
 
template<Integer T>
bool update_integer_value (const std::string &key, T &value) const
 Update the specified value if there exists an integer value at key.
 
bool update_dictionary (Dictionary &dict_out) const
 Update the provided dictionary with all key-value pairs in this dictionary.
 

Detailed Description

Dictionary class for interface to Python and C++ API.

Only this class should be used in code outside dictionary.{h,cpp}.

Methods that behave as in std::map are not documented explicitly.

Constructor & Destructor Documentation

◆ Dictionary()

Dictionary::Dictionary ( )
inline

Member Function Documentation

◆ all_entries_accessed()

void Dictionary::all_entries_accessed ( const std::string &  where,
const std::string &  what,
const bool  thread_local_dict = false 
) const
inline

Confirm that all entries in dictionary have been accessed.

Requires that init_access_flags has been called previously and does nothing if dict_miss_is_error has been set to false.

Exceptions

ref nest::UnaccessedDictionaryEntry if at least one dictionary entry has not been marked as accessed

Parameters
whereInformation about calling location, will be included in error message
whatInformation about dictionary inspected, will be included in error message
thread_local_dictPass true if calling this method on a thread-specific dictionary. Used for internal error checking (assert).

Referenced by nest::cm_default::add_compartment_(), nest::cm_default::add_receptor_(), nest::CompartmentCurrents::add_synapse(), nest::Compartment::Compartment(), nest::ConnectionManager::connect(), nest::connect_layers(), nest::ConnectionManager::connect_tripartite(), nest::ConnectionCreator::ConnectionCreator(), nest::create_layer(), nest::create_mask(), nest::create_parameter(), nest::SPManager::disconnect(), nest::get_connections(), nest::set_connection_status(), and nest::set_kernel_status().

Here is the caller graph for this function:

◆ at() [1/2]

◆ at() [2/2]

const any_type & Dictionary::at ( const std::string &  key) const

◆ begin()

auto Dictionary::begin ( ) const
inline

Referenced by nest::create_parameter(), and operator<<().

Here is the caller graph for this function:

◆ clear()

void Dictionary::clear ( )
inline

Referenced by nest::ModelManager::clear_connection_models_(), nest::ModelManager::clear_node_models_(), nest::ConnectionManager::finalize(), nest::SPManager::finalize(), nest::RecordingDevice::set_status(), and nest::StimulationDevice::set_status().

Here is the caller graph for this function:

◆ empty()

auto Dictionary::empty ( ) const
inline

Referenced by nest::NodeManager::get_nodes().

Here is the caller graph for this function:

◆ end()

auto Dictionary::end ( ) const
inline

Referenced by nest::get_nc_status(), and operator<<().

Here is the caller graph for this function:

◆ find()

auto Dictionary::find ( const std::string &  key) const
inline

Referenced by nest::ConnectionManager::connect_arrays(), and nest::get_nc_status().

Here is the caller graph for this function:

◆ get()

template<DictionaryEntryType T>
T Dictionary::get ( const std::string &  key) const
inline

Get the value at key in the specified type.

Template Parameters
TType of the value. If the value is not of the specified type, a TypeMismatch error is thrown.
Parameters
keykey where the value is located in the dictionary.
Exceptions

c std::out_of_range if key is not on dictionary

Exceptions

ref TypeMismatch if the value is not of specified type T.

Returns
the value at key cast to the specified type.

Referenced by nest::cm_default::add_compartment_(), nest::cm_default::add_receptor_(), nest::AMPA::AMPA(), nest::AMPA_NMDA::AMPA_NMDA(), nest::BernoulliBuilder::BernoulliBuilder(), nest::ConnectionManager::connect(), nest::ConnectionManager::connect_tripartite(), nest::ConnectionCreator::ConnectionCreator(), nest::ModelManager::copy_model(), nest::AbstractLayer::create_layer(), nest::create_mask(), nest::create_parameter(), nest::SPManager::disconnect(), nest::Layer< D >::dump_connections(), nest::ConnectionCreator::extract_params_(), nest::FixedInDegreeBuilder::FixedInDegreeBuilder(), nest::FixedOutDegreeBuilder::FixedOutDegreeBuilder(), nest::GABA::GABA(), nest::ConnectionManager::get_conn_builder(), nest::ModelManager::get_node_model_id(), nest::StructuralPlasticityNode::get_status(), nest::ModelManager::get_synapse_model_id(), nest::ConnectionManager::get_third_conn_builder(), nest::K::K(), nest::Na::Na(), nest::SPManager::new_growth_curve(), nest::NMDA::NMDA(), nest::PoissonBuilder::PoissonBuilder(), nest::ModelManager::set_model_defaults(), nest::cm_default::set_status(), nest::SPManager::set_status(), nest::StructuralPlasticityNode::set_status(), nest::BipartiteConnBuilder::set_structural_plasticity_parameters(), nest::BipartiteConnBuilder::set_synapse_model_(), and nest::SPBuilder::update_delay().

Here is the caller graph for this function:

◆ get_or_create_vector()

template<typename T >
std::vector< T > & Dictionary::get_or_create_vector ( const std::string &  key)

Return reference to vector of type T stored under key.

If key does not exist in dict, create empty vector<T> and return it.

◆ has_been_accessed()

bool Dictionary::has_been_accessed ( const std::string &  key) const
inline

Return true if mark_as_accessed has been called at least once for key.

Todo:
Should be removed, see #3791

Referenced by nest::RecordingDevice::set_status(), and nest::StimulationDevice::set_status().

Here is the caller graph for this function:

◆ init_access_flags()

void Dictionary::init_access_flags ( const bool  thread_local_dict = false) const
inline

Initialize access flags to prepare for later error checking with all_entries_accessed.

Parameters
thread_local_dictPass true if calling this method on a thread-specific dictionary. Used for internal error checking (assert).

Referenced by nest::cm_default::add_compartment_(), nest::cm_default::add_receptor_(), nest::CompartmentCurrents::add_synapse(), nest::Compartment::Compartment(), nest::ConnectionManager::connect(), nest::connect_layers(), nest::ConnectionManager::connect_tripartite(), nest::create_layer(), nest::create_mask(), nest::create_parameter(), nest::SPManager::disconnect(), nest::get_connections(), nest::set_connection_status(), and nest::set_kernel_status().

Here is the caller graph for this function:

◆ known()

bool Dictionary::known ( const std::string &  key) const
inline

Check whether there exists a value with specified key in the dictionary.

Parameters
keykey where the value may be located in the dictionary.
Returns
true if there is a value with the specified key, false if not.
Note
This does not mark the entry as accessed, because we sometimes need to confirm that a certain key is not in a dictionary.

Referenced by nest::cm_default::add_compartment_(), nest::cm_default::add_receptor_(), nest::AMPA::AMPA(), nest::AMPA_NMDA::AMPA_NMDA(), nest::cont_delay_synapse< targetidentifierT >::check_synapse_params(), nest::stdp_dopamine_synapse< targetidentifierT >::check_synapse_params(), nest::static_synapse_hom_w< targetidentifierT >::check_synapse_params(), nest::GenericConnectorModel< ConnectionT >::check_synapse_params(), nest::ConnectionManager::connect(), nest::ConnectionManager::connect_tripartite(), nest::ConnectionCreator::ConnectionCreator(), nest::ModelManager::copy_model(), nest::AbstractLayer::create_layer(), nest::SPManager::disconnect(), nest::ConnectionCreator::extract_params_(), nest::GABA::GABA(), nest::ConnectionManager::get_conn_builder(), nest::ModelManager::get_node_model_id(), nest::NodeManager::get_nodes(), nest::ModelManager::get_synapse_model_id(), nest::ConnectionManager::get_third_conn_builder(), nest::K::K(), nest::Na::Na(), nest::NMDA::NMDA(), nest::ConnectionManager::register_conn_builder(), nest::SPManager::register_growth_curve(), nest::ModelManager::register_node_model(), nest::ModelManager::register_specific_connection_model_(), nest::ConnectionManager::register_third_conn_builder(), nest::BipartiteConnBuilder::set_default_weight_or_delay_(), nest::ModelManager::set_model_defaults(), nest::cm_default::set_status(), nest::StructuralPlasticityNode::set_status(), nest::BipartiteConnBuilder::set_structural_plasticity_parameters(), nest::BipartiteConnBuilder::set_synapse_model_(), nest::BipartiteConnBuilder::set_synapse_params(), and nest::ConnectionManager::valid_connection_rule().

Here is the caller graph for this function:

◆ mark_as_accessed()

void Dictionary::mark_as_accessed ( const std::string &  key) const
inline

Mark to support checking for unaccessed entries.

Todo:
Should be removed, see #3791

◆ operator==()

bool Dictionary::operator== ( const Dictionary &  other) const
inline

Check whether the dictionary is equal to another dictionary.

Two dictionaries are equal if and only if they contain the exact same entries with the same values.

Parameters
otherdictionary to check against.
Returns
true if the dictionary is equal to the other dictionary, false if not.

◆ operator[]() [1/2]

any_type & Dictionary::operator[] ( const std::string &  key)

◆ operator[]() [2/2]

any_type & Dictionary::operator[] ( std::string &&  key)

◆ size()

auto Dictionary::size ( ) const
inline

Referenced by nest::create_parameter(), nest::get_nc_status(), and nest::slice_nc().

Here is the caller graph for this function:

◆ update_dictionary()

bool Dictionary::update_dictionary ( Dictionary &  dict_out) const
inline

Update the provided dictionary with all key-value pairs in this dictionary.

Parameters
dict_outthe dictionary to be updated.
Returns
true if any values were updated in or added to dict_out .

Referenced by nest::StimulationDevice::get_status().

Here is the caller graph for this function:

◆ update_integer_value()

template<Integer T>
bool Dictionary::update_integer_value ( const std::string &  key,
T &  value 
) const
inline

Update the specified value if there exists an integer value at key.

Parameters
keykey where the value may be located in the dictionary.
valueobject to update if there exists a value at key.
Exceptions
TypeMismatchif the value at key is not an integer.
Returns
true if key was found in dictionary and value was updated, else false

◆ update_value()

template<typename T >
bool Dictionary::update_value ( const std::string &  key,
T &  value 
) const
inline

Update the specified non-vector value if there exists a value at key.

Parameters
keykey where the value may be located in the dictionary.
valueobject to update if there exists a value at key.
Exceptions
TypeMismatchif the value at key is not the same type as the value argument.
Returns
true if key was found in dictionary and value was updated, else false
Note
Only use this where the user is not allowed to use random or spatial parameters. Otherwise, use update_value_param .

Referenced by nest::BipartiteConnBuilder::BipartiteConnBuilder(), nest::Compartment::Compartment(), nest::ConnectionCreator::ConnectionCreator(), nest::IOManager::set_data_path_prefix_(), nest::cm_default::set_status(), nest::EventDeliveryManager::set_status(), nest::LoggingManager::set_status(), nest::MPIManager::set_status(), nest::EpropSynapseCommonProperties::set_status(), nest::EpropSynapseBSSHSLM2020CommonProperties::set_status(), nest::Node::set_status_base(), and nest::ThirdBernoulliWithPoolBuilder::ThirdBernoulliWithPoolBuilder().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: