11
11
#define UREACT_DETAIL_NODE_BASE_HPP
12
12
13
13
#include < memory>
14
+ #include < tuple>
14
15
#include < utility>
15
16
16
17
#include < ureact/context.hpp>
@@ -41,18 +42,9 @@ Ret create_wrapped_node( Args&&... args )
41
42
class node_base : public reactive_node_interface
42
43
{
43
44
public:
44
- explicit node_base ( context context )
45
- : m_context( std::move( context ) )
46
- {
47
- assert ( !get_graph ().is_locked () && " Can't create node from callback" );
48
- m_id = get_graph ().register_node ();
49
- }
45
+ explicit node_base ( context context );
50
46
51
- ~node_base () override
52
- {
53
- detach_from_all ();
54
- get_graph ().unregister_node ( m_id );
55
- }
47
+ ~node_base () override ;
56
48
57
49
UREACT_WARN_UNUSED_RESULT node_id get_node_id () const
58
50
{
@@ -70,36 +62,14 @@ class node_base : public reactive_node_interface
70
62
}
71
63
72
64
protected:
73
- UREACT_WARN_UNUSED_RESULT react_graph& get_graph ()
74
- {
75
- return get_internals ( m_context ).get_graph ();
76
- }
77
-
78
- UREACT_WARN_UNUSED_RESULT const react_graph& get_graph () const
79
- {
80
- return get_internals ( m_context ).get_graph ();
81
- }
65
+ UREACT_WARN_UNUSED_RESULT react_graph& get_graph ();
66
+ UREACT_WARN_UNUSED_RESULT const react_graph& get_graph () const ;
82
67
83
- void attach_to ( node_id parentId )
84
- {
85
- m_parents.add ( parentId );
86
- get_graph ().attach_node ( m_id, parentId );
87
- }
68
+ void attach_to ( node_id parentId );
88
69
89
- void detach_from ( node_id parentId )
90
- {
91
- get_graph ().detach_node ( m_id, parentId );
92
- m_parents.remove ( parentId );
93
- }
70
+ void detach_from ( node_id parentId );
94
71
95
- void detach_from_all ()
96
- {
97
- for ( node_id parentId : m_parents )
98
- {
99
- get_graph ().detach_node ( m_id, parentId );
100
- }
101
- m_parents.clear ();
102
- }
72
+ void detach_from_all ();
103
73
104
74
template <class ... Deps>
105
75
void attach_to ( const Deps&... deps )
@@ -137,4 +107,8 @@ class node_base : public reactive_node_interface
137
107
138
108
UREACT_END_NAMESPACE
139
109
110
+ #if UREACT_HEADER_ONLY
111
+ # include < ureact/detail/node_base.inl>
112
+ #endif
113
+
140
114
#endif // UREACT_DETAIL_NODE_BASE_HPP
0 commit comments