Value.h
1 /*
2  * MoMEMta: a modular proxy of the Matrix Element Method
3  * Copyright (C) 2016 Universite catholique de Louvain (UCL), Belgium
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <momemta/impl/ValueProxy_fwd.h>
22 
29 template <typename T>
30 class Value {
31 public:
32 
33  Value() = default;
34  Value(const Value&) = default;
35  Value(Value&&) = default;
36  Value<T>& operator=(const Value<T>&) = default;
37 
38  const T& operator*() {
39  return proxy->operator*();
40  }
41 
42  const T& operator*() const {
43  return proxy->operator*();
44  }
45 
46  const T* operator->() {
47  return proxy->operator->();
48  }
49 
50  const T* operator->() const {
51  return proxy->operator->();
52  }
53 
54  const T* get() {
55  return proxy->get();
56  }
57 
58 private:
59  friend class Pool;
60 
61  // Only Pool can create a Value
62  Value(std::shared_ptr<ValueProxy<const T>> impl) {
63  proxy = impl;
64  }
65 
66  std::shared_ptr<ValueProxy<const T>> proxy;
67 };
Definition: Pool.h:40
A class representing a value produced by a module.
Definition: Value.h:30