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 std::shared_ptr<::Constraints::Constraints> m_handle;
46 std::unique_ptr<VariantMap> m_params;
47
48 bool has_in_core(std::shared_ptr<Constraint> const &obj_ptr) const override {
49 return m_handle->contains(obj_ptr->constraint());
50 }
51 void add_in_core(std::shared_ptr<Constraint> const &obj_ptr) override {
52 m_handle->add(obj_ptr->constraint());
53 obj_ptr->bind_system(m_system.lock());
54 }
55 void remove_in_core(std::shared_ptr<Constraint> const &obj_ptr) override {
56 m_handle->remove(obj_ptr->constraint());
57 }
58
59 void do_construct(VariantMap const &params) override {
60 m_handle = std::make_shared<::Constraints::Constraints>();
61 m_handle->bind_system(::System::get_system().shared_from_this());
62 m_params = std::make_unique<VariantMap>(params);
63 }
64
65 void on_bind_system(::System::System &system) override {
66 m_handle = system.constraints;
67 m_handle->bind_system(m_system.lock());
68 Base::do_construct(*m_params);
69 m_params.reset();
70 }
71};
72
73} // namespace Constraints
74} // namespace ScriptInterface
void add_in_core(std::shared_ptr< Constraint > const &obj_ptr) override
void remove_in_core(std::shared_ptr< Constraint > const &obj_ptr) override
bool has_in_core(std::shared_ptr< Constraint > const &obj_ptr) const override
Owning list of ObjectHandles.
void do_construct(VariantMap const &params) override
Script interface wrapper for a component of the system class.
Main system class.
std::shared_ptr< Constraints::Constraints > constraints
ObjectList< Constraint, AutoParameters< ObjectList< Constraint, System::Leaf >, System::Leaf > > Constraints_t
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:69
System & get_system()
static SteepestDescentParameters params
Currently active steepest descent instance.