-
Notifications
You must be signed in to change notification settings - Fork 0
/
RealProducer.h
37 lines (35 loc) · 1.34 KB
/
RealProducer.h
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
#ifndef REALPRODUCER_H
// imports
#include "Producer.h" // for producers
#include "Point.h" // for the point conversion
/*!class that implements the RealProducer*/
class RealProducer : public Producer<std::pair<float, float>>
{
public:
/**
* constructor of RealProducer
* @param buffer: buffer to use [Buffer]
* @set Producer [Producer]
*/
explicit RealProducer(Buffer<std::pair<float, float>>& buffer) : Producer<std::pair<float, float>>(buffer) {};
/**
* 'produce' function that does the actual work
* @param new_point: point to produce [std::pair<float,float>]
* @return finished: whether task is finished or not [Boolean]
*/
bool produce(std::pair<float, float>* new_point) override
{
// determine the next point
m_point.m_point = m_point.getNextPoint(m_point.m_point);
// return reference to next point
*new_point = m_point.m_point;
// check whether enough points were already produced. If yes, break up, otherwise continue
if (i < m_numbers - 1) { i++; return false;}
else { return true; }
}
private:
Point m_point; // point object
unsigned int i = 0; // counter for number of produced points by current producer
const unsigned int m_numbers = 1e8; // max number of points to produce per producer = 10^8
};
#endif // !REALPRODUCER_H