1 // Copyright (C) 2006-2024 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __TOYNODE_HXX__
21 #define __TOYNODE_HXX__
23 #include "ServiceNode.hxx"
24 #include "AnyInputPort.hxx"
25 #include "OutputPort.hxx"
26 #include "InputPort.hxx"
33 class InputToyPort : public InputPort
36 InputToyPort(const InputToyPort& other, Node *newHelder);
37 InputToyPort(const std::string& name, Node *node);
38 void releaseData() override;
39 void put(const void *data);
40 InputPort *clone(Node *newHelder) const;
41 bool edIsManuallyInitialized() const;
43 void edRemoveManInit();
46 Any *getAny() { return _data; }
54 class OutputToyPort : public OutputPort
57 OutputToyPort(const std::string& name, Node *node, TypeCode *type);
58 OutputToyPort(const OutputToyPort& other, Node *newHelder);
59 void put(const void *data);
60 OutputPort *clone(Node *newHelder) const;
64 Any *get() { return _data; }
69 class ToyNode : public ElementaryNode
72 OutputToyPort _nbOfInputsPort;
75 ToyNode(const ToyNode& other, ComposedNode *father);
76 ToyNode(const std::string& name);
77 OutputPort *edGetNbOfInputsOutputPort() { return &_nbOfInputsPort; }
78 std::list<OutputPort *> getSetOfOutputPort() const;
79 int getNumberOfOutputPorts()const;
80 OutputPort *getOutputPort(const std::string& name) const ;
82 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
84 static char NAME_FOR_NB[];
85 static char MY_IMPL_NAME[];
88 class ToyNode1S : public ServiceNode
91 ToyNode1S(const std::string& name);
92 ToyNode1S(const ToyNode1S& other, ComposedNode *father);
94 std::string getKind() const;
95 ServiceNode *createNode(const std::string& name);
97 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
99 static const char KIND[];
102 class ToyNode2S : public ServiceNode
105 ToyNode2S(const std::string& name);
106 ToyNode2S(const ToyNode2S& other, ComposedNode *father);
108 std::string getKind() const;
109 ServiceNode *createNode(const std::string& name);
111 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
113 static const char KIND[];
116 class SeqToyNode : public ElementaryNode
119 OutputToyPort _seqOut;
120 AnyInputPort _inIntValue;
123 SeqToyNode(const SeqToyNode& other, ComposedNode *father);
124 SeqToyNode(const std::string& name);
125 OutputPort *edGetSeqOut() const { return (OutputPort *)&_seqOut; }
126 InputPort *edGetInIntValue() const { return (InputPort *)&_inIntValue; }
127 int getNumberOfInputPorts() const;
128 std::list<InputPort *> getSetOfInputPort() const;
129 InputPort *getInputPort(const std::string& name) const ;
130 int getNumberOfOutputPorts() const;
131 std::list<OutputPort *> getSetOfOutputPort() const;
132 OutputPort *getOutputPort(const std::string& name) const ;
134 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
136 static char NAME_NBOFELTS_INSEQ_INPRT[];
137 static char NAME_SEQ_OUTPRT[];
140 class Seq2ToyNode : public ElementaryNode
143 OutputToyPort _seqOut;
144 AnyInputPort _inValue1;
145 AnyInputPort _inValue2;
148 Seq2ToyNode(const Seq2ToyNode& other, ComposedNode *father);
149 Seq2ToyNode(const std::string& name);
150 OutputToyPort *edGetSeqOut() const { return (OutputToyPort *)&_seqOut; }
151 InputPort *edGetInValue1() const { return (InputPort *)&_inValue1; }
152 InputPort *edGetInValue2() const { return (InputPort *)&_inValue2; }
153 int getNumberOfInputPorts() const;
154 std::list<InputPort *> getSetOfInputPort() const;
155 InputPort *getInputPort(const std::string& name) const ;
156 int getNumberOfOutputPorts() const;
157 std::list<OutputPort *> getSetOfOutputPort() const;
158 OutputPort *getOutputPort(const std::string& name) const ;
160 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
162 static char NAME_SEQ_INPRT1[];
163 static char NAME_SEQ_INPRT2[];
164 static char NAME_SEQ_OUTPRT[];
167 class Seq3ToyNode : public ElementaryNode
170 OutputToyPort _seqOut;
171 AnyInputPort _inValue1;
172 AnyInputPort _inValue2;
175 Seq3ToyNode(const Seq3ToyNode& other, ComposedNode *father);
176 Seq3ToyNode(const std::string& name);
177 OutputToyPort *edGetSeqOut() const { return (OutputToyPort *)&_seqOut; }
178 InputPort *edGetInValue1() const { return (InputPort *)&_inValue1; }
179 InputPort *edGetInValue2() const { return (InputPort *)&_inValue2; }
180 int getNumberOfInputPorts() const;
181 std::list<InputPort *> getSetOfInputPort() const;
182 InputPort *getInputPort(const std::string& name) const ;
183 int getNumberOfOutputPorts() const;
184 std::list<OutputPort *> getSetOfOutputPort() const;
185 OutputPort *getOutputPort(const std::string& name) const ;
187 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
189 static char NAME_SEQ_INPRT1[];
190 static char NAME_SEQ_INPRT2[];
191 static char NAME_SEQ_OUTPRT[];
196 class InputLimitPort : public InputPort
198 friend class LimitNode;
200 void put(const void *data);
201 InputPort *clone(Node *newHelder) const;
202 bool edIsManuallyInitialized() const;
204 void edRemoveManInit();
205 void releaseData() override;
208 Any *getAny() { return _data; }
210 void exRestoreInit();
212 InputLimitPort(const InputLimitPort& other, Node *newHelder);
213 InputLimitPort(const std::string& name, Node *node);
219 class OutputLimitPort : public OutputPort
221 friend class LimitNode;
223 void put(const void *data);
224 OutputPort *clone(Node *newHelder) const;
227 Any *get() { return _data; }
229 OutputLimitPort(const OutputLimitPort& other, Node *newHelder);
230 OutputLimitPort(const std::string& name, Node *node, TypeCode *type);
235 class LimitNode : public ElementaryNode
240 InputLimitPort _entry;
241 OutputLimitPort _switchPort;
242 OutputLimitPort _counterPort;
244 void init(bool start=true);
246 void setLimit(double limit) { _limit=limit; }
247 InputPort *getEntry() { return &_entry; }
248 OutputPort *getSwitchPort() { return &_switchPort; }
249 OutputPort *getCounterPort() { return &_counterPort; }
250 std::list<InputPort *> getSetOfInputPort() const;
251 std::list<OutputPort *> getSetOfOutputPort() const;
252 InputPort *getInputPort(const std::string& name) const ;
253 OutputPort *getOutputPort(const std::string& name) const ;
254 LimitNode(const LimitNode& other, ComposedNode *father);
255 LimitNode(const std::string& name);
257 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
259 static char MY_IMPL_NAME[];
260 static char NAME_FOR_SWPORT[];
261 static char NAME_FOR_SWPORT2[];