equal
deleted
inserted
replaced
14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 */ |
16 */ |
17 #pragma once |
17 #pragma once |
18 |
18 |
|
19 #include <memory> |
|
20 #include <vector> |
|
21 |
19 namespace relpipe { |
22 namespace relpipe { |
20 namespace in { |
23 namespace in { |
21 namespace asn1 { |
24 namespace asn1 { |
22 namespace lib { |
25 namespace lib { |
23 |
26 |
24 class ASN1ContentHandler { |
27 class ASN1ContentHandler { |
|
28 public: |
|
29 |
|
30 virtual ~ASN1ContentHandler() = default; |
|
31 |
|
32 virtual void abc() = 0; // FIXME: remove dummy method |
|
33 virtual void def(int a) = 0; // FIXME: remove dummy method |
|
34 virtual void ghi(int a, int b) = 0; // FIXME: remove dummy method |
|
35 |
25 }; |
36 }; |
|
37 |
|
38 class ASN1ContentHandlerProxy : public ASN1ContentHandler { |
|
39 private: |
|
40 std::vector<std::shared_ptr<ASN1ContentHandler>> handlers; |
|
41 public: |
|
42 |
|
43 void addHandler(std::shared_ptr<ASN1ContentHandler> handler) { |
|
44 handlers.push_back(handler); |
|
45 } |
|
46 |
|
47 #define handler for (auto ___h : handlers) ___h |
|
48 |
|
49 void abc() override { |
|
50 handler->abc(); |
|
51 } |
|
52 |
|
53 void def(int a) override { |
|
54 handler->def(a); |
|
55 } |
|
56 |
|
57 void ghi(int a, int b) override { |
|
58 handler->ghi(a, b); |
|
59 } |
|
60 |
|
61 #undef handler |
|
62 |
|
63 }; |
|
64 |
26 |
65 |
27 } |
66 } |
28 } |
67 } |
29 } |
68 } |
30 } |
69 } |