![]() | ResetObjectState Method |
void ResetObjectState();
Co<MainClass>.cpp
Co<RepCapClass>.cpp
Returns S_OK if successful, otherwise a failure HRESULT.
Drivers often need to cache data of various forms. Typically, cached data is stored as member variables of the main driver class or on repeated capability classes if the data is specific to a repeated capability instance. This cached data is referred to generically as object state. One use of object state in drivers is to store settings that represent the default state of the instrument.
The ResetObjectState method is provided by Nimbus as a single location to place initialization code for cached data. ResetObjectState is called after the IIviDriver:Initialize method but before the call to OnFinalInitialize. ResetObjectState is also called by the Nimbus implementation of IIviDriverUtility::Reset and IIviDriverUtility::ResetWithDefaults.
The ResetObjectState method is called on the main driver class as well as on each repeated capability instance.
The code below demonstrates how to use the ResetObjectState method to initialize member variables on the main driver class.
// CoAcme4321.cpp void Acme4321::ResetObjectState() { // Use this function to initialize member variables and any cached data. // This function is automatically called in the following circumstances. // 1) After IIviDriver::Initialize, just BEFORE FinalInitialize is called // 2) After IIviDriverUtility::Reset // 3) After IIviDriverUtility::ResetWithDefaults // Set the initial active trace window to the first window m_lActiveWindow = 1; }