![]() | CCacheEntry<T>::ContainsValue |
Indicates if the specified entry is in the cache and is valid.
bool CCacheEntry<T>::ContainsValue(T value, const CString& strModel);
[in] Value to check.
[in] The current instrument model.
Returns true if the specified value is in the cache and is valid, otherwise false.
The following example demonstrates use of the ContainsValue function.
// CoAcme4321.cpp STDMETHODIMP Acme4321::put_Bandwidth(double Bandwidth) { HRESULT hr = S_OK; // Retrieve the cache entry for the Bandwidth property CCacheEntry<double>* pEntry = GetOrCreateCacheEntry<double>(_T("IAcme4321.Bandwidth")); // If the value is in the cache AND is valid, simply return since we don't need to send the instrument command if (pEntry->ContainsValue(Bandwidth, GetModel())) return S_OK; // 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 HRESULT hr = io.Printf(_T("SENSE:BAND %.15g"), Bandwidth); if (SUCCEEDED(hr)) { // The new value was successfully sent to the instrument, so update the cache pEntry->UpdateValue(Bandwidth); } return hr; }