1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
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.
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
19 #ifndef __TOYNODE_HXX__
20 #define __TOYNODE_HXX__
22 #include "ServiceNode.hxx"
23 #include "AnyInputPort.hxx"
24 #include "OutputPort.hxx"
25 #include "InputPort.hxx"
32 class InputToyPort : public InputPort
35 InputToyPort(const InputToyPort& other, Node *newHelder);
36 InputToyPort(const std::string& name, Node *node);
37 void put(const void *data) throw(ConversionException);
38 InputPort *clone(Node *newHelder) const;
39 bool edIsManuallyInitialized() const;
40 void *get() const throw(Exception);
41 void edRemoveManInit();
44 Any *getAny() { return _data; }
52 class OutputToyPort : public OutputPort
55 OutputToyPort(const std::string& name, Node *node, TypeCode *type);
56 OutputToyPort(const OutputToyPort& other, Node *newHelder);
57 void put(const void *data) throw(ConversionException);
58 OutputPort *clone(Node *newHelder) const;
62 Any *get() { return _data; }
67 class ToyNode : public ElementaryNode
70 OutputToyPort _nbOfInputsPort;
73 ToyNode(const ToyNode& other, ComposedNode *father);
74 ToyNode(const std::string& name);
75 OutputPort *edGetNbOfInputsOutputPort() { return &_nbOfInputsPort; }
76 std::list<OutputPort *> getSetOfOutputPort() const;
77 int getNumberOfOutputPorts()const;
78 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
80 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
82 static char NAME_FOR_NB[];
83 static char MY_IMPL_NAME[];
86 class ToyNode1S : public ServiceNode
89 ToyNode1S(const std::string& name);
90 ToyNode1S(const ToyNode1S& other, ComposedNode *father);
92 std::string getKind() const;
93 ServiceNode *createNode(const std::string& name);
95 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
97 static const char KIND[];
100 class ToyNode2S : public ServiceNode
103 ToyNode2S(const std::string& name);
104 ToyNode2S(const ToyNode2S& other, ComposedNode *father);
106 std::string getKind() const;
107 ServiceNode *createNode(const std::string& name);
109 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
111 static const char KIND[];
114 class SeqToyNode : public ElementaryNode
117 OutputToyPort _seqOut;
118 AnyInputPort _inIntValue;
121 SeqToyNode(const SeqToyNode& other, ComposedNode *father);
122 SeqToyNode(const std::string& name);
123 OutputPort *edGetSeqOut() const { return (OutputPort *)&_seqOut; }
124 InputPort *edGetInIntValue() const { return (InputPort *)&_inIntValue; }
125 int getNumberOfInputPorts() const;
126 std::list<InputPort *> getSetOfInputPort() const;
127 InputPort *getInputPort(const std::string& name) const throw(Exception);
128 int getNumberOfOutputPorts() const;
129 std::list<OutputPort *> getSetOfOutputPort() const;
130 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
132 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
134 static char NAME_NBOFELTS_INSEQ_INPRT[];
135 static char NAME_SEQ_OUTPRT[];
138 class Seq2ToyNode : public ElementaryNode
141 OutputToyPort _seqOut;
142 AnyInputPort _inValue1;
143 AnyInputPort _inValue2;
146 Seq2ToyNode(const Seq2ToyNode& other, ComposedNode *father);
147 Seq2ToyNode(const std::string& name);
148 OutputToyPort *edGetSeqOut() const { return (OutputToyPort *)&_seqOut; }
149 InputPort *edGetInValue1() const { return (InputPort *)&_inValue1; }
150 InputPort *edGetInValue2() const { return (InputPort *)&_inValue2; }
151 int getNumberOfInputPorts() const;
152 std::list<InputPort *> getSetOfInputPort() const;
153 InputPort *getInputPort(const std::string& name) const throw(Exception);
154 int getNumberOfOutputPorts() const;
155 std::list<OutputPort *> getSetOfOutputPort() const;
156 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
158 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
160 static char NAME_SEQ_INPRT1[];
161 static char NAME_SEQ_INPRT2[];
162 static char NAME_SEQ_OUTPRT[];
165 class Seq3ToyNode : public ElementaryNode
168 OutputToyPort _seqOut;
169 AnyInputPort _inValue1;
170 AnyInputPort _inValue2;
173 Seq3ToyNode(const Seq3ToyNode& other, ComposedNode *father);
174 Seq3ToyNode(const std::string& name);
175 OutputToyPort *edGetSeqOut() const { return (OutputToyPort *)&_seqOut; }
176 InputPort *edGetInValue1() const { return (InputPort *)&_inValue1; }
177 InputPort *edGetInValue2() const { return (InputPort *)&_inValue2; }
178 int getNumberOfInputPorts() const;
179 std::list<InputPort *> getSetOfInputPort() const;
180 InputPort *getInputPort(const std::string& name) const throw(Exception);
181 int getNumberOfOutputPorts() const;
182 std::list<OutputPort *> getSetOfOutputPort() const;
183 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
185 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
187 static char NAME_SEQ_INPRT1[];
188 static char NAME_SEQ_INPRT2[];
189 static char NAME_SEQ_OUTPRT[];
194 class InputLimitPort : public InputPort
196 friend class LimitNode;
198 void put(const void *data) throw(ConversionException);
199 InputPort *clone(Node *newHelder) const;
200 bool edIsManuallyInitialized() const;
201 void *get() const throw(Exception);
202 void edRemoveManInit();
205 Any *getAny() { return _data; }
207 void exRestoreInit();
209 InputLimitPort(const InputLimitPort& other, Node *newHelder);
210 InputLimitPort(const std::string& name, Node *node);
216 class OutputLimitPort : public OutputPort
218 friend class LimitNode;
220 void put(const void *data) throw(ConversionException);
221 OutputPort *clone(Node *newHelder) const;
224 Any *get() { return _data; }
226 OutputLimitPort(const OutputLimitPort& other, Node *newHelder);
227 OutputLimitPort(const std::string& name, Node *node, TypeCode *type);
232 class LimitNode : public ElementaryNode
237 InputLimitPort _entry;
238 OutputLimitPort _switchPort;
239 OutputLimitPort _counterPort;
241 void init(bool start=true);
243 void setLimit(double limit) { _limit=limit; }
244 InputPort *getEntry() { return &_entry; }
245 OutputPort *getSwitchPort() { return &_switchPort; }
246 OutputPort *getCounterPort() { return &_counterPort; }
247 std::list<InputPort *> getSetOfInputPort() const;
248 std::list<OutputPort *> getSetOfOutputPort() const;
249 InputPort *getInputPort(const std::string& name) const throw(Exception);
250 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
251 LimitNode(const LimitNode& other, ComposedNode *father);
252 LimitNode(const std::string& name);
254 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
256 static char MY_IMPL_NAME[];
257 static char NAME_FOR_SWPORT[];
258 static char NAME_FOR_SWPORT2[];