ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/accumulators/AutoUpdateAccumulators.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "AccumulatorBase.hpp"
23
26
31
32#include <memory>
33
34namespace ScriptInterface {
35namespace Accumulators {
36
40
43 using value_type = typename Base::value_type;
44
45 std::shared_ptr<::Accumulators::AutoUpdateAccumulators> m_handle;
46 std::unique_ptr<VariantMap> m_params;
47
48 bool has_in_core(value_type const &obj_ptr) const override {
49 return m_handle->contains(obj_ptr->accumulator().get());
50 }
51
52 void add_in_core(value_type const &obj_ptr) override {
53 m_handle->add(obj_ptr->accumulator().get());
54 }
55
56 void remove_in_core(value_type const &obj_ptr) final {
57 m_handle->remove(obj_ptr->accumulator().get());
58 }
59
60public:
62
63 void do_construct(VariantMap const &params) override {
64 m_params = std::make_unique<VariantMap>(params);
65 }
66
67private:
69 m_handle = system.auto_update_accumulators;
70 m_handle->bind_system(m_system.lock());
71 Base::do_construct(*m_params);
72 m_params.reset();
73 }
74};
75} /* namespace Accumulators */
76} /* namespace ScriptInterface */
Bind parameters in the script interface.
Owning list of object handles.
void do_construct(VariantMap const &params) override
std::shared_ptr< ManagedType > value_type
Script interface wrapper for a component of the system class.
Main system class.
ObjectList< AccumulatorBase, AutoParameters< ObjectList< AccumulatorBase, System::Leaf >, System::Leaf > > AutoUpdateAccumulators_t
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:69
static SteepestDescentParameters params
Currently active steepest descent instance.