Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::RangeManager Class Reference

This class manages range requests made by clients identified by ID's in the ranges.
More...

#include <RangeManager.h>

Public Types

enum  EResult : int { rmOutOfRange = -1 , rmInaccessible = 0 , rmAccessible = 1 }
 Enumerate for return values used by request method. More...
 

Public Member Functions

 RangeManager ()=default
 Default constructor.
 
 ~RangeManager ()=default
 Destructor.
 
bool isFlushable ()
 Checks if flushing has any effect.
 
bool flush ()
 Flushes all ranges and range list as if it were initialized.
 
void setManaged (const Range &r)
 Sets the limiting range on requests. If the managed range is not set (empty) requests get the rmOutOfRange result. Also for when the requested range is outside the managed range.
 
const RangegetManaged () const
 Retrieves the limit on the maximum requestable range span from zero.
 
const Range::VectorgetAccessibles () const
 Retrieves the current accessible list of ranges.
 
const Range::VectorgetRequests () const
 Retrieves the current request list.
 
const Range::VectorgetActualRequests () const
 Retrieves actual request list of ranges missing to fulfill requests.
These are the resulting-requested ranges when all requests are added up.
 
bool isAccessible (const Range &r) const
 Returns if this range is accessible. Using the managed range and the current accessible ranges as a reference.
 
EResult request (const Range &r, Range::Vector &rrl)
 Called by client to request access for a range.
 
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 all ranges and owners in an owned range list which request are satisfied/fulfilled with the passed ranges.
 
bool setAccessible (const Range &r, Range::Vector &rl_req)
 Same as setAccessible but now for a single Range element.
 
void flushRequests (Range::id_type id)
 Flushes all the requests having the range identifier.
 
bool setAutoManaged (bool flag=true)
 Determines if the managed range is automatically determined and set when setAccessible is called. Making a call to setManaged unnecessary when set to true.
 
void unitTest (Range::Vector *accessibles, Range::Vector *actual_requests=nullptr, Range::Vector *requests=nullptr)
 Test function for set privates during a unit test.
 
void setDebug (bool debug)
 Sets the debug flag for this instance.
 

Detailed Description

This class manages range requests made by clients identified by ID's in the ranges.

A server sets the range which is managed.
Multiple clients make requests for ranges passing a unique ID (Range::setId).
The requested ranges are reduced to actual requests for the server by excluding ranges that are available already.
A server retrieves the actual requests (getActualRequests) and translates those to multiples of the used block size.
When the blocks finished processing the server tells the range manager by calling setAccessible .
The manager updates the accessible ranges and rearrange them. This means that overlapped and each other extending ranges are merged and sorted.
At the same time the fulfilled client requests are extracted and removed from the manager.
The server notifies clients identified by Range::getId.

See also
setManaged, getManaged, request, getRequests, getActualRequests, setAccessible, setAutoManaged
Range, Range::Vector

Member Enumeration Documentation

◆ EResult

Enumerate for return values used by request method.

Enumerator
rmOutOfRange 

Range was outside the managed range.

rmInaccessible 

Requested range is inaccessible and needs to be retrieved.

rmAccessible 

Returned when a requested range is already accessible.

Constructor & Destructor Documentation

◆ RangeManager()

sf::RangeManager::RangeManager ( )
default

Default constructor.

◆ ~RangeManager()

sf::RangeManager::~RangeManager ( )
default

Destructor.

Member Function Documentation

◆ flush()

bool sf::RangeManager::flush ( )

Flushes all ranges and range list as if it were initialized.

Returns
True if a flush was actually performed.

◆ flushRequests()

void sf::RangeManager::flushRequests ( Range::id_type  id)

Flushes all the requests having the range identifier.

Parameters
idIdentifier (Type can hold a pointer cast to the id_type).

◆ getAccessibles()

const Range::Vector & sf::RangeManager::getAccessibles ( ) const
inline

Retrieves the current accessible list of ranges.

Returns
Access list.

◆ getActualRequests()

const Range::Vector & sf::RangeManager::getActualRequests ( ) const
inline

Retrieves actual request list of ranges missing to fulfill requests.
These are the resulting-requested ranges when all requests are added up.

Returns
Real request

◆ getManaged()

const Range & sf::RangeManager::getManaged ( ) const
inline

Retrieves the limit on the maximum requestable range span from zero.

Returns
Managed range.

◆ getRequests()

const Range::Vector & sf::RangeManager::getRequests ( ) const
inline

Retrieves the current request list.

Returns
Request list.

◆ isAccessible()

bool sf::RangeManager::isAccessible ( const Range r) const

Returns if this range is accessible. Using the managed range and the current accessible ranges as a reference.

Parameters
rRange
Returns
True when accessible.

◆ isFlushable()

bool sf::RangeManager::isFlushable ( )

Checks if flushing has any effect.

Returns
True on having effect.

◆ request()

EResult sf::RangeManager::request ( const Range r,
Range::Vector rrl 
)

Called by client to request access for a range.

Parameters
rRange to request access to. And the ID must be filled in.
rrlResulting ranges missing to fulfill the request.
Returns
True when the request was excepted and added to the request range list. False when the range is already accessible.

◆ setAccessible() [1/2]

bool sf::RangeManager::setAccessible ( const Range r,
Range::Vector rl_req 
)

Same as setAccessible but now for a single Range element.

Parameters
rRange that became accessible.
rl_reqRequested and fulfilled ranges becoming accessible now.
Returns
True when ranges have become accessible.

◆ setAccessible() [2/2]

bool sf::RangeManager::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 all ranges and owners in an owned range list which request are satisfied/fulfilled with the passed ranges.

Parameters
rlNew ranges that are accessible.
rl_reqRequested and fulfilled ranges becoming accessible now.
Returns
True when ranges have become accessible.

◆ setAutoManaged()

bool sf::RangeManager::setAutoManaged ( bool  flag = true)
inline

Determines if the managed range is automatically determined and set when setAccessible is called. Making a call to setManaged unnecessary when set to true.

Parameters
flagTrue when auto managed.
Returns
Previous value of the flag.

◆ setDebug()

void sf::RangeManager::setDebug ( bool  debug)
inline

Sets the debug flag for this instance.

Parameters
debugTrue to enable.

◆ setManaged()

void sf::RangeManager::setManaged ( const Range r)
inline

Sets the limiting range on requests. If the managed range is not set (empty) requests get the rmOutOfRange result. Also for when the requested range is outside the managed range.

Parameters
rManaged range.

◆ unitTest()

void sf::RangeManager::unitTest ( Range::Vector accessibles,
Range::Vector actual_requests = nullptr,
Range::Vector requests = nullptr 
)

Test function for set privates during a unit test.


The documentation for this class was generated from the following file: