-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.hpp
123 lines (107 loc) · 3.51 KB
/
task.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
56
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* task.hpp
*
* \date 14/mag/2010
* \author Daniele De Sensi ([email protected])
* =========================================================================
* Copyright (C) 2010-2014, Daniele De Sensi ([email protected])
*
* This file is part of ffProbe.
*
* ffProbe is free software: you can redistribute it and/or
* modify it under the terms of the Lesser GNU General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
* ffProbe 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
* Lesser GNU General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public
* License along with ffProbe.
* If not, see <http://www.gnu.org/licenses/>.
*
* =========================================================================
*
* This file contains the definition of the task passed by the stages of the pipeline.
*/
#ifndef TASK_HPP_
#define TASK_HPP_
#include "flow.hpp"
#include <ff/squeue.hpp>
#include <iostream>
/**
* The task generated by the first stage of the pipeline.
*/
class Task{
private:
uint numWorkers; ///<Number of workers of the pipeline.
ff::squeue<hashElement>
**flowsToAdd,///< A list of flows to add.
*flowsToExport;///< A list of flows to export.
bool eof; ///< True if the eof of a .pcap file is arrived.
/**
* The timestamp will be taken per task instead of per packet.
* In this way we avoid the overhead due to an huge number of call of "time(NULL)".
* Moreover, such that the packets belonging to the same task will be captured in
* very short time between each other (because the read is non blocking),
* the timestamps of these packets will be equal.
*/
time_t timestamp;
public:
/**
* Constructor of the task.
* \param numWorkers Number of workers of the pipeline.
*/
Task(uint numWorkers);
/**
* Denstructor of the task.
*/
~Task();
/**
* Sets the timestamp of the task.
* \param t The timestamp.
*/
void setTimestamp(time_t t);
/**
* Returns the timestamp of the task.
* \return The timestamp of the task.
*/
time_t getTimestamp();
/**
* Adds an hashElement to the list of flows to export.
* \param h The hashElement.
*/
void addFlowToExport(hashElement& h);
/**
* Returns a pointer to the list of flows to export.
* \return A pointer to the list of flows to export.
*/
ff::squeue<hashElement>* getFlowsToExport();
/**
* Returns a pointer to the list of the flows to add.
* \return A pointer to the list of the flows to add.
*/
ff::squeue<hashElement>* getFlowsToAdd(const int i);
/**
* Adds the hashElement h for the i-th worker.
* \param h The hashElement to add.
* \param i The worker that have to add the flow.
*/
void setFlowToAdd(hashElement& h, const int i);
/**Sets EOF. **/
void setEof();
/**Resets EOF.**/
void resetEof();
/**
* Returns true if EOF of a .pcap file is arrived.
* \return True if EOF is arrived, otherwise returns false.
*/
bool isEof();
/**
* Returns the number of workers.
* \return The number of workers.
*/
int getNumWorkers();
};
#endif /* TASK_HPP_ */