ForwardEdge.hpp 3.52 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 * Copyright (C) 2014-2021 DBIS Group - TU Ilmenau, All Rights Reserved.
 *
 * This file is part of the PipeFabric package.
 *
 * PipeFabric is free software: you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * PipeFabric is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with PipeFabric. If not,
 * see <http://www.gnu.org/licenses/>.
 */

aliahmadbutt4's avatar
aliahmadbutt4 committed
18

Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55


#ifndef ForwardEdge_hpp
#define ForwardEdge_hpp

#include "NFAEdge.hpp"
#include "../state/NFAState.hpp"
namespace pfabric {
template<class Tin>
class NFAState;
/**
 * @brief an object represents a forward edge in our engine, the CEP uses this kind
 * of edge to jump from state to state
 */
template<class Tin, class Tout, class Tdep>
class ForwardEdge: public NFAEdge<Tin, Tout, Tdep> {
public:
	typedef ns_types::SharedPtr<ForwardEdge<Tin ,Tout, Tdep>> ForwardEdgePtr;
	/**
	 * default constructor to set the ID of the edge
	 * @param edge_id the edge ID assigned to this edge
	 */
	ForwardEdge(int edgeID): NFAEdge<Tin, Tout, Tdep>(edgeID) {}
	/**
	 * default constructor to set the ID of the edge and its predicate
	 * @param edge_id the edge ID assigned to this edge
	 * @param predicate the predicate assigned to this edge
	 */
	ForwardEdge(int edgeID, typename NFAEdge<Tin, Tout, Tdep>::EdgePredicate predicate): NFAEdge<Tin, Tout, Tdep>(edgeID, predicate) {}
	/**
	 * virtual destructor
	 */
	virtual ~ForwardEdge() {}
	/**
	 * output member variable information.
	 * @param out the output stream handle.
	 */
aliahmadbutt4's avatar
aliahmadbutt4 committed
56
	virtual void write(std::ostream& out = std::cout) const {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
		out << "This is a forward edge with ID(" << this->edgeID
					<< ") to destination state " << destState->getStateID();
	}
	/**
	 * set the destination state of this edge.
	 * @param dest_state the destination state to set to.
	 */
	void setDestState(NFAState<Tin>*  destState) { this->destState = destState; }

	/**
	 * equality comparison operator.
	 * @param rhs the input edge for this edge to compare to
	 * @return true iff this edge has the same predicate and destination  state as that of rhs
	 */
	 bool operator ==(const ForwardEdge& rhs) const { return NFAEdge<Tin, Tout, Tdep>::operator ==(rhs) && rhs.getDestState() == destState; }

	/**
	 * inequality comparison operator.
	 * @param rhs the input edge for this edge to compare to
	 * @return true iff this edge does not have the same predicate and
	 * destination state as that of rhs
	 */
	 bool operator !=(const ForwardEdge& rhs) const { return !(this->operator ==(rhs)); }
	/**
	 * get the edge type (forward edge)
	 * @return as above
	 */
	const typename NFAEdge<Tin, Tout, Tdep>::EdgeType getEdgeType() const { return NFAEdge<Tin, Tout, Tdep>::Forward; }
	/**
	 * get the destination state of this edge. It can be kleene, final and negated states
	 * @return the destination state to this edge.
	 */
	NFAState<Tin>* getDestState() const { return this->destState; }

private:
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
92
	/**
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
93
94
95
96
97
98
99
100
101
	 * this variable stores the destination state of this forward edge.
	 * it can be kleene, final and negated states
	 */
	NFAState<Tin>*  destState;
};
//class ForwardEdge;
}//namespace pfabric

#endif //ForwardEdge_hpp