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 std::shared_ptr<::Accumulators::AutoUpdateAccumulators> m_handle;
44 std::unique_ptr<VariantMap> m_params;
45
46 bool
47 has_in_core(std::shared_ptr<AccumulatorBase> const &obj_ptr) const override {
48 return m_handle->contains(obj_ptr->accumulator().get());
49 }
50
51 void add_in_core(std::shared_ptr<AccumulatorBase> const &obj_ptr) override {
52 m_handle->add(obj_ptr->accumulator().get());
53 }
54
55 void
56 remove_in_core(std::shared_ptr<AccumulatorBase> const &obj_ptr) override {
57 m_handle->remove(obj_ptr->accumulator().get());
58 }
59
60 void do_construct(VariantMap const &params) override {
61 m_params = std::make_unique<VariantMap>(params);
62 }
63
65 m_handle = system.auto_update_accumulators;
66 m_handle->bind_system(m_system.lock());
67 Base::do_construct(*m_params);
68 m_params.reset();
69 }
70};
71} /* namespace Accumulators */
72} /* namespace ScriptInterface */
bool has_in_core(std::shared_ptr< AccumulatorBase > const &obj_ptr) const override
void add_in_core(std::shared_ptr< AccumulatorBase > const &obj_ptr) override
void remove_in_core(std::shared_ptr< AccumulatorBase > const &obj_ptr) override
Bind parameters in the script interface.
Owning list of ObjectHandles.
void do_construct(VariantMap const &params) override
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.