Version: 8.3.0
LinkInfo.hxx
Go to the documentation of this file.
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 #ifndef __LINKINFO_HXX__
21 #define __LINKINFO_HXX__
22 
23 #include "YACSlibEngineExport.hxx"
24 #include "Exception.hxx"
25 
26 #include <vector>
27 #include <list>
28 #include <map>
29 #include <set>
30 
31 namespace YACS
32 {
33  namespace ENGINE
34  {
35  class Node;
36  class InGate;
37  class InPort;
38  class OutGate;
39  class OutPort;
40  class ComposedNode;
41  class CollectorSwOutPort;
42 
43  typedef enum
44  {
46  I_USELESS = 42,
47  I_BACK = 43,//In loop context
48  I_BACK_USELESS = 44,//In loop context - Not implemented yet
49  I_BACK_CRAZY = 45,//Out of loop context
50  I_DFDS = 46,
51  I_ALL = 49,
52  } InfoReason;
53 
54  typedef enum
55  {
56  W_COLLAPSE = 141,
64  W_ALL = 149
65  } WarnReason;
66 
67  typedef enum
68  {
76  E_ALL = 249
77  } ErrReason;
78 
83  {
84  private:
86  unsigned int _level;
87  unsigned char _levelOfInfo;
88  std::vector<InPort *> _unsetInPort;
89  std::vector<InPort *> _onlyBackDefined;
90  std::set< std::pair<Node *, Node *> > _uselessLinks;
91  std::map<InfoReason, std::vector< std::pair<OutPort *,InPort *> > > _infos;
92  std::map<WarnReason, std::vector< std::vector< std::pair<OutPort *,InPort *> > > > _collapse;
93  std::map<ErrReason, std::vector< std::pair<OutPort *,InPort *> > > _errors;
94  std::vector<CollectorSwOutPort *> _errorsOnSwitchCases;
95  public:
96  LinkInfo(unsigned char level);
97  void clearAll();
98  void startCollapseTransac();
99  void endCollapseTransac() throw(Exception);
100  void setPointOfView(ComposedNode *pov);
101  void pushInfoLink(OutPort *semStart, InPort *end, InfoReason reason);
102  void pushWarnLink(OutPort *semStart, InPort *end, WarnReason reason);
103  void pushErrLink(OutPort *semStart, InPort *end, ErrReason reason) throw(Exception);
104  void pushErrSwitch(CollectorSwOutPort *collector) throw(Exception);
105  void pushUselessCFLink(Node *start, Node *end);
106  void takeDecision() const throw(Exception);
107  //Typically methods for high level use.
108  std::string getGlobalRepr() const;
109  std::string getInfoRepr() const;
110  std::string getWarnRepr() const;
111  std::string getErrRepr() const;
112  bool areWarningsOrErrors() const;
113  unsigned getNumberOfInfoLinks(InfoReason reason) const;
114  unsigned getNumberOfWarnLinksGrp(WarnReason reason) const;
115  unsigned getNumberOfErrLinks(ErrReason reason) const;
116  std::set< std::pair<Node *, Node *> > getInfoUselessLinks() const;
117  std::pair<OutPort *, InPort *> getInfoLink(unsigned id, InfoReason reason) const;
118  std::vector< std::pair<OutPort *, InPort *> > getWarnLink(unsigned id, WarnReason reason) const;
119  std::pair<OutPort *, InPort *> getErrLink(unsigned id, ErrReason reason) const;
120  protected:
121  static std::string getStringReprOfI(InfoReason reason);
122  static std::string getStringReprOfW(WarnReason reason);
123  static std::string getStringReprOfE(ErrReason reason);
124  static std::string printThereIsAre(unsigned val, const std::string& other);
125  public:
126  static const unsigned char ALL_STOP_ASAP = 1;
127  static const unsigned char ALL_DONT_STOP = 2;
128  static const unsigned char WARN_ONLY_DONT_STOP = 3;
129  };
130  }
131 }
132 
133 #endif