![]() |
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
|
Owning map of object handles. More...
#include <ObjectMap.hpp>
Public Types | |
using | Base = ObjectContainer< ObjectMap, ManagedType, BaseType > |
using | key_type = KeyType |
using | mapped_type = std::shared_ptr< ManagedType > |
using | container_type = std::unordered_map< key_type, mapped_type > |
Public Member Functions | |
ObjectMap () | |
~ObjectMap () override | |
void | do_construct (VariantMap const ¶ms) override=0 |
void | insert (key_type const &key, mapped_type const &element) |
Add an element to the map. | |
key_type | insert (mapped_type const &element) |
Add an element to the map. | |
void | erase (key_type const &key) |
Removes all occurrences of an element from the map. | |
auto const & | elements () const |
Map elements. | |
void | clear () |
Clear the map. | |
Protected Member Functions | |
void | do_destruct () |
Variant | do_call_method (std::string const &method, VariantMap const ¶meters) override |
void | restore_from_checkpoint (VariantMap const ¶ms) |
key_type | get_key (Variant const &key) const |
Private Member Functions | |
virtual key_type | insert_in_core (mapped_type const &obj_ptr)=0 |
virtual void | insert_in_core (key_type const &key, mapped_type const &obj_ptr)=0 |
virtual void | erase_in_core (key_type const &key)=0 |
Owning map of object handles.
Mapped elements are cleared from the core during destruction. Due to how dynamic dispatch works, derived types must mark erase_in_core as final`
and call do_destruct in their virtual destructor. This is to ensure that pure virtual functions called by clear cannot be executed in a type derived from the type currently being destructed, since derived types no longer exist at this point of the destruction sequence.
ManagedType | Type of the managed objects, needs to be derived from ObjectHandle |
Definition at line 52 of file ObjectMap.hpp.
using ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::Base = ObjectContainer<ObjectMap, ManagedType, BaseType> |
Definition at line 54 of file ObjectMap.hpp.
using ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::container_type = std::unordered_map<key_type, mapped_type> |
Definition at line 58 of file ObjectMap.hpp.
using ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::key_type = KeyType |
Definition at line 56 of file ObjectMap.hpp.
using ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::mapped_type = std::shared_ptr<ManagedType> |
Definition at line 57 of file ObjectMap.hpp.
|
inline |
Definition at line 77 of file ObjectMap.hpp.
References ScriptInterface::make_unordered_map_of_variants(), and ScriptInterface::AutoParameter::read_only.
|
inlineoverride |
Definition at line 84 of file ObjectMap.hpp.
References ScriptInterface::get_value().
|
inline |
Clear the map.
Definition at line 130 of file ObjectMap.hpp.
References ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::erase_in_core().
Referenced by ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::do_call_method(), and ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::do_destruct().
|
inlineoverrideprotected |
Definition at line 139 of file ObjectMap.hpp.
References ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::clear(), ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::erase(), ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::get_key(), ScriptInterface::get_value(), ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::insert(), ScriptInterface::make_unordered_map_of_variants(), and ScriptInterface::none.
Referenced by ScriptInterface::BondBreakage::BreakageSpecs::do_call_method(), and ScriptInterface::Interactions::BondedInteractions::do_call_method().
|
overridepure virtual |
|
inlineprotected |
Definition at line 70 of file ObjectMap.hpp.
References ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::clear(), and ScriptInterface::get_value().
Referenced by ScriptInterface::Interactions::BondedInteractions::~BondedInteractions(), and ScriptInterface::BondBreakage::BreakageSpecs::~BreakageSpecs().
|
inline |
Map elements.
Definition at line 125 of file ObjectMap.hpp.
Referenced by ScriptInterface::Interactions::BondedInteractions::do_call_method().
|
inline |
Removes all occurrences of an element from the map.
key | Identifier of the element to remove. |
Definition at line 117 of file ObjectMap.hpp.
References ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::erase_in_core(), and ScriptInterface::get_value().
Referenced by ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::do_call_method().
|
privatepure virtual |
|
inlineprotected |
Definition at line 203 of file ObjectMap.hpp.
References ScriptInterface::get_value().
Referenced by ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::do_call_method(), and ScriptInterface::Interactions::BondedInteractions::do_call_method().
|
inline |
Add an element to the map.
key | Identifier of the element to add. |
element | The element to add. |
Definition at line 95 of file ObjectMap.hpp.
References ScriptInterface::get_value(), and ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::insert_in_core().
Referenced by ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::do_call_method().
|
inline |
Add an element to the map.
A free key is generated automatically.
element | The element to add. |
Definition at line 106 of file ObjectMap.hpp.
References ScriptInterface::get_value(), and ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::insert_in_core().
|
privatepure virtual |
|
privatepure virtual |
Implemented in ScriptInterface::BondBreakage::BreakageSpecs, and ScriptInterface::Interactions::BondedInteractions.
Referenced by ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::insert(), ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::insert(), and ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::restore_from_checkpoint().
|
inlineprotected |
Definition at line 196 of file ObjectMap.hpp.
References ScriptInterface::get_value(), ScriptInterface::ObjectMap< ManagedType, BaseType, KeyType >::insert_in_core(), and params.
Referenced by ScriptInterface::BondBreakage::BreakageSpecs::do_construct(), and ScriptInterface::Interactions::BondedInteractions::on_bind_system().