Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ResultDataRequester.h
Go to the documentation of this file.
1#pragma once
4#include <misc/gen/Sustain.h>
5#include <misc/gen/TBitSet.h>
6
7namespace sf
8{
16{
17 public:
22 {
27 reDataValid = reUserLocal,
32 reTimedOut = reUserLocal + 1,
33 };
34
39
44
49
54
59
66 void release();
67
72 bool requestIndex(size_type index);
73
79 bool requestIndex(const Range& range);
80
86 bool requestData(const Range& range);
87
92 void setTimeout(const TimeSpec& timeout);
93
98 void reset();
99
103 [[nodiscard]] const Range& getIndexRange() const;
104
108 [[nodiscard]] const Range& getDataRange() const;
109
116
120 [[nodiscard]] const ResultDataHandler* getHandler() const;
121
144
151 const char* getStateName(int state = -2);
152
156 [[nodiscard]] EState getState() const;
157
161 std::ostream& getStatus(std::ostream& os);
162
163 private:
168
172 bool sustain(const timespec& t);
173
178
182 void resultCallback(ResultDataTypes::EEvent event, const ResultData& caller, ResultData& link, const Range& rng, bool sameInst);
183
187 ResultData* _rdIndex{nullptr};
191 PtrVector _rdDataList;
195 ElapseTimer _timeoutTimer;
196
200 bool process();
201
205 EState _state{drsReady};
209 EState _statePrevious{drsReady};
213 EState _stateWait{drsReady};
214
218 bool setState(EState state);
219
225 bool setError(const std::string& text);
226
233 bool waitForState(EState state);
234
239 void passIndexEvent(EReqEvent event);
240
244 struct WorkData
245 {
249 WorkData()
250 {
251 clear();
252 }
253
257 void clear()
258 {
259 _indexRequest = false;
260 _dataRequest._bits = 0;
261 _range.clear();
262 _index.clear();
263 _dataRequest._bits = 0;
264 _dataAccess._bits = 0;
265 }
266
270 Range _range;
274 Range _index;
278 bool _indexRequest{};
282 TSet<int> _dataRequest;
286 TSet<int> _dataAccess;
287 };
288
292 WorkData _work;
296 ResultDataHandler* _handler;
300 bool _byPass;
301};
302
304{
305 return _state;
306}
307
308inline void ResultDataRequester::setTimeout(const TimeSpec& timeout)
309{
310 _timeoutTimer.set(timeout);
311}
312
314{
315 return requestIndex(Range(index, index + 1));
316}
317
319{
320 return _handler;
321}
322
324{
325 return _work._index;
326}
327
329{
330 return _work._range;
331}
332}// namespace sf
Timer for turning true when a certain amount of time has passed.
Definition ElapseTimer.h:12
void set(const timespec &t)
Setting the elapse time and enabling the timer.
size_t size_type
Type used for size of vectors.
Definition InformationBase.h:38
Class to manage 64-bit integer ranges.
Definition Range.h:52
Class used to give a ResultData instance access to virtual method of a derived class.
Definition ResultDataHandler.h:12
Handles requests and events for indexed data sources.
Definition ResultDataRequester.h:16
const ResultDataHandler * getHandler() const
Returns the linked handler hook object.
Definition ResultDataRequester.h:318
const char * getStateName(int state=-2)
Gets the name of the state.
virtual ~ResultDataRequester()
Virtual destructor.
void detachData(ResultData *rd)
Unhooks the result-data entries to this instance.
std::ostream & getStatus(std::ostream &os)
For debugging purposes only it writes the status to the output stream.
void attachData(ResultData *rd)
Hooks the result-data entries to this instance.
void setTimeout(const TimeSpec &timeout)
Sets the time-out in ms in which a request is allowed too take before it is timed out....
Definition ResultDataRequester.h:308
EReqEvent
Additional local user result data events.
Definition ResultDataRequester.h:22
void attachIndex(ResultData *rd)
Links the single index result-data entry to this instance.
void release()
Releases all the result-data entries and set handlers.
EState
Enumerate for states.
Definition ResultDataRequester.h:126
@ drsGetIndex
Definition ResultDataRequester.h:132
@ drsTryData
Definition ResultDataRequester.h:136
@ drsApply
Definition ResultDataRequester.h:140
@ drsGetData
Definition ResultDataRequester.h:138
@ drsReadIndex
Definition ResultDataRequester.h:134
@ drsReady
Definition ResultDataRequester.h:130
@ drsWait
Definition ResultDataRequester.h:142
EState getState() const
Definition ResultDataRequester.h:303
ResultDataRequester()
Default constructor.
void setHandler(ResultDataHandler *handler)
Sets an event handler for this instance to which all result events are rerouted after it handled its ...
const Range & getIndexRange() const
Gets the index range the requester is working on or has done.
Definition ResultDataRequester.h:323
const Range & getDataRange() const
Gets the data range the requester is working on or has done.
Definition ResultDataRequester.h:328
void reset()
Called when results are attached or detached and when a time-out occurred. Sets all members to their ...
bool requestIndex(const Range &range)
Requests a range of the data using multiple index ranges.
bool requestIndex(size_type index)
Requests a range of the data using a single index range.
Definition ResultDataRequester.h:313
bool requestData(const Range &range)
Directly requests a range of the data without using the index.
This base class contains all local types of used in the sf::ResultData class. Multiple inheritance m...
Definition ResultDataTypes.h:25
EEvent
Event enumerate values used in broadcasting where global events have a negative value.
Definition ResultDataTypes.h:46
Class for creating and referencing global created data called result data. This class allows linking ...
Definition ResultData.h:20
Definition ResultDataHandler.h:33
Template to make the sustain system call a class method regularly.
Definition Sustain.h:184
#define _GII_CLASS
Definition gii/global.h:38
Definition Application.h:10
Class wrapper for timespec structure to modify.
Definition TimeSpec.h:12