neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_node.hpp
Go to the documentation of this file.
1// i_node.hpp
2/*
3 neoGFX Design Studio
4 Copyright(C) 2020 Leigh Johnston
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
27
29{
31 {
32 public:
33 virtual color_or_gradient color() const = 0;
34 virtual i_widget const& icon() const = 0;
35 virtual i_widget& icon() = 0;
36 };
37
38 enum class pin_type
39 {
40 Execution = 0x01,
41 Data = 0x02,
42 Input = 0x10,
43 Output = 0x20
44 };
45
46 class i_node;
47
49 {
50 typedef i_node_pin self_type;
51 public:
53 public:
54 virtual pin_type type() const = 0;
55 virtual i_node& get() const = 0;
56 virtual bool connected() const = 0;
57 public:
58 virtual color_or_gradient color() const = 0;
59 virtual i_pin_widget const& as_widget() const = 0;
60 virtual i_pin_widget& as_widget() = 0;
61 virtual void set_widget(i_pin_widget& aWidget) = 0;
62 };
63
65 {
67 public:
69 };
70
72 {
74 public:
76 };
77
79 {
81 public:
83 public:
84 virtual i_node_pin const& source() const = 0;
85 virtual i_node_pin& source() = 0;
86 virtual i_node_pin const& destination() const = 0;
87 virtual i_node_pin& destination() = 0;
88 };
89
90 class i_node : public i_element
91 {
92 typedef i_node self_type;
93 public:
95 declare_event(input_removed, i_node_input_pin&)
97 declare_event(output_removed, i_node_output_pin&)
98 declare_event(connection_added, i_node_connection&)
99 declare_event(connection_removed, i_node_connection&)
100 public:
105 public:
106 virtual node_inputs_t const& inputs() const = 0;
107 virtual node_outputs_t const& outputs() const = 0;
108 virtual node_connections_t const& connections() const = 0;
109 virtual std::size_t connected_inputs() const = 0;
110 virtual std::size_t connected_outputs() const = 0;
111 public:
112 virtual void add_input(i_node_input_pin& aPin) = 0;
113 virtual void remove_input(i_node_input_pin& aPin) = 0;
114 virtual void add_output(i_node_output_pin& aPin) = 0;
115 virtual void remove_output(i_node_output_pin& aPin) = 0;
116 virtual void add_connection(i_node_pin& aSource, i_node_pin& aDestination) = 0;
117 virtual void remove_connection(i_node_pin& aSource, i_node_pin& aDestination) = 0;
118 };
119
120 inline void connect_nodes(i_node_pin& aSource, i_node_pin& aDestination)
121 {
122 aSource.get().add_connection(aSource, aDestination);
123 aDestination.get().add_connection(aSource, aDestination);
124 }
125}
virtual i_node_pin const & destination() const =0
virtual i_node_pin const & source() const =0
virtual i_node_pin & destination()=0
virtual i_pin_widget & as_widget()=0
virtual color_or_gradient color() const =0
virtual i_node & get() const =0
virtual void set_widget(i_pin_widget &aWidget)=0
virtual bool connected() const =0
virtual pin_type type() const =0
virtual i_pin_widget const & as_widget() const =0
virtual void remove_connection(i_node_pin &aSource, i_node_pin &aDestination)=0
virtual void add_input(i_node_input_pin &aPin)=0
virtual node_connections_t const & connections() const =0
declare_event(input_added, i_node_input_pin &) declare_event(input_removed
virtual void remove_input(i_node_input_pin &aPin)=0
virtual void add_output(i_node_output_pin &aPin)=0
virtual node_outputs_t const & outputs() const =0
virtual void add_connection(i_node_pin &aSource, i_node_pin &aDestination)=0
virtual std::size_t connected_inputs() const =0
virtual node_inputs_t const & inputs() const =0
virtual void remove_output(i_node_output_pin &aPin)=0
virtual std::size_t connected_outputs() const =0
virtual color_or_gradient color() const =0
virtual i_widget const & icon() const =0
virtual i_widget & icon()=0
void connect_nodes(i_node_pin &aSource, i_node_pin &aDestination)
Definition i_node.hpp:120
Definition plf_hive.h:79
#define declare_event(declName,...)
Definition i_event.hpp:305