ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
BreakageSpecs.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 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 "BreakageSpec.hpp"
23
25
29
30#include <memory>
31#include <stdexcept>
32#include <unordered_map>
33
34namespace ScriptInterface {
35namespace BondBreakage {
36
38 : public ObjectMap<
39 BreakageSpec,
40 AutoParameters<ObjectMap<BreakageSpec, System::Leaf>, System::Leaf>> {
41 using container_type = std::unordered_map<int, std::shared_ptr<BreakageSpec>>;
42
43public:
44 using key_type = typename container_type::key_type;
45 using mapped_type = typename container_type::mapped_type;
46
47private:
48 std::shared_ptr<::BondBreakage::BondBreakage> m_bond_breakage;
49
50 void do_construct(VariantMap const &params) override {
51 m_bond_breakage = std::make_shared<::BondBreakage::BondBreakage>();
53 }
54
56 system.bond_breakage = m_bond_breakage;
57 }
58
60 if (context()->is_head_node()) {
61 throw std::runtime_error(
62 "Inserting breakage spec without a bond type is not permitted.");
63 }
64 return {};
65 }
67 mapped_type const &obj_ptr) override {
68 m_bond_breakage->breakage_specs.emplace(key, obj_ptr->breakage_spec());
69 }
70 void erase_in_core(key_type const &key) override {
71 m_bond_breakage->breakage_specs.erase(key);
72 }
73};
74} // namespace BondBreakage
75} // namespace ScriptInterface
typename container_type::mapped_type mapped_type
void insert_in_core(key_type const &key, mapped_type const &obj_ptr) override
typename container_type::key_type key_type
key_type insert_in_core(mapped_type const &) override
void do_construct(VariantMap const &params) override
void erase_in_core(key_type const &key) override
void on_bind_system(::System::System &system) override
Owning map of ObjectHandles.
Definition ObjectMap.hpp:43
Main system class.
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.