ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/PidObservable.hpp
Go to the documentation of this file.
1
2
/*
3
* Copyright (C) 2010-2022 The ESPResSo project
4
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
5
* Max-Planck-Institute for Polymer Research, Theory Group
6
*
7
* This file is part of ESPResSo.
8
*
9
* ESPResSo is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
13
*
14
* ESPResSo is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
*/
22
23
#ifndef SCRIPT_INTERFACE_OBSERVABLES_PIDOBSERVABLE_HPP
24
#define SCRIPT_INTERFACE_OBSERVABLES_PIDOBSERVABLE_HPP
25
26
#include "
script_interface/ScriptInterface.hpp
"
27
#include "
script_interface/auto_parameters/AutoParameters.hpp
"
28
29
#include "
Observable.hpp
"
30
#include "
core/observables/PidObservable.hpp
"
31
32
#include <memory>
33
#include <type_traits>
34
#include <vector>
35
36
namespace
ScriptInterface
{
37
namespace
Observables
{
38
39
/** Base class for script interfaces to particle-based observables
40
* @tparam CorePidObs Any core class derived from @ref
41
* ::Observables::PidObservable "Observables::PidObservable"
42
*/
43
template
<
typename
CoreP
id
Obs>
44
class
PidObservable
45
:
public
AutoParameters
<PidObservable<CorePidObs>, Observable> {
46
public
:
47
static_assert
(std::is_base_of_v<::Observables::PidObservable, CorePidObs>);
48
49
PidObservable
() {
50
this->
add_parameters
({{
"ids"
,
AutoParameter::read_only
,
51
[
this
]() {
return
m_observable->ids(); }}});
52
}
53
54
void
do_construct
(
VariantMap
const
&
params
)
override
{
55
ObjectHandle::context
()->
parallel_try_catch
([&]() {
56
m_observable =
57
make_shared_from_args<CorePidObs, std::vector<int>
>(
params
,
"ids"
);
58
});
59
}
60
61
std::shared_ptr<::Observables::Observable>
observable
()
const override
{
62
return
m_observable;
63
}
64
65
private
:
66
std::shared_ptr<CorePidObs> m_observable;
67
};
68
69
}
/* namespace Observables */
70
}
/* namespace ScriptInterface */
71
72
#endif
AutoParameters.hpp
ScriptInterface.hpp
ScriptInterface::AutoParameters
Bind parameters in the script interface.
Definition
AutoParameters.hpp:93
ScriptInterface::AutoParameters< PidObservable< CorePidObs >, Observable >::add_parameters
void add_parameters(std::vector< AutoParameter > &¶ms)
Definition
AutoParameters.hpp:115
ScriptInterface::Context::parallel_try_catch
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
ScriptInterface::ObjectHandle::context
Context * context() const
Responsible context.
Definition
ObjectHandle.hpp:58
ScriptInterface::Observables::PidObservable
Base class for script interfaces to particle-based observables.
Definition
script_interface/observables/PidObservable.hpp:45
ScriptInterface::Observables::PidObservable::do_construct
void do_construct(VariantMap const ¶ms) override
Definition
script_interface/observables/PidObservable.hpp:54
ScriptInterface::Observables::PidObservable::observable
std::shared_ptr<::Observables::Observable > observable() const override
Definition
script_interface/observables/PidObservable.hpp:61
ScriptInterface::Observables::PidObservable::PidObservable
PidObservable()
Definition
script_interface/observables/PidObservable.hpp:49
PidObservable.hpp
Observables
Definition
BondAngles.hpp:36
ScriptInterface
Definition
script_interface/accumulators/AccumulatorBase.hpp:33
ScriptInterface::get_value
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
Definition
get_value.hpp:400
ScriptInterface::VariantMap
std::unordered_map< std::string, Variant > VariantMap
Definition
Variant.hpp:69
Observable.hpp
params
static SteepestDescentParameters params
Currently active steepest descent instance.
Definition
steepest_descent.cpp:44
ScriptInterface::AutoParameter::read_only
static constexpr const ReadOnly read_only
Definition
AutoParameter.hpp:42
src
script_interface
observables
PidObservable.hpp
Generated on Fri Nov 22 2024 02:13:54 for ESPResSo by
1.9.8