author | František Kučera <franta-hg@frantovo.cz> |
Sun, 04 Jul 2021 11:51:13 +0200 | |
branch | v_0 |
changeset 27 | d9cc2d356cdb |
parent 24 | 114810ee2386 |
permissions | -rw-r--r-- |
24
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2021 František Kučera (Frantovo.cz, GlobalCode.info) |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
#pragma once |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
#include <memory> |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
|
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
namespace relpipe { |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
namespace in { |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
namespace asn1 { |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
namespace lib { |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
template <typename Class> |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
class ProxyVector : public std::vector<std::shared_ptr<Class>> { |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
public: |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
|
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
/** |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
* Call given method on all instances. |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
* |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
* @param method a method of Class |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
* @param arguments arguments of the method |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
*/ |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
template<typename Method, typename... Arguments> void forward(Method method, Arguments&&... arguments) { |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
for (auto& h : * this) { |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
// TODO: optionally handle/collect exceptions |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
(h.get()->*method)(arguments...); |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
} |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
} |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
}; |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
|
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
} |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
} |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
} |
114810ee2386
replace macro with ProxyVector that forwards method calls to all its elements
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
} |