MatchProducer.hpp 3.17 KB
Newer Older
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
1
/*
2
 * Copyright (C) 2014-2021 DBIS Group - TU Ilmenau, All Rights Reserved.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
3
4
5
 *
 * This file is part of the PipeFabric package.
 *
6
7
8
 * 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.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
9
 *
10
11
12
 * 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.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
13
 *
14
15
 * You should have received a copy of the GNU General Public License along with PipeFabric. If not,
 * see <http://www.gnu.org/licenses/>.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
16
17
18
19
20
21
22
23
24
25
26
27
28
 */

#ifndef MatchProducer_hpp_
#define MatchProducer_hpp_
#include "Instance.hpp"
#include "NFAStructure.hpp"
//#include "EventBuffer.hpp"
/**
 * A class to produce a match once the engine reaches the final state. The result can be multiple
 * complex events since we have multiple structures running at the same time.
 */

namespace pfabric {
29
template<class TinPtr, class ToutPtr, class TdepPtr>
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
30
31
class MatchProducer {
public:
32
33
34
	typedef boost::shared_ptr<MatchProducer<TinPtr, ToutPtr, TdepPtr>> MatchProducerPtr;
	typedef typename std::vector<typename Instance<TinPtr, ToutPtr>::InstancePtr> matchesList;
	typedef typename std::vector<typename Instance<TinPtr, ToutPtr>::InstancePtr>::const_iterator matchConstIterator;
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
35
36
37
38
39
40
41
42
43
44
45
46
47
	/**
	 * A constructor to receive and build a match from a 'structure' which has events ids for the match, then get the actual events
	 * from an event buffer to build a match
	 * @param run the structure which has the ids of events
	 * @param buffer the buffer which has the actual events
	 */
	MatchProducer() {
	}
	/**
	 * generate a new tuple which has all corresponding events
	 * @return a new tuple which has all corresponding events
	 */
	ToutPtr produceTogether(
48
			const typename NFAStructure<TinPtr, ToutPtr, TdepPtr>::NFAStructurePtr& str) {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
49
		//int index = 0;
50
		typename MatchProducer<TinPtr, ToutPtr, TdepPtr>::matchesList matches;
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
51

52
		std::vector<typename Instance<TinPtr, ToutPtr>::InstancePtr> l =
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
53
				str->getEvents();
54
		for (typename std::vector<typename Instance<TinPtr, ToutPtr>::InstancePtr>::const_iterator i =
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
				l.begin(); i != l.end(); i++) {
			auto tup = (*i)->getOriginalEvent();
			for (int j = 0; j < tup->size(); j++) {
				//data.at(index++) = (tup->operator [](j));
			}
			//data.at(index++) = (*i)->getState();
			//data.at(index++) = (*i)->getSequenceInComplex();
		}
		//return ToutPtr(new Tout(/*data*/)); // create new tuple which combine all the matching events
	}

	/**
	 * get the list of all matches for this structure
	 * @return a list of all matches for this structure
	 */
	matchesList produceAsList(
71
			const typename NFAStructure<TinPtr, ToutPtr, TdepPtr>::NFAStructurePtr& str) {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
72
73
74
75
76
77
78
79
		return str->getEvents();
	}

	/**
	 * number of matches in this structure
	 * @return the size
	 */
	int sizeOfMatch(
80
			const typename NFAStructure<TinPtr, ToutPtr, TdepPtr>::NFAStructurePtr& str) {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
81
82
83
84
85
86
87
88
89
90
91
		return str->getSequence();
	}
	/**
	 * destructor
	 */
	virtual ~MatchProducer() {
	}
};

}
#endif /* MatchProducer_H_ */