Persisting application data so that it can be reused between different runs of the application is a problem developers continually face. Most of the services provided by the operating system for this effect consist of APIs for reading and writing byte streams to files on disk. The application developer has to take care of issues like file formats, object construction and recovery, object reference resolution, and so on.
SFL offers a solution for this problem in the form of its Persistence package, a set of classes based on the standard COM property bag concept. The property bags implementation provided in SFL is usable in two ways:
As a binary library that publishes its services in the form of COM objects
At the source code level from a C++ application
COM defines several standard mechanisms for object persistence, including:
COM storages
COM streams
Property bags
The first two methods represent binary, non-structured storage mechanisms. The application is responsible not only for the contents that are stored there, but also for the physical format in which the data is stored.
Property bags are a more structured persistence mechanism. Conceptually, a property bag is a set of name-value pairs, each one of which is a simple property. A property can also contain multiple subproperties, making it a composite property. This means that property bags are hierarchical, with a tree-like logical structure.
Property bags are used extensively by technologies like ActiveX documents and ActiveX controls. Many other COM objects are also capable of persisting their internal state in property bags.
COM originally defined the interface IPropertyBag as the standard mechanism to manipulate a property bag object. A more flexible interface, IPropertyBag2, was introduced in later versions of COM to accommodate some functionality the original IPropertyBag interface was not able to perform, such as providing metainformation about the actual properties existing in a bag, or loading the state of an object already instantiated.
The COM property bags definition standardizes only the way in which a COM component interacts with a property bag object. It says nothing about the media where the persisted data will be stored for later retrieval. The definition provides a logical format for the data, in the form of name-value pairs; but the actual shape of this data in the persisted media is implementation-dependent.
Unlike streams and storages, COM does not offer a single property bag implementation. Applications that make use of this technology, like Microsoft Visual Basic or Microsoft Internet Explorer, have their own private implementations of these interfaces, not available to be used by other applications.
To be loaded from or saved to persistent media using the property bag mechanism, a COM object must implement either the IPersistPropertyBag or IPersistPropertyBag2 standard COM interfaces, depending on the property bag interface being used. Both interfaces provide Load() and Save() methods to retrieve or store an object to a property bag. For more documentation of these interfaces, consult the COM Reference.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.