ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/constraints/Constraints.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "Constraint.hpp"
25
30
33
34#include <memory>
35
36namespace ScriptInterface {
37namespace Constraints {
38
42
43class Constraints : public Constraints_t {
44 using Base = Constraints_t;
45 using value_type = typename Base::value_type;
46
47 std::shared_ptr<::Constraints::Constraints> m_handle;
48 std::unique_ptr<VariantMap> m_params;
49
50 bool has_in_core(value_type const &obj_ptr) const override {
51 return m_handle->contains(obj_ptr->constraint());
52 }
53 void add_in_core(value_type const &obj_ptr) override {
54 m_handle->add(obj_ptr->constraint());
55 obj_ptr->bind_system(m_system.lock());
56 }
57 void remove_in_core(value_type const &obj_ptr) final {
58 m_handle->remove(obj_ptr->constraint());
59 }
60
61public:
62 ~Constraints() override { do_destruct(); }
63
64 void do_construct(VariantMap const &params) override {
65 m_handle = std::make_shared<::Constraints::Constraints>();
66 m_handle->bind_system(::System::get_system().shared_from_this());
67 m_params = std::make_unique<VariantMap>(params);
68 }
69
70private:
72 m_handle = system.constraints;
73 m_handle->bind_system(m_system.lock());
74 Base::do_construct(*m_params);
75 m_params.reset();
76 }
77};
78
79} // namespace Constraints
80} // namespace ScriptInterface
bool has_in_core(value_type const &obj_ptr) const override
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< Constraint, AutoParameters< ObjectList< Constraint, System::Leaf >, System::Leaf > > Constraints_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
System & get_system()
static SteepestDescentParameters params
Currently active steepest descent instance.