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