Viewable Objects and the Data Cache

Closely related to data objects in Uniform Data Transfer is the capability of an object to indicate that it can draw presentations of its data directly to devices through the interface IViewObject2. Often a data object will use IDataObject to provide renderings of its presentations into bitmaps and metafiles while it implements IViewObject2 to provide direct device renderings. When an object supports this interface to draw its own "views," it's called a viewable object, the topic of Chapter 11.

IViewObject2 also contains member functions for handling notifications to a client for when an object's view, as opposed to its data, changes. For example, a bar chart has underlying data used to generate the chart, and a data change will normally also mean a view change for the chart. But changing the color of one of the bars changes the view but not the data; therefore, we have a separate notification. This notification also happens through IAdviseSink because IDataObject and IViewObject2 are often found together, and the combination of notifications into IAdviseSink centralizes not only sink implementation but also the asynchronous nature of the interface. In response to the view change notification, a client displaying the object's view somewhere will normally ask the object to redraw itself.

An important point about IViewObject2 is that it has no marshaling support: an HDC argument to its Draw function cannot be shared across process boundaries. So a "viewable" object always shares the client's process.

Closely related to an object's view is the capability of a client to cache one or more views (metafiles or bitmaps) in what is called a data cache, the implementation of which is a standard OLE service. This cache component, which always works in a client's own process, has an object that implements the interfaces IOleCache2 and IOleCacheControl. Through this object, the client can control what is saved in the cache and can also connect the cache to a running local or remote object's IDataObject interface. Through this interface, the cache can obtain the graphics to cache and can watch for changes in those presentations in order to update the cache automatically.