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