Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / engine / Test / ToyNode.cxx
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "ToyNode.hxx"
20 #include "TypeCode.hxx"
21 #include <iostream>
22
23 using namespace YACS::ENGINE;
24 using namespace std;
25
26 char ToyNode::MY_IMPL_NAME[]="TOY";
27
28 const char ToyNode1S::KIND[]="TESTKIND1";
29
30 const char ToyNode2S::KIND[]="TESTKIND2";
31
32 char LimitNode::MY_IMPL_NAME[]="LIMIT";
33
34 char ToyNode::NAME_FOR_NB[]="NbOfEntries";
35
36 char SeqToyNode::NAME_NBOFELTS_INSEQ_INPRT[]="NbOfEltsInSeq";
37
38 char SeqToyNode::NAME_SEQ_OUTPRT[]="MySeq";
39
40 char Seq2ToyNode::NAME_SEQ_INPRT1[]="SeqIn1";
41
42 char Seq2ToyNode::NAME_SEQ_INPRT2[]="SeqIn2";
43
44 char Seq2ToyNode::NAME_SEQ_OUTPRT[]="SeqOut";
45
46 char Seq3ToyNode::NAME_SEQ_INPRT1[]="SeqIn1";
47
48 char Seq3ToyNode::NAME_SEQ_INPRT2[]="SeqIn2";
49
50 char Seq3ToyNode::NAME_SEQ_OUTPRT[]="SeqOut";
51
52 char LimitNode::NAME_FOR_SWPORT[]="SwitchPort";
53
54 char LimitNode::NAME_FOR_SWPORT2[]="SwitchPort2";
55
56 InputToyPort::InputToyPort(const InputToyPort& other, Node *newHelder):InputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),
57                                                                        _data(0),_initData(0)
58 {
59   if(other._data)
60     _data=other._data->clone();
61   if(other._initData)
62     _initData=other._initData->clone();
63 }
64
65 InputToyPort::InputToyPort(const string& name, Node *node):InputPort(name, node, Runtime::_tc_double),DataPort(name, node, Runtime::_tc_double),Port(node),_data(0),_initData(0)
66 {
67 }
68
69 void InputToyPort::put(const void *data) throw(ConversionException)
70 {
71   put((Any *)data);
72 }
73
74 bool InputToyPort::edIsManuallyInitialized() const
75 {
76   return _initData!=0;
77 }
78
79 void *InputToyPort::get() const throw(Exception)
80 {
81   return (void *)_data;
82 }
83
84 void InputToyPort::edRemoveManInit()
85 {
86   if(_initData)
87     _initData->decrRef();
88   _initData=0;
89   InputPort::edRemoveManInit();
90 }
91
92 InputPort *InputToyPort::clone(Node *newHelder) const
93 {
94   return new InputToyPort(*this,newHelder);
95 }
96
97 void InputToyPort::put(Any *data)
98 {
99   if(_data)
100     _data->decrRef();
101   _data=data;
102   _data->incrRef();
103 }
104
105 void InputToyPort::exSaveInit()
106   {
107     if(_initData) _initData->decrRef();
108     _initData=_data;
109     _initData->incrRef();
110   }
111
112 void InputToyPort::exRestoreInit()
113   {
114     if(!_initData)return;
115     if(_data) _data->decrRef();
116     _data=_initData;
117     _data->incrRef();
118   }
119
120 InputToyPort::~InputToyPort()
121 {
122   if(_data)
123     _data->decrRef();
124   if(_initData)
125     _initData->decrRef();
126 }
127
128 OutputToyPort::OutputToyPort(const string& name, Node *node, TypeCode *type):OutputPort(name, node, type),DataPort(name, node, type),Port(node),_data(0)
129 {
130 }
131
132 OutputToyPort::OutputToyPort(const OutputToyPort& other, Node *newHelder):OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),_data(0)
133 {
134   if(other._data)
135     _data=other._data->clone();
136 }
137
138 void OutputToyPort::put(const void *data) throw(ConversionException)
139 {
140   put((Any *)data);
141   OutputPort::put(data);
142 }
143
144 OutputPort *OutputToyPort::clone(Node *newHelder) const
145 {
146   return new OutputToyPort(*this,newHelder);
147 }
148
149 void OutputToyPort::put(Any *data)
150 {
151   if(_data)
152     _data->decrRef();
153   _data=data;
154   _data->incrRef();
155 }
156
157 OutputToyPort::~OutputToyPort()
158 {
159   if(_data)
160     _data->decrRef();
161 }
162
163 void OutputToyPort::exInit()
164 {
165   if(_data)
166     {
167       _data->decrRef();
168       _data=0;
169     }
170 }
171
172 ToyNode::ToyNode(const ToyNode& other, ComposedNode *father):ElementaryNode(other,father),_nbOfInputsPort(other._nbOfInputsPort,this)
173 {
174 }
175
176 ToyNode::ToyNode(const string& name):ElementaryNode(name),_nbOfInputsPort(NAME_FOR_NB,this,Runtime::_tc_int)
177 {
178   _implementation=MY_IMPL_NAME;
179 }
180
181 void ToyNode::execute()
182 {
183   int i=0;
184   double d=0.;
185   for(list<InputPort *>::iterator iter=_setOfInputPort.begin();iter!=_setOfInputPort.end();iter++)
186     {
187       i++;
188       InputToyPort *p=(InputToyPort *) (*iter);
189       d+=p->getAny()->getDoubleValue();
190     }
191   int size=_setOfOutputPort.size();
192   if(size)
193     d/=(double)(size);
194   Any *tmp=AtomAny::New((int)_setOfInputPort.size());
195   _nbOfInputsPort.put((const void *)tmp);
196   tmp->decrRef();
197   for(list<OutputPort *>::iterator iter2=_setOfOutputPort.begin();iter2!=_setOfOutputPort.end();iter2++)
198     {
199       Any *tmp=AtomAny::New(d);
200       (*iter2)->put(tmp);
201       tmp->decrRef();
202     }
203 }
204
205 std::list<OutputPort *> ToyNode::getSetOfOutputPort() const
206 {
207   list<OutputPort *> ret=ElementaryNode::getSetOfOutputPort();
208   ret.push_back((OutputPort *)&_nbOfInputsPort);
209   return ret;
210 }
211
212 int ToyNode::getNumberOfOutputPorts() const
213 {
214   return ElementaryNode::getNumberOfInputPorts()+1;
215 }
216
217 OutputPort *ToyNode::getOutputPort(const std::string& name) const throw(Exception)
218 {
219   if(name==NAME_FOR_NB)
220     return (OutputPort *)&_nbOfInputsPort;
221   else
222     return ElementaryNode::getOutputPort(name);
223 }
224
225 Node *ToyNode::simpleClone(ComposedNode *father, bool editionOnly) const
226 {
227   return new ToyNode(*this,father);
228 }
229
230 ToyNode1S::ToyNode1S(const std::string& name):ServiceNode(name)
231 {
232 }
233
234 ToyNode1S::ToyNode1S(const ToyNode1S& other, ComposedNode *father):ServiceNode(other,father)
235 {
236 }
237
238 void ToyNode1S::execute()
239 {
240   //nothing only to test deployment calculation not for running.
241 }
242
243 std::string ToyNode1S::getKind() const
244 {
245   return KIND;
246 }
247
248 ServiceNode *ToyNode1S::createNode(const std::string& name)
249 {
250   ToyNode1S* node=new ToyNode1S(name);
251   node->setComponent(_component);
252   return node;
253 }
254
255 Node *ToyNode1S::simpleClone(ComposedNode *father, bool editionOnly) const
256 {
257   return new ToyNode1S(*this,father);
258 }
259
260 ToyNode2S::ToyNode2S(const std::string& name):ServiceNode(name)
261 {
262 }
263
264 ToyNode2S::ToyNode2S(const ToyNode2S& other, ComposedNode *father):ServiceNode(other,father)
265 {
266 }
267
268 void ToyNode2S::execute()
269 {
270   //nothing only to test deployment calculation not for running.
271 }
272
273 std::string ToyNode2S::getKind() const
274 {
275   return KIND;
276 }
277
278 ServiceNode *ToyNode2S::createNode(const std::string& name)
279 {
280   ToyNode2S* node=new ToyNode2S(name);
281   node->setComponent(_component);
282   return node;
283 }
284
285 Node *ToyNode2S::simpleClone(ComposedNode *father, bool editionOnly) const
286 {
287   return new ToyNode2S(*this,father);
288 }
289
290 void SeqToyNode::execute()
291 {
292   int val=_inIntValue.getIntValue();
293   SequenceAny *tmp=SequenceAny::New(Runtime::_tc_double,val);
294   double d=(double) val;
295   for(int i=0;i<val;i++)
296     {
297       Any *tmp2=AtomAny::New(d);
298       tmp->setEltAtRank(i,tmp2);
299       tmp2->decrRef();
300       d+=1.;
301     }
302   _seqOut.put((const void *)tmp);
303   tmp->decrRef();
304 }
305
306 SeqToyNode::SeqToyNode(const SeqToyNode& other, ComposedNode *father):ElementaryNode(other,father),
307                                                                       _seqOut(other._seqOut,this),
308                                                                       _inIntValue(other._inIntValue,this)
309 {
310 }
311
312 SeqToyNode::SeqToyNode(const std::string& name):ElementaryNode(name),_seqOut(NAME_SEQ_OUTPRT,this,Runtime::_tc_double),
313                                                 _inIntValue(NAME_NBOFELTS_INSEQ_INPRT,this,Runtime::_tc_int)
314 {
315   _implementation=ToyNode::MY_IMPL_NAME;
316   TypeCodeSeq *tc=new TypeCodeSeq("","",Runtime::_tc_double);
317   _seqOut.edSetType(tc);
318   tc->decrRef();
319 }
320
321 int SeqToyNode::getNumberOfInputPorts() const
322 {
323   return ElementaryNode::getNumberOfInputPorts()+1;
324 }
325
326 std::list<InputPort *> SeqToyNode::getSetOfInputPort() const
327 {
328   list<InputPort *> ret=ElementaryNode::getSetOfInputPort();
329   ret.push_back((InputPort *)&_inIntValue);
330   return ret;
331 }
332
333 InputPort *SeqToyNode::getInputPort(const std::string& name) const throw(Exception)
334 {
335   if(name==NAME_NBOFELTS_INSEQ_INPRT)
336     return (InputPort *)&_inIntValue;
337   else
338     return ElementaryNode::getInputPort(name);
339 }
340
341 int SeqToyNode::getNumberOfOutputPorts() const
342 {
343   return ElementaryNode::getNumberOfOutputPorts()+1;
344 }
345
346 std::list<OutputPort *> SeqToyNode::getSetOfOutputPort() const
347 {
348   list<OutputPort *> ret=ElementaryNode::getSetOfOutputPort();
349   ret.push_back((OutputPort *)&_seqOut);
350   return ret;
351 }
352
353 OutputPort *SeqToyNode::getOutputPort(const std::string& name) const throw(Exception)
354 {
355   if(name==NAME_SEQ_OUTPRT)
356     return (OutputPort *)&_seqOut;
357   else
358     return ElementaryNode::getOutputPort(name);
359 }
360
361 Node *SeqToyNode::simpleClone(ComposedNode *father, bool editionOnly) const
362 {
363   return new SeqToyNode(*this,father);
364 }
365
366 void Seq2ToyNode::execute()
367 {
368   SequenceAny *vals1=(SequenceAny *)_inValue1.getValue();
369   SequenceAny *vals2=(SequenceAny *)_inValue2.getValue();
370   int val=vals1->size();
371   SequenceAny *tmp=SequenceAny::New(Runtime::_tc_int,val);
372   for(int i=0;i<val;i++)
373     {
374       Any *tmp2=AtomAny::New((int)((*vals1)[i]->getDoubleValue()+(*vals2)[i]->getDoubleValue()));
375       tmp->setEltAtRank(i,tmp2);
376       tmp2->decrRef();
377     }
378   _seqOut.put((const void *)tmp);
379   tmp->decrRef();
380 }
381
382 Seq2ToyNode::Seq2ToyNode(const Seq2ToyNode& other, ComposedNode *father):ElementaryNode(other,father),
383                                                                         _seqOut(other._seqOut,this),
384                                                                         _inValue1(other._inValue1,this),
385                                                                         _inValue2(other._inValue1,this)
386 {
387 }
388
389 Seq2ToyNode::Seq2ToyNode(const std::string& name):ElementaryNode(name),_seqOut(NAME_SEQ_OUTPRT,this,Runtime::_tc_double),
390                                                   _inValue1(NAME_SEQ_INPRT1,this,Runtime::_tc_int),
391                                                   _inValue2(NAME_SEQ_INPRT2,this,Runtime::_tc_int)
392 {
393   _implementation=ToyNode::MY_IMPL_NAME;
394   TypeCodeSeq *tc=new TypeCodeSeq("","",Runtime::_tc_double);
395   _inValue1.edSetType(tc);
396   _inValue2.edSetType(tc);
397   tc->decrRef();
398   tc=new TypeCodeSeq("","",Runtime::_tc_int);
399   _seqOut.edSetType(tc);
400   tc->decrRef();
401 }
402
403 int Seq2ToyNode::getNumberOfInputPorts() const
404 {
405   return ElementaryNode::getNumberOfOutputPorts()+2;
406 }
407
408 std::list<InputPort *> Seq2ToyNode::getSetOfInputPort() const
409 {
410   list<InputPort *> ret=ElementaryNode::getSetOfInputPort();
411   ret.push_back((InputPort *)&_inValue1);
412   ret.push_back((InputPort *)&_inValue2);
413   return ret;
414 }
415
416 InputPort *Seq2ToyNode::getInputPort(const std::string& name) const throw(Exception)
417 {
418   if(name==NAME_SEQ_INPRT1)
419     return (InputPort *)&_inValue1;
420   else if(name==NAME_SEQ_INPRT2)
421     return (InputPort *)&_inValue2;
422   else
423     return ElementaryNode::getInputPort(name);
424 }
425
426 int Seq2ToyNode::getNumberOfOutputPorts() const
427 {
428   return ElementaryNode::getNumberOfOutputPorts()+1;
429 }
430
431 std::list<OutputPort *> Seq2ToyNode::getSetOfOutputPort() const
432 {
433   list<OutputPort *> ret=ElementaryNode::getSetOfOutputPort();
434   ret.push_back((OutputPort *)&_seqOut);
435   return ret;
436 }
437
438 OutputPort *Seq2ToyNode::getOutputPort(const std::string& name) const throw(Exception)
439 {
440   if(name==NAME_SEQ_OUTPRT)
441     return (OutputPort *)&_seqOut;
442   else
443     return ElementaryNode::getOutputPort(name);
444 }
445
446 Node *Seq2ToyNode::simpleClone(ComposedNode *father, bool editionOnly) const
447 {
448   return new Seq2ToyNode(*this,father);
449 }
450
451 void Seq3ToyNode::execute()
452 {
453   SequenceAny *vals1=(SequenceAny *)_inValue1.getValue();
454   SequenceAny *vals2=(SequenceAny *)_inValue2.getValue();
455   int val=vals1->size();
456   TypeCodeSeq *tc1=new TypeCodeSeq("","",Runtime::_tc_int);
457   SequenceAny *tmp=SequenceAny::New(tc1,val);
458   tc1->decrRef();
459   for(int i=0;i<val;i++)
460     {
461       Any *anyTemp=(Any *)(*vals1)[i];
462       SequenceAny *anyTemp2=(SequenceAny *)anyTemp;
463       int val2=anyTemp2->size();
464       SequenceAny *tmp2=SequenceAny::New(Runtime::_tc_int,val2);
465       for(int j=0;j<val2;j++)
466         {
467           Any *tmp3=AtomAny::New((int)((*vals1)[i][j]->getDoubleValue()+(*vals2)[i][j]->getDoubleValue()));
468           tmp2->setEltAtRank(j,tmp3);
469           tmp3->decrRef();
470         }
471       tmp->setEltAtRank(i,tmp2);
472       tmp2->decrRef();
473     }
474   _seqOut.put((const void *)tmp);
475   tmp->decrRef();
476 }
477
478 Seq3ToyNode::Seq3ToyNode(const Seq3ToyNode& other, ComposedNode *father):ElementaryNode(other,father),
479                                                                         _seqOut(other._seqOut,this),
480                                                                         _inValue1(other._inValue1,this),
481                                                                         _inValue2(other._inValue1,this)
482 {
483 }
484
485 Seq3ToyNode::Seq3ToyNode(const std::string& name):ElementaryNode(name),_seqOut(NAME_SEQ_OUTPRT,this,Runtime::_tc_double),
486                                                   _inValue1(NAME_SEQ_INPRT1,this,Runtime::_tc_int),
487                                                   _inValue2(NAME_SEQ_INPRT2,this,Runtime::_tc_int)
488 {
489   _implementation=ToyNode::MY_IMPL_NAME;
490   TypeCodeSeq *tc1=new TypeCodeSeq("","",Runtime::_tc_double);
491   TypeCodeSeq *tc2=new TypeCodeSeq("","",tc1);
492   tc1->decrRef();
493   _inValue1.edSetType(tc2);
494   _inValue2.edSetType(tc2);
495   tc2->decrRef();
496   tc1=new TypeCodeSeq("","",Runtime::_tc_int);
497   tc2=new TypeCodeSeq("","",tc1);
498   tc1->decrRef();
499   _seqOut.edSetType(tc2);
500   tc2->decrRef();
501 }
502
503 int Seq3ToyNode::getNumberOfInputPorts() const
504 {
505   return ElementaryNode::getNumberOfOutputPorts()+2;
506 }
507
508 std::list<InputPort *> Seq3ToyNode::getSetOfInputPort() const
509 {
510   list<InputPort *> ret=ElementaryNode::getSetOfInputPort();
511   ret.push_back((InputPort *)&_inValue1);
512   ret.push_back((InputPort *)&_inValue2);
513   return ret;
514 }
515
516 InputPort *Seq3ToyNode::getInputPort(const std::string& name) const throw(Exception)
517 {
518   if(name==NAME_SEQ_INPRT1)
519     return (InputPort *)&_inValue1;
520   else if(name==NAME_SEQ_INPRT2)
521     return (InputPort *)&_inValue2;
522   else
523     return ElementaryNode::getInputPort(name);
524 }
525
526 int Seq3ToyNode::getNumberOfOutputPorts() const
527 {
528   return ElementaryNode::getNumberOfOutputPorts()+1;
529 }
530
531 std::list<OutputPort *> Seq3ToyNode::getSetOfOutputPort() const
532 {
533   list<OutputPort *> ret=ElementaryNode::getSetOfOutputPort();
534   ret.push_back((OutputPort *)&_seqOut);
535   return ret;
536 }
537
538 OutputPort *Seq3ToyNode::getOutputPort(const std::string& name) const throw(Exception)
539 {
540   if(name==NAME_SEQ_OUTPRT)
541     return (OutputPort *)&_seqOut;
542   else
543     return ElementaryNode::getOutputPort(name);
544 }
545
546 Node *Seq3ToyNode::simpleClone(ComposedNode *father, bool editionOnly) const
547 {
548   return new Seq3ToyNode(*this,father);
549 }
550
551 InputLimitPort::InputLimitPort(const InputLimitPort& other, Node *newHelder):InputPort(other,newHelder),
552                                                                              DataPort(other,newHelder),Port(other,newHelder),
553                                                                              _data(0),_initData(0)
554 {
555   if(other._data)
556     _data=other._data->clone();
557   if(other._initData)
558     _initData=other._initData->clone();
559 }
560
561 InputLimitPort::InputLimitPort(const string& name, Node *node)
562                 :InputPort(name, node, Runtime::_tc_double),
563                 DataPort(name, node, Runtime::_tc_double),
564                 Port(node),_data(0),_initData(0)
565 {
566 }
567
568 void InputLimitPort::put(const void *data) throw(ConversionException)
569 {
570   put((Any *)data);
571 }
572
573 InputPort *InputLimitPort::clone(Node *newHelder) const
574 {
575   return new InputLimitPort(*this,newHelder);
576 }
577
578 bool InputLimitPort::edIsManuallyInitialized() const
579 {
580   return _initData!=0;
581 }
582
583 void *InputLimitPort::get() const throw(Exception)
584 {
585   if(!_data)
586     {
587       string what="InputLimitPort::get : no value currently in input whith name \""; what+=_name; what+="\"";
588       throw Exception(what);
589     }
590   return (void *)_data;
591 }
592
593 void InputLimitPort::edRemoveManInit()
594 {
595   if(_initData)
596     _initData->decrRef();
597   _initData=0;
598   InputPort::edRemoveManInit();
599 }
600
601 void InputLimitPort::put(Any *data)
602 {
603   if(_data)
604     _data->decrRef();
605   _data=data;
606   _data->incrRef();
607 }
608
609 void InputLimitPort::exSaveInit()
610 {
611   if(_initData) _initData->decrRef();
612   _initData=_data;
613   _initData->incrRef();
614 }
615
616 void InputLimitPort::exRestoreInit()
617 {
618   if(!_initData)return;
619   if(_data) _data->decrRef();
620   _data=_initData;
621   _data->incrRef();
622 }
623
624 InputLimitPort::~InputLimitPort()
625 {
626   if(_data)
627     _data->decrRef();
628   if(_initData)
629     _initData->decrRef();
630 }
631
632 OutputLimitPort::OutputLimitPort(const OutputLimitPort& other, Node *newHelder):OutputPort(other,newHelder),
633                                                                                 DataPort(other,newHelder),Port(other,newHelder),_data(0)
634 {
635   if(other._data)
636     _data=other._data->clone();
637 }
638
639 OutputLimitPort::OutputLimitPort(const string& name, Node *node, TypeCode *type):OutputPort(name, node, type),DataPort(name, node, type),Port(node),_data(0)
640 {
641 }
642
643 void OutputLimitPort::put(const void *data) throw(ConversionException)
644 {
645   put((Any *)data);
646   OutputPort::put(data);
647 }
648
649 OutputPort *OutputLimitPort::clone(Node *newHelder) const
650 {
651   return new OutputLimitPort(*this,newHelder);
652 }
653
654 void OutputLimitPort::put(Any *data)
655 {
656   if(_data)
657     _data->decrRef();
658   _data=data;
659   _data->incrRef();
660 }
661
662 OutputLimitPort::~OutputLimitPort()
663 {
664   if(_data)
665     _data->decrRef();
666 }
667
668 void LimitNode::init(bool start)
669 {
670   if(start)
671     _current=0.;
672   Node::init(start);
673 }
674
675 void LimitNode::execute()
676 {
677   _current+=_entry.getAny()->getDoubleValue();
678   Any *tmp=AtomAny::New(_current);
679   _counterPort.put((const void *)tmp);
680   tmp->decrRef();
681   bool verdict=(_current<_limit);
682   tmp=AtomAny::New(verdict);
683   _switchPort.put((const void *)tmp);
684   tmp->decrRef();
685 }
686
687 Node *LimitNode::simpleClone(ComposedNode *father, bool editionOnly) const
688 {
689   return new LimitNode(*this,father);
690 }
691
692 std::list<InputPort *> LimitNode::getSetOfInputPort() const
693 {
694   list<InputPort *> ret=ElementaryNode::getSetOfInputPort();
695   ret.push_back((InputPort *)&_entry);
696   return ret;
697 }
698
699 std::list<OutputPort *> LimitNode::getSetOfOutputPort() const
700 {
701   list<OutputPort *> ret=ElementaryNode::getSetOfOutputPort();
702   ret.push_back((OutputPort *)&_switchPort);
703   ret.push_back((OutputPort *)&_counterPort);
704   return ret;
705 }
706
707 InputPort *LimitNode::getInputPort(const std::string& name) const throw(Exception)
708 {
709   if(name==NAME_FOR_SWPORT)
710     return (InputPort *)&_entry;
711   else
712     return ElementaryNode::getInputPort(name);
713 }
714
715 OutputPort *LimitNode::getOutputPort(const std::string& name) const throw(Exception)
716 {
717   if(name==NAME_FOR_SWPORT)
718     return (OutputPort *)&_switchPort;
719   else if(name==NAME_FOR_SWPORT2)
720     return (OutputPort *)&_counterPort;
721   else
722     return ElementaryNode::getOutputPort(name);
723 }
724
725 LimitNode::LimitNode(const LimitNode& other, ComposedNode *father):ElementaryNode(other,father),
726                                                                    _limit(other._limit),_current(other._limit),
727                                                                    _entry(other._entry,this),
728                                                                    _switchPort(other._switchPort,this),
729                                                                    _counterPort(other._counterPort,this)
730 {
731 }
732
733 LimitNode::LimitNode(const string& name):ElementaryNode(name),_limit(0.),_current(0.),
734                                          _entry(NAME_FOR_SWPORT,this),
735                                          _switchPort(NAME_FOR_SWPORT,this, Runtime::_tc_bool),
736                                          _counterPort(NAME_FOR_SWPORT2,this, Runtime::_tc_double)
737 {
738 }