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 before_do_construct() override {
51 m_bond_breakage = std::make_shared<::BondBreakage::BondBreakage>();
52 }
53
54 void on_bind_system(::System::System &system) override {
55 system.bond_breakage = m_bond_breakage;
56 }
57
59 if (context()->is_head_node()) {
60 throw std::runtime_error(
61 "Inserting breakage spec without a bond type is not permitted.");
62 }
63 return {};
64 }
65 void insert_in_core(key_type const &key,
66 mapped_type const &obj_ptr) override {
67 m_bond_breakage->breakage_specs.emplace(key, obj_ptr->breakage_spec());
68 }
69 void erase_in_core(key_type const &key) override {
70 m_bond_breakage->breakage_specs.erase(key);
71 }
72};
73} // namespace BondBreakage
74} // 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 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.
std::shared_ptr< BondBreakage::BondBreakage > bond_breakage