ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
observable.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-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#ifndef SRC_PARTICLE_OBSERVABLES_OBSERVABLE_HPP
20#define SRC_PARTICLE_OBSERVABLES_OBSERVABLE_HPP
21
22#include "algorithms.hpp"
23#include "properties.hpp"
24
25namespace ParticleObservables {
26/**
27 * @brief Meta-Observable that returns the product of two
28 * other observables.
29 *
30 * The operand observables are stored by privately deriving
31 * from them to get the empty case optimization if they do
32 * not have state.
33 *
34 * @tparam Left left operand of the product.
35 * @tparam Right right operand of the product.
36 */
37template <class Left, class Right> struct Product : Left, Right {
38 Product(Left left = {}, Right right = {})
39 : Left(std::move(left)), Right(std::move(right)) {}
40
41 template <class Particle, class Traits = default_traits<Particle>>
42 decltype(auto) operator()(Particle const &p,
43 Traits const &traits = {}) const {
44 return Left::template operator()<Particle, Traits>(p, traits) *
45 Right::template operator()<Particle, Traits>(p, traits);
46 }
47};
48
62} // namespace ParticleObservables
63
64#endif // SRC_PARTICLE_OBSERVABLES_OBSERVABLE_HPP
Generic algorithms for the calculation of particle property derived observables.
This file contains interface functionality for extracting particle properties via a particle traits c...
Meta-Observable that returns the product of two other observables.
Product(Left left={}, Right right={})
Struct holding all information for one particle.
Definition Particle.hpp:395