![]() | CacheEntry::HasValue |
Indicates if the specified value is in the cache and is valid.
bool HasValue(const T& value) const;
[in] The value to test for equality against the cached value, if present. The data type T is that of the CacheEntry template instance.
Returns true if the specified value is in the cache for this particular entry and if the entry is valid.
The following example demonstrates use of the HasValue function.
ViStatus _VI_FUNC acme4321_set_BANDWIDTH(ViSession Vi, ViConstString RepCapIdentifier, ViReal64 AttributeValue) { auto status = VI_SUCCESS; // Retrieve the cache entry for the Bandwidth attribute // auto entry = GetCacheEntry<ViReal64>(Vi, ACME4321_ATTR_BANDWIDTH); // If the value is in the cache AND is valid, simply return since we don't need to send the instrument command // if (entry.HasValue(AttributeValue)) { return status; } // If we get this far, then the new value is not in the cache, so we must communicate with the instrument to set the value // status = viPrintf(GetVisaSession(Vi), "SENS:BAND %0.15g\n", AttributeValue); ReturnOnError(status); // The new value was successfully sent to the instrument, so update the cache // entry.SetValue(AttributeValue); return status; }