43template <
typename ManagedType,
class BaseType = ObjectHandle>
47 using Base::add_parameters;
51 std::vector<std::shared_ptr<ManagedType>> m_elements;
68 for (
auto const &
object : m_elements) {
78 void add(std::shared_ptr<ManagedType>
const &element) {
80 if (Base::context()->is_head_node()) {
81 throw std::runtime_error(
"This object is already present in the list");
85 context()->parallel_try_catch([&]() {
add_in_core(element); });
86 m_elements.push_back(element);
94 void remove(std::shared_ptr<ManagedType>
const &element) {
96 if (Base::context()->is_head_node()) {
97 throw std::runtime_error(
"This object is absent from the list");
102 std::erase(m_elements, element);
108 auto const &
elements()
const {
return m_elements; }
114 for (
auto const &
e : m_elements) {
141 if (
method ==
"get_elements") {
151 return static_cast<int>(m_elements.size());
155 return m_elements.empty();
Owning list of ObjectHandles.
auto const & elements() const
List elements.
void add(std::shared_ptr< ManagedType > const &element)
Add an element to the list.
virtual bool has_in_core(const std::shared_ptr< ManagedType > &obj_ptr) const =0
void do_construct(VariantMap const ¶ms) override
void remove(std::shared_ptr< ManagedType > const &element)
Removes all occurrences of an element from the list.
void clear()
Clear the list.
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
virtual void remove_in_core(const std::shared_ptr< ManagedType > &obj_ptr)=0
ObjectContainer< ObjectList, ManagedType, BaseType > Base
virtual void add_in_core(const std::shared_ptr< ManagedType > &obj_ptr)=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_vector_of_variants(std::vector< T > 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