1 // Copyright (C) 2006-2014 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, 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 put(const void *data) throw(ConversionException);
39 InputPort *clone(Node *newHelder) const;
40 bool edIsManuallyInitialized() const;
41 void *get() const throw(Exception);
42 void edRemoveManInit();
45 Any *getAny() { return _data; }
53 class OutputToyPort : public OutputPort
56 OutputToyPort(const std::string& name, Node *node, TypeCode *type);
57 OutputToyPort(const OutputToyPort& other, Node *newHelder);
58 void put(const void *data) throw(ConversionException);
59 OutputPort *clone(Node *newHelder) const;
63 Any *get() { return _data; }
68 class ToyNode : public ElementaryNode
71 OutputToyPort _nbOfInputsPort;
74 ToyNode(const ToyNode& other, ComposedNode *father);
75 ToyNode(const std::string& name);
76 OutputPort *edGetNbOfInputsOutputPort() { return &_nbOfInputsPort; }
77 std::list<OutputPort *> getSetOfOutputPort() const;
78 int getNumberOfOutputPorts()const;
79 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
81 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
83 static char NAME_FOR_NB[];
84 static char MY_IMPL_NAME[];
87 class ToyNode1S : public ServiceNode
90 ToyNode1S(const std::string& name);
91 ToyNode1S(const ToyNode1S& other, ComposedNode *father);
93 std::string getKind() const;
94 ServiceNode *createNode(const std::string& name);
96 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
98 static const char KIND[];
101 class ToyNode2S : public ServiceNode
104 ToyNode2S(const std::string& name);
105 ToyNode2S(const ToyNode2S& other, ComposedNode *father);
107 std::string getKind() const;
108 ServiceNode *createNode(const std::string& name);
110 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
112 static const char KIND[];
115 class SeqToyNode : public ElementaryNode
118 OutputToyPort _seqOut;
119 AnyInputPort _inIntValue;
122 SeqToyNode(const SeqToyNode& other, ComposedNode *father);
123 SeqToyNode(const std::string& name);
124 OutputPort *edGetSeqOut() const { return (OutputPort *)&_seqOut; }
125 InputPort *edGetInIntValue() const { return (InputPort *)&_inIntValue; }
126 int getNumberOfInputPorts() const;
127 std::list<InputPort *> getSetOfInputPort() const;
128 InputPort *getInputPort(const std::string& name) const throw(Exception);
129 int getNumberOfOutputPorts() const;
130 std::list<OutputPort *> getSetOfOutputPort() const;
131 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
133 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
135 static char NAME_NBOFELTS_INSEQ_INPRT[];
136 static char NAME_SEQ_OUTPRT[];
139 class Seq2ToyNode : public ElementaryNode
142 OutputToyPort _seqOut;
143 AnyInputPort _inValue1;
144 AnyInputPort _inValue2;
147 Seq2ToyNode(const Seq2ToyNode& other, ComposedNode *father);
148 Seq2ToyNode(const std::string& name);
149 OutputToyPort *edGetSeqOut() const { return (OutputToyPort *)&_seqOut; }
150 InputPort *edGetInValue1() const { return (InputPort *)&_inValue1; }
151 InputPort *edGetInValue2() const { return (InputPort *)&_inValue2; }
152 int getNumberOfInputPorts() const;
153 std::list<InputPort *> getSetOfInputPort() const;
154 InputPort *getInputPort(const std::string& name) const throw(Exception);
155 int getNumberOfOutputPorts() const;
156 std::list<OutputPort *> getSetOfOutputPort() const;
157 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
159 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
161 static char NAME_SEQ_INPRT1[];
162 static char NAME_SEQ_INPRT2[];
163 static char NAME_SEQ_OUTPRT[];
166 class Seq3ToyNode : public ElementaryNode
169 OutputToyPort _seqOut;
170 AnyInputPort _inValue1;
171 AnyInputPort _inValue2;
174 Seq3ToyNode(const Seq3ToyNode& other, ComposedNode *father);
175 Seq3ToyNode(const std::string& name);
176 OutputToyPort *edGetSeqOut() const { return (OutputToyPort *)&_seqOut; }
177 InputPort *edGetInValue1() const { return (InputPort *)&_inValue1; }
178 InputPort *edGetInValue2() const { return (InputPort *)&_inValue2; }
179 int getNumberOfInputPorts() const;
180 std::list<InputPort *> getSetOfInputPort() const;
181 InputPort *getInputPort(const std::string& name) const throw(Exception);
182 int getNumberOfOutputPorts() const;
183 std::list<OutputPort *> getSetOfOutputPort() const;
184 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
186 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
188 static char NAME_SEQ_INPRT1[];
189 static char NAME_SEQ_INPRT2[];
190 static char NAME_SEQ_OUTPRT[];
195 class InputLimitPort : public InputPort
197 friend class LimitNode;
199 void put(const void *data) throw(ConversionException);
200 InputPort *clone(Node *newHelder) const;
201 bool edIsManuallyInitialized() const;
202 void *get() const throw(Exception);
203 void edRemoveManInit();
206 Any *getAny() { return _data; }
208 void exRestoreInit();
210 InputLimitPort(const InputLimitPort& other, Node *newHelder);
211 InputLimitPort(const std::string& name, Node *node);
217 class OutputLimitPort : public OutputPort
219 friend class LimitNode;
221 void put(const void *data) throw(ConversionException);
222 OutputPort *clone(Node *newHelder) const;
225 Any *get() { return _data; }
227 OutputLimitPort(const OutputLimitPort& other, Node *newHelder);
228 OutputLimitPort(const std::string& name, Node *node, TypeCode *type);
233 class LimitNode : public ElementaryNode
238 InputLimitPort _entry;
239 OutputLimitPort _switchPort;
240 OutputLimitPort _counterPort;
242 void init(bool start=true);
244 void setLimit(double limit) { _limit=limit; }
245 InputPort *getEntry() { return &_entry; }
246 OutputPort *getSwitchPort() { return &_switchPort; }
247 OutputPort *getCounterPort() { return &_counterPort; }
248 std::list<InputPort *> getSetOfInputPort() const;
249 std::list<OutputPort *> getSetOfOutputPort() const;
250 InputPort *getInputPort(const std::string& name) const throw(Exception);
251 OutputPort *getOutputPort(const std::string& name) const throw(Exception);
252 LimitNode(const LimitNode& other, ComposedNode *father);
253 LimitNode(const std::string& name);
255 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
257 static char MY_IMPL_NAME[];
258 static char NAME_FOR_SWPORT[];
259 static char NAME_FOR_SWPORT2[];