Salome HOME
Compilation on Windows
[modules/yacs.git] / src / engine / ForLoop.hxx
1 // Copyright (C) 2006-2013  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
20 #ifndef __FORLOOP_HXX__
21 #define __FORLOOP_HXX__
22
23 #include "YACSlibEngineExport.hxx"
24 #include "AnyInputPort.hxx"
25 #include "AnyOutputPort.hxx"
26 #include "Loop.hxx"
27
28 namespace YACS
29 {
30   namespace ENGINE
31   {
32     class YACSLIBENGINE_EXPORT ForLoop : public Loop
33     {
34     protected:
35       static const char NAME_OF_INDEX[];
36       static const char NAME_OF_NSTEPS_NUMBER[];
37       AnyInputPort _nbOfTimesPort;
38       AnyOutputPort _indexPort;
39     public:
40       ForLoop(const ForLoop& other, ComposedNode *father, bool editionOnly);
41       ForLoop(const std::string& name);
42       void exUpdateState();
43       void init(bool start=true);
44       InputPort *edGetNbOfTimesInputPort() { return &_nbOfTimesPort; }
45       Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
46       InputPort* getInputPort(const std::string& name) const throw(Exception);
47       OutPort *getOutPort(const std::string& name) const throw(Exception);
48       OutputPort *getOutputPort(const std::string& name) const throw(Exception);
49       std::list<InputPort *> getLocalInputPorts() const;
50       std::list<OutputPort *> getLocalOutputPorts() const;
51       std::list<OutputPort *> getSetOfOutputPort() const;
52       virtual void accept(Visitor *visitor);
53       InputPort *getDecisionPort() const { return (InputPort *)&_nbOfTimesPort; }
54       OutputPort *edGetIndexPort() { return &_indexPort; }
55       virtual std::string typeName() {return "YACS__ENGINE__ForLoop";}
56     protected:
57       YACS::Event updateStateOnFinishedEventFrom(Node *node);
58       void checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed,
59                         bool direction, LinkInfo& info) const;
60       void checkControlDependancy(OutPort *start, InPort *end, bool cross,
61                                   std::map < ComposedNode *,  std::list < OutPort * >, SortHierarc >& fw,
62                                   std::vector<OutPort *>& fwCross,
63                                   std::map< ComposedNode *, std::list < OutPort *>, SortHierarc >& bw,
64                                   LinkInfo& info) const;
65     };
66   }
67 }
68
69 #endif