Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
RangeManager.h
Go to the documentation of this file.
1#pragma once
2#include <misc/gen/Range.h>
3#include <misc/global.h>
4
5namespace sf
6{
7
26{
27 public:
31 RangeManager() = default;
32
36 ~RangeManager() = default;
37
42 bool isFlushable() const;
43
48 bool flush();
49
56 void setManaged(const Range& r);
57
62 [[nodiscard]] const Range& getManaged() const;
63
68 [[nodiscard]] const Range::Vector& getAccessibles() const;
69
74 [[nodiscard]] const Range::Vector& getRequests() const;
75
81 [[nodiscard]] const Range::Vector& getActualRequests() const;
82
89 [[nodiscard]] bool isAccessible(const Range& r) const;
90
94 enum EResult : int
95 {
97 rmOutOfRange = -1,
99 rmInaccessible = 0,
101 rmAccessible = 1
102 };
103
112
121 bool setAccessible(const Range::Vector& rl, Range::Vector& rl_req);
122
129 bool setAccessible(const Range& r, Range::Vector& rl_req);
130
136
143 bool setAutoManaged(bool flag = true);
144
148 void unitTest(Range::Vector* accessibles, Range::Vector* actual_requests = nullptr, Range::Vector* requests = nullptr);
149
155 void setDebug(bool debug);
156
157 private:
161 bool _autoManaged{false};
165 Range _managedRange;
169 Range::Vector _accessibles;
173 Range::Vector _requests;
177 Range::Vector _actualRequests;
181 bool _debug{false};
182};
183
184inline void RangeManager::setDebug(bool debug)
185{
186 _debug = debug;
187}
188
189inline bool RangeManager::setAutoManaged(bool flag)
190{
191 std::swap(flag, _autoManaged);
192 return flag;
193}
194
195inline const Range& RangeManager::getManaged() const
196{
197 return _managedRange;
198}
199
200inline void RangeManager::setManaged(const Range& r)
201{
202 _managedRange = r;
203}
204
206{
207 return _accessibles;
208}
209
211{
212 return _actualRequests;
213}
214
216{
217 return _requests;
218}
219
220}// namespace sf
This class manages range requests made by clients identified by ID's in the ranges.
Definition RangeManager.h:26
bool setAccessible(const Range &r, Range::Vector &rl_req)
Same as setAccessible but now for a single Range element.
RangeManager()=default
Default constructor.
void setDebug(bool debug)
Sets the debug flag for this instance.
Definition RangeManager.h:184
void unitTest(Range::Vector *accessibles, Range::Vector *actual_requests=nullptr, Range::Vector *requests=nullptr)
Test function for set privates during a unit test.
bool setAutoManaged(bool flag=true)
Determines if the managed range is automatically determined and set when setAccessible is called....
Definition RangeManager.h:189
void flushRequests(Range::id_type id)
Flushes all the requests having the range identifier.
const Range::Vector & getRequests() const
Retrieves the current request list.
Definition RangeManager.h:215
void setManaged(const Range &r)
Sets the limiting range on requests. If the managed range is not set (empty) requests get the rmOutOf...
Definition RangeManager.h:200
bool isAccessible(const Range &r) const
Returns if this range is accessible. Using the managed range and the current accessible ranges as a r...
~RangeManager()=default
Destructor.
EResult request(const Range &r, Range::Vector &rrl)
Called by client to request access for a range.
bool flush()
Flushes all ranges and range list as if it were initialized.
bool setAccessible(const Range::Vector &rl, Range::Vector &rl_req)
This function is called by a derived server class to as a reply to an event. The function will return...
bool isFlushable() const
Checks if flushing has any effect.
const Range::Vector & getActualRequests() const
Retrieves actual request list of ranges missing to fulfill requests. These are the resulting-request...
Definition RangeManager.h:210
const Range & getManaged() const
Retrieves the limit on the maximum requestable range span from zero.
Definition RangeManager.h:195
EResult
Enumerate for return values used by request method.
Definition RangeManager.h:95
const Range::Vector & getAccessibles() const
Retrieves the current accessible list of ranges.
Definition RangeManager.h:205
Type to contain and manipulate range lists.
Definition Range.h:67
Class to manage 64-bit integer ranges.
Definition Range.h:52
RANGE::id_type id_type
Integer type used for the ID.
Definition Range.h:61
#define _MISC_CLASS
Definition misc/global.h:40
Definition Application.h:10