Describing IOleCache2, I made several references to a local or remote object, by which I mean an object running in a local or remote server. The remaining interface on the data cache, IOleCacheControl, has two members through which the client of the cache makes the cache aware of this object:
interface IOleCacheControl : IUnknown
{
HRESULT OnRun(IDataObject *pIDataObject);
HRESULT OnStop(void);
};
The OnRun function tells the cache that the object identified with pIDataObject is now running, and OnStop tells the cache that the same object has stopped running. (The data cache manages only one remote object at a time.) When the data cache becomes aware of this remote object, it establishes advisory connections for any cached format using the ADVF_* flags previously passed to IOleCache2::Cache for those formats, as shown in Figure 11-2. The sink objects here are simple objects with IAdviseSink; their pointers are enumerated through IOleCache2::EnumCache.
Figure 11-2.
Through IOleCacheControl, the data cache becomes connected with an object running in a local or remote server.
When these connections are active, the cache updates its cached formats whenever the remote object sends an IAdviseSink::OnDataChange. The various flags that you can pass to IOleCache2::UpdateCache determine which formats are updated according to the type of advisory connection they use with the remote object. For example, UPDFCACHE_ALLBUTNODATACACHE updates all the data formats that were cached with flags other than ADVF_NODATA.
We can now understand the other values of the ADVF enumeration that we glossed over in Chapter 10. ADVFCACHE_NOHANDLER itself is reserved for future use, so you will have occasion to use it presently. ADVFCACHE_FORCEBUILTIN restricts cached presentation data to that which OLE itself can handle, namely metafiles and bitmaps (both CF_BITMAP and CF_DIB). ADVFCACHE_ONSAVE causes the cache to update data only when the remote object is itself saved—that is, when and if the data source object calls IAdviseSink::OnSave. Obviously, the client using this flag should have some knowledge about the nature of the data source.