FSM Library - C++ version
FsmNode.h
1 /*
2  * Copyright. GaĆ«l Dottel, Christoph Hilken, and Jan Peleska 2016 - 2021
3  *
4  * Licensed under the EUPL V.1.1
5  */
6 #ifndef FSM_FSM_FSMNODE_H_
7 #define FSM_FSM_FSMNODE_H_
8 
9 #include <iostream>
10 #include <memory>
11 #include <string>
12 #include <unordered_set>
13 #include <unordered_map>
14 #include <utility>
15 #include <vector>
16 
17 class FsmTransition;
19 class OutputTree;
20 class Tree;
21 class OutputTrace;
22 class InputTrace;
23 class OFSMTable;
24 class PkTable;
25 class DFSMTableRow;
26 
27 class FsmNode : public std::enable_shared_from_this<FsmNode>
28 {
29 private:
30  std::vector<FsmTransition> transitions;
31  int id;
32  std::string name;
33  bool visited;
34  int color;
35  std::shared_ptr<FsmPresentationLayer> presentationLayer;
36  std::shared_ptr<std::pair<std::shared_ptr<FsmNode>, std::shared_ptr<FsmNode>>> derivedFromPair;
37 public:
38  const static int white = 0;
39  const static int grey = 1;
40  const static int black = 2;
41  FsmNode(const int id, const std::shared_ptr<FsmPresentationLayer> presentationLayer);
42  FsmNode(const int id, const std::string & name, const std::shared_ptr<FsmPresentationLayer> presentationLayer);
43  void addTransition(const FsmTransition & transition);
44  std::vector<FsmTransition> getTransitions() const;
45  int getId() const;
46  std::string getName() const;
47  bool hasBeenVisited() const;
48  void setVisited();
49  void setPair(const std::shared_ptr<FsmNode> l, const std::shared_ptr<FsmNode> r);
50  void setPair(const std::shared_ptr<std::pair<std::shared_ptr<FsmNode>, std::shared_ptr<FsmNode>>> p);
51  bool isDerivedFrom(const std::shared_ptr<std::pair<std::shared_ptr<FsmNode>, std::shared_ptr<FsmNode>>> p) const;
52  std::shared_ptr<std::pair<std::shared_ptr<FsmNode>, std::shared_ptr<FsmNode>>> getPair() const;
53  std::shared_ptr<FsmNode> apply(const int e, OutputTrace & o);
54  OutputTree apply(const InputTrace & itrc);
55 
63  std::unordered_set<std::shared_ptr<FsmNode>> after(const InputTrace & itrc);
64 
75  std::vector<std::shared_ptr<FsmNode>> after(const int x);
76  std::unordered_set<std::shared_ptr<FsmNode>> afterAsSet(const int x);
77  void setColor(const int color);
78  int getColor();
79  std::shared_ptr<DFSMTableRow> getDFSMTableRow(const int maxInput);
80  bool distinguished(const std::shared_ptr<FsmNode> otherNode, const std::vector<int>& iLst);
81  std::shared_ptr<InputTrace> distinguished(const std::shared_ptr<FsmNode> otherNode, std::shared_ptr<Tree> w);
82 
91  InputTrace calcDistinguishingTrace(const std::shared_ptr<FsmNode> otherNode, const std::vector<std::shared_ptr<PkTable>>& pktblLst, const int maxInput);
92 
102  InputTrace calcDistinguishingTrace(const std::shared_ptr<FsmNode> otherNode, const std::vector<std::shared_ptr<OFSMTable>>& ofsmTblLst, const int maxInput, const int maxOutput);
103  bool isObservable() const;
104 
108  bool isDeterministic() const;
109  friend std::ostream & operator<<(std::ostream & out, const FsmNode & node);
110  friend bool operator==(FsmNode const & node1, FsmNode const & node2);
111 };
112 #endif //FSM_FSM_FSMNODE_H_
InputTrace calcDistinguishingTrace(const std::shared_ptr< FsmNode > otherNode, const std::vector< std::shared_ptr< PkTable >> &pktblLst, const int maxInput)
Definition: FsmNode.cpp:245
std::unordered_set< std::shared_ptr< FsmNode > > after(const InputTrace &itrc)
Definition: FsmNode.cpp:139
Definition: DFSMTableRow.h:17
bool isDeterministic() const
Definition: FsmNode.cpp:395
Definition: OutputTree.h:15
Definition: PkTable.h:24
Definition: Tree.h:19
Definition: OFSMTable.h:37
Definition: InputTrace.h:15
Definition: FsmPresentationLayer.h:16
Definition: FsmNode.h:27
Definition: OutputTrace.h:15
Definition: FsmTransition.h:15