Robox Library for Cpp: BCC/31 module 1.0.0
RLibCpp BCC/31 protocol implementation
|
The class to handle variable caches. More...
#include <connection.h>
Public Member Functions | |
VariablesCache (Connection *connection) | |
The constructor. | |
~VariablesCache () | |
The destructor. | |
Globals::Results | update (VariablesDict &varDict, bool useCoherentValues) |
Updates the variables' cache with the current dictionary values. | |
Globals::Results | getCacheItem (Client &client, uint32_t cacheId, bool forceVarDictUpdate, bool useCoherentValues, bool checkFullVar, uint32_t startMsgOffset, uint32_t splitOffset, VariablesCacheItem *&vcache) |
Query a cached item given its ID. | |
uint32_t | add (const String &name, const String &extraTag="") |
Adds a variable to the cache. | |
bool | contains (uint32_t cacheId) |
Helper to check if cacheId is a valid identifier stored into the cache. | |
uint32_t | find (const String &name, const String &extraTag="") |
Check if the variable of specified in name with extraTag is cached. | |
Globals::Results | remove (uint32_t cacheId) |
Removes the variable specified by cacheId from the cache. | |
Message::DataTypes | dataType (uint32_t cacheId) |
Get the data types for the specified cacheId stored into the cache. | |
uint32_t | count () |
Get the number of cached items. | |
void | clear () |
Clears the variables' cache removing all the cached variables. | |
void | cleanup () |
Clears each cached variable without removing the cache entry. | |
VariablesCacheItem * | item (uint32_t cacheId) |
Returns the pointer to the cache item with cache id cacheId | |
bool | needUpdate () const |
get the flag to indicate if the variable cache needs to be udpated | |
Protected Types | |
typedef std::map< uint32_t, VariablesCacheItem * > | VariablesCacheItemHash |
Protected Member Functions | |
uint32_t | getCacheId (const String &name, const String &extraTag) |
Get the cache identifier from the name. | |
VariablesCacheItemHash & | varCaches () |
Get the cached variable dictionary (
) | |
Connection * | connection () const |
Get the connection internal object. | |
void | setNeedUpdate (bool value) |
Set/reset the flag for variable cache to be udpated on the next operation using the cache. | |
The class to handle variable caches.
|
protected |
VariablesCache | ( | Connection * | connection | ) |
The constructor.
connection | The connection to use |
~VariablesCache | ( | ) |
The destructor.
uint32_t add | ( | const String & | name, |
const String & | extraTag = "" ) |
Adds a variable to the cache.
name | The name of the variable to add to the cache |
extraTag | The optional extra tag used in cache id calculation: you can set this to different values to force caching of distinct entries of the same variable |
All successive operation onto the variable (Client.readVariable(ClientStruct::ReadVariableData &) , Client.writeVariable(ClientStruct::WriteVariableData &) etc) must refer to returned cache identifier
Variable naming convention must the same as RDE.
Using different extraTag values for the same name may be useful to maximize performance when accessing the same variable from Monitor, Client ( e.g. Client.readVariable(ClientStruct::ReadVariableData &), Client.writeVariable(ClientStruct::WriteVariableData &) , Monitor::read(MonitorStruct::ReadData &), etc) or Oscilloscope: in that cases, using different extraTag values (e.g. "MON", "CLIENT", "OSC" ) will force the caching of distinct entry , improving the overall performance
void cleanup | ( | ) |
Clears each cached variable without removing the cache entry.
void clear | ( | ) |
Clears the variables' cache removing all the cached variables.
|
protected |
Get the connection internal object.
bool contains | ( | uint32_t | cacheId | ) |
Helper to check if cacheId is a valid identifier stored into the cache.
cacheId | The cache identifier to check |
uint32_t count | ( | ) |
Get the number of cached items.
Message::DataTypes dataType | ( | uint32_t | cacheId | ) |
Get the data types for the specified cacheId stored into the cache.
cacheId | The cache identifier for which to get the data type |
uint32_t find | ( | const String & | name, |
const String & | extraTag = "" ) |
Check if the variable of specified in name with extraTag is cached.
name | The name of the variable to earch for |
extraTag | The optional extra tag used in cache id calculation |
The search is case insensitive: leading and traling whites char are trimmed.
|
protected |
Get the cache identifier from the name.
The id is calculated from the 'normalized' name i.e the name is trimmed and converted to upper case
name | the name from which to get the cache id |
extraTag | The extra tag used in cache id calculation: you can set this to different values to force caching of distinct entries of the same variable |
Globals::Results getCacheItem | ( | Client & | client, |
uint32_t | cacheId, | ||
bool | forceVarDictUpdate, | ||
bool | useCoherentValues, | ||
bool | checkFullVar, | ||
uint32_t | startMsgOffset, | ||
uint32_t | splitOffset, | ||
VariablesCacheItem *& | vcache ) |
Query a cached item given its ID.
client | The client to use for comunicate to the device. |
cacheId | The identifier of the variable into the cache |
forceVarDictUpdate | Flag to force the variable dictionary update |
useCoherentValues | Flag to indicate that coherent operations are required, so no packet splitting will be performed |
checkFullVar | Flag to enable the variable full check when parsing |
startMsgOffset | Message offset to be used on new var |
splitOffset | Offset to be applyed to the to the parsing variable logic to properly split the variable. Thats applies when a variable has to be fitted into a BCC message which contains other data (tipcally when using monitors) |
vcache | The cache object , or null if some error occurred |
VariablesCacheItem * item | ( | uint32_t | cacheId | ) |
Returns the pointer to the cache item with cache id cacheId
cacheId | the item cache id |
bool needUpdate | ( | ) | const |
get the flag to indicate if the variable cache needs to be udpated
Globals::Results remove | ( | uint32_t | cacheId | ) |
Removes the variable specified by cacheId from the cache.
cacheId | The cache identifier to remove |
|
protected |
Set/reset the flag for variable cache to be udpated on the next operation using the cache.
value | The value to set |
Globals::Results update | ( | VariablesDict & | varDict, |
bool | useCoherentValues ) |
Updates the variables' cache with the current dictionary values.
varDict | the variable dictionay to use |
useCoherentValues | Flag to ensure coherent values operation |
|
protected |