Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_NodeBase.h « intern « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e386b5e08a0e57a2b2d0c7aba596d873aee2e247 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
 * Copyright 2011, Blender Foundation.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * Contributor: 
 *		Jeroen Bakker 
 *		Monique Dewanchand
 */

#ifndef __COM_NODEBASE_H__
#define __COM_NODEBASE_H__

#include "COM_InputSocket.h"
#include "COM_OutputSocket.h"
#include "DNA_node_types.h"
#include "BKE_text.h"
#include <vector>
#include <string>

using namespace std;


class NodeOperation;
class ExecutionSystem;

/**
 * @brief The NodeBase class is the super-class of all node related objects like @see Node @see NodeOperation
 * the reason for the existence of this class is to support graph-nodes when using ExecutionSystem
 * the NodeBase also contains the reference to InputSocket and OutputSocket.
 * @ingroup Model
 */
class NodeBase {
private:
	/**
	 * @brief the list of actual inputsockets @see InputSocket
	 */
	vector<InputSocket *> m_inputsockets;

	/**
	 * @brief the list of actual outputsockets @see OutputSocket
	 */
	vector<OutputSocket *> m_outputsockets;

	/**
	 * @brief stores the reference to the SDNA bNode struct
	 */
	bNode *m_editorNode;

protected:
	/**
	 * @brief get access to the vector of input sockets
	 */
	inline vector<InputSocket *>& getInputSockets() { return this->m_inputsockets; }
	
	/**
	 * @brief get access to the vector of input sockets
	 */
	inline vector<OutputSocket *>& getOutputSockets() { return this->m_outputsockets; }


protected:
	/**
	 * @brief destructor
	 * clean up memory related to this NodeBase.
	 */
	virtual ~NodeBase();
	
public:
	/**
	 * @brief get the reference to the SDNA bNode struct
	 */
	bNode *getbNode() {return m_editorNode;}
	
	/**
	 * @brief set the reference to the bNode
	 * @note used in Node instances to receive the storage/settings and complex node for highlight during execution
	 * @param bNode
	 */
	void setbNode(bNode *bNode) {this->m_editorNode = bNode;}
	
	/**
	 * @brief is this node an operation?
	 * This is true when the instance is of the subclass NodeOperation.
	 * @return [true:false]
	 * @see NodeOperation
	 */
	virtual const bool isOperation() const { return false; }
	
	/**
	 * @brief check if this is an input node
	 * An input node is a node that only has output sockets and no input sockets
	 * @return [false..true]
	 */
	const bool isInputNode() const;
	
	/**
	 * @brief Return the number of input sockets of this node.
	 */
	const unsigned int getNumberOfInputSockets() const { return this->m_inputsockets.size(); }

	/**
	 * @brief Return the number of output sockets of this node.
	 */
	const unsigned int getNumberOfOutputSockets() const { return this->m_outputsockets.size(); }

	/**
	 * get the reference to a certain outputsocket
	 * @param index
	 * the index of the needed outputsocket
	 */
	OutputSocket *getOutputSocket(const unsigned int index);
	
	/**
	 * get the reference to the first outputsocket
	 * @param index
	 * the index of the needed outputsocket
	 */
	inline OutputSocket *getOutputSocket() { return getOutputSocket(0); }
	
	/**
	 * get the reference to a certain inputsocket
	 * @param index
	 * the index of the needed inputsocket
	 */
	InputSocket *getInputSocket(const unsigned int index);
	
	
	virtual bool isStatic() const { return false; }
	void getStaticValues(float *result) const { }
protected:
	NodeBase();
	
	/**
	 * @brief add an InputSocket to the collection of inputsockets
	 * @note may only be called in an constructor
	 * @param socket the InputSocket to add
	 */
	void addInputSocket(DataType datatype);
	void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode);
	void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket *socket);
	
	/**
	 * @brief add an OutputSocket to the collection of outputsockets
	 * @note may only be called in an constructor
	 * @param socket the OutputSocket to add
	 */
	void addOutputSocket(DataType datatype);
	void addOutputSocket(DataType datatype, bNodeSocket *socket);


#ifdef WITH_CXX_GUARDEDALLOC
	MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeBase")
#endif
};

#endif  /* __COM_NODEBASE_H__ */