|
1 | 1 | #pragma once |
2 | | -#include "document_node_interface_access.h" |
3 | 2 | #include <sfun/interface.h> |
4 | | -#include <sfun/optional_ref.h> |
5 | | -#include <gsl/assert> |
6 | | -#include <string> |
7 | 3 | #include <typeinfo> |
8 | | -#include <memory> |
9 | | -#include <vector> |
10 | 4 |
|
11 | 5 | namespace htcpp { |
12 | | -class INodeCollection; |
13 | | -class IDocumentNodeRenderer; |
14 | | -class IRenderedAsStringPart; |
15 | | -class IConvertibleToProcedure; |
16 | | -class IAttribute; |
17 | | - |
18 | | -template<typename TInterface> |
19 | | -struct InterfaceGetterMapping; |
20 | 6 |
|
21 | 7 | class IDocumentNode : private sfun::interface<IDocumentNode> |
22 | 8 | { |
23 | 9 | public: |
24 | | - template<typename TInterface> |
25 | | - auto getInterface() const |
26 | | - { |
27 | | - return (this->*InterfaceGetterMapping<TInterface>::getterPtr())(); |
28 | | - } |
29 | | - |
30 | | - template<typename TInterface> |
31 | | - auto getInterface() |
32 | | - { |
33 | | - return (this->*InterfaceGetterMapping<TInterface>::getterPtr())(); |
34 | | - } |
35 | | - |
36 | 10 | template<typename T> |
37 | 11 | bool is() |
38 | 12 | { |
39 | 13 | return typeid(*this) == typeid(T); |
40 | 14 | } |
41 | | - |
42 | | -private: |
43 | | - DOCUMENT_NODE_ADD_INTERFACE_GETTER(INodeCollection); |
44 | | - DOCUMENT_NODE_ADD_INTERFACE_GETTER(IDocumentNodeRenderer); |
45 | | - DOCUMENT_NODE_ADD_INTERFACE_GETTER(IRenderedAsStringPart); |
46 | | - DOCUMENT_NODE_ADD_INTERFACE_GETTER(IConvertibleToProcedure); |
47 | | - DOCUMENT_NODE_ADD_INTERFACE_GETTER(IAttribute); |
48 | | - |
49 | | - template<typename TInterface> |
50 | | - friend struct InterfaceGetterMapping; |
51 | 15 | }; |
52 | 16 |
|
53 | | -DOCUMENT_NODE_REGISTER_INTERFACE(INodeCollection); |
54 | | -DOCUMENT_NODE_REGISTER_INTERFACE(IDocumentNodeRenderer); |
55 | | -DOCUMENT_NODE_REGISTER_INTERFACE(IRenderedAsStringPart); |
56 | | -DOCUMENT_NODE_REGISTER_INTERFACE(IConvertibleToProcedure); |
57 | | -DOCUMENT_NODE_REGISTER_INTERFACE(IAttribute); |
58 | | - |
59 | 17 |
|
60 | 18 | } // namespace htcpp |
0 commit comments