32#include <unordered_map>
46 using Base::add_parameters;
49 std::unordered_map<KeyType, std::shared_ptr<ManagedType>> m_elements;
54 std::shared_ptr<ManagedType>
const &
obj_ptr) = 0;
75 m_elements[
key] = element;
86 m_elements[
key] = element;
97 m_elements.erase(
key);
103 auto const &
elements()
const {
return m_elements; }
109 for (
auto const &kv : m_elements) {
143 if (
method ==
"get_map") {
148 std::vector<Variant>
res;
149 for (
auto const &kv : m_elements) {
150 res.push_back(kv.first);
161 return static_cast<int>(m_elements.size());
165 return m_elements.empty();
168 if (
method ==
"contains") {
177 for (
auto const &[
key, element] : m_elements) {
186 using namespace detail::demangle;
187 auto const actual = simplify_symbol_variant(
key);
188 auto const target = simplify_symbol(
static_cast<KeyType *
>(
nullptr));
189 if (Base::context()->is_head_node()) {
190 throw std::invalid_argument(
"Key has to be of type '" +
target +
191 "', got type '" +
actual +
"'");
Owning map of ObjectHandles.
void insert(KeyType const &key, std::shared_ptr< ManagedType > const &element)
Add an element to the map.
virtual KeyType insert_in_core(std::shared_ptr< ManagedType > const &obj_ptr)=0
ObjectContainer< ObjectMap, ManagedType, BaseType > Base
void clear()
Clear the map.
virtual void insert_in_core(KeyType const &key, std::shared_ptr< ManagedType > const &obj_ptr)=0
KeyType get_key(Variant const &key) const
KeyType insert(std::shared_ptr< ManagedType > const &element)
Add an element to the map.
void do_construct(VariantMap const ¶ms) override=0
auto const & elements() const
Map elements.
void restore_from_checkpoint(VariantMap const ¶ms)
void erase(KeyType const &key)
Removes all occurrences of an element from the map.
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
virtual void erase_in_core(KeyType const &key)=0
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
auto make_unordered_map_of_variants(std::unordered_map< K, V > const &v)
std::conditional_t< std::is_same_v< BaseType, ObjectHandle >, AutoParameters< Container< ManagedType, BaseType >, BaseType >, BaseType > ObjectContainer
Base class for containers whose BaseType might be a full specialization of AutoParameters.
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
constexpr const None none
None-"literal".
static SteepestDescentParameters params
Currently active steepest descent instance.
static constexpr const ReadOnly read_only