Version: 9.16.0
InGate.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
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 "InGate.hxx"
21#include "Node.hxx"
22
23//#define _DEVDEBUG_
24#include "YacsTrace.hxx"
25
26#include <algorithm>
27
28using namespace YACS::ENGINE;
29using namespace std;
30
31const char InGate::NAME[]="InGate";
32
33InGate::InGate(Node *node):Port(node)
34{
35}
36
38{
39}
40
42{
43 return NAME;
44}
45
47{
48 for(list< std::pair<OutGate *, bool> >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
49 ((*iter).first)->edRemoveInGate(this,false);
50 _backLinks.clear();
51}
52
54{
55private:
57public:
58 ItemCmp(OutGate *itf):_itf(itf) { }
59 bool operator()(const std::pair<OutGate *,bool>& elt) const { return elt.first==_itf; }
60};
61
63
69{
70 DEBTRACE("InGate::exNotifyFromPrecursor");
71 list< pair<OutGate *, bool> >::iterator iter(std::find_if(_backLinks.begin(),_backLinks.end(),ItemCmp(from)));
72 if(iter==_backLinks.end())
73 throw YACS::Exception("InGate::exNotifyFromPrecursor : precursor not found !");
74 (*iter).second=true;
75 if(exIsReady())
77}
78
80
84{
85 if(_node)
87}
88
90
94{
95 if(_node)
97}
98
100{
101 list< pair<OutGate *, bool> >::iterator iter(std::find_if(_backLinks.begin(),_backLinks.end(),ItemCmp(from)));
102 if(iter!=_backLinks.end())
103 (*iter).second=false;
104 else
105 _backLinks.push_back(pair<OutGate *, bool>(from,false));
106}
107
109{
110 list< pair<OutGate *, bool> >::iterator iter(std::find_if(_backLinks.begin(),_backLinks.end(),ItemCmp(from)));
111 if(iter!=_backLinks.end())
112 _backLinks.erase(iter);
113}
114
116{
117 return _backLinks.size();
118}
119
121{
122 for(list< std::pair<OutGate *, bool> >::iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
123 (*iter).second=false;
124}
125
127{
128 bool isReady(true);
129 for(list< std::pair<OutGate *, bool> >::const_iterator iter=_backLinks.begin();iter!=_backLinks.end() && isReady;iter++)
130 isReady=(*iter).second;
131 return isReady;
132}
133
134std::list<OutGate *> InGate::getBackLinks()
135{
136 list<OutGate *> listo;
137 for(list< std::pair<OutGate *, bool> >::const_iterator iter=_backLinks.begin();iter!=_backLinks.end();iter++)
138 listo.push_back(iter->first);
139 return listo;
140}
141
143{
144 list< std::pair<OutGate *, bool> >::iterator iter(std::find_if(_backLinks.begin(),_backLinks.end(),ItemCmp(from)));
145 if(iter!=_backLinks.end())
146 (*iter).second=true;
147 else
148 throw YACS::Exception("InGate::setPrecursorDone : precursor not found !");
149}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
bool operator()(const std::pair< OutGate *, bool > &elt) const
Definition: InGate.cxx:59
OutGate * _itf
Definition: InGate.cxx:56
ItemCmp(OutGate *itf)
Definition: InGate.cxx:58
void setPrecursorDone(OutGate *fromgate)
Definition: InGate.cxx:142
void edDisconnectAllLinksToMe()
Definition: InGate.cxx:46
void exNotifyFailed()
Notify this port that an upstream node connected by a control flow link has failed.
Definition: InGate.cxx:83
void edRemovePrecursor(OutGate *fromgate)
Definition: InGate.cxx:108
std::string getNameOfTypeOfCurrentInstance() const
Definition: InGate.cxx:41
std::list< OutGate * > getBackLinks()
Definition: InGate.cxx:134
static const char NAME[]
Definition: InGate.hxx:40
void exNotifyDisabled()
Notify this port that an upstream node connected by a control flow link has been disabled.
Definition: InGate.cxx:93
bool exIsReady() const
Definition: InGate.cxx:126
void exNotifyFromPrecursor(OutGate *fromgate)
Notify this port that an upstream node connected by a control flow link is finished.
Definition: InGate.cxx:68
virtual ~InGate()
Definition: InGate.cxx:37
int getNumberOfBackLinks() const
Definition: InGate.cxx:115
std::list< std::pair< OutGate *, bool > > _backLinks
Definition: InGate.hxx:42
void edAppendPrecursor(OutGate *fromgate)
Definition: InGate.cxx:99
Base class for all nodes.
Definition: Node.hxx:70
virtual void exUpdateState()
Update the node state.
Definition: Node.cxx:206
virtual void exDisabledState()
Notify this node that it has been disabled.
Definition: Node.cxx:232
virtual void exFailedState()
Notify this node that its execution has failed.
Definition: Node.cxx:219
Base class for all ports.
Definition: Port.hxx:43
Node * _node
Definition: Port.hxx:55