The principle and application of COM----structured storage

Source: Internet
Author: User
Tags file system naming convention ole

1. Structured Storage

The structured storage (structured storage) mechanism of COM, also known as the permanent storage (persistent storage) mechanism. Structured storage is an important development of software storage technology, and the concept of structured storage is proposed on the basis of file system based on the requirement of component software. With structured storage, component programs work well together, and one component program can share the same file with another, just as an application shares the same disk file system as another application.

COM defines the specification of structured storage, including a set of interfaces and some rules for implementing these interface member functions, while COM also provides the implementation of structured storage, that is, compound document technology. Compound document technology is the foundation of OLE. OLE's original goal was to embed or link objects in the document, but now OLE has grown beyond that, but compound documents are still the underlying storage technology for OLE.

2, the introduction of structured storage

The Component-based programming method designs the application system into several component programs, and how to access the same file in shared way between these component programs is a problem that the component programming must solve. and multiple components access to shared files through file handle is difficult to achieve, structured storage technology "borrow" the concept of file system, within the file structure a similar to the file system tree hierarchy, solve this problem.

The nodes of a structured storage hierarchy can be two objects: a storage object and a stream object, and each storage object or stream object is an object that can be read and write independently, and the component program operates on only the node objects it owns. From the application system as a whole, these component programs share access to the same file.

3. File system

The birth of the operating system isolates the application from the underlying storage device, and the operating system provides a basic abstraction for the operation of the application, which can handle all the basic operations related to the storage device. At the same time, the operating system introduces the concept of file systems, allowing multiple applications to share the same storage device. Furthermore, the operating system provides an abstract, streaming storage structure for applications, which still accesses its own storage space independently, and the different applications are undisturbed from one another.

4, file system and structured storage block diagram

5. Storing objects and streaming objects

For a complete storage operation, it is divided into two levels: the application invokes API functions, and the operating system provides the implementation of API functions. The COM library provides a structured storage implementation that provides a set of interfaces and API functions for component program calls to accomplish actual storage operations. Therefore, the storage objects and stream objects defined by the structured storage are implemented by the COM library, and the application or component program does not need to implement the two objects, just as the application does not need to implement file handles or directory objects.

Stream object is very similar to a separate disk file, it is also a basic object of data read and write operations, the use of streaming objects can save various types of data, it has its own access rights and a separate search pointer. The Stream object also uses a string as its name, as if it were a filename. The Stream object is a COM-implemented Component object, it implements the basic COM interface IStream, the application accesses the stream object through the IStream interface, and carries out various data access operations.

A stored object is similar to a directory object, it also has a string name, but it does not itself store data information, it acts as a container for its child storage objects and child stream objects, and only records the information for those child objects. The storage object exposes the IStorage interface, and the client operates on the storage object through the IStorage interface.

An application or component program can share the same compound file through a structured storage mechanism, and storage objects and stream objects can also be shared between those programs, even if the programs are running in different processes.

6, structured storage characteristics-access mode

Storage objects and Stream objects support two basic access modes: direct access and transactional access mode. In direct access mode, the modification of a program to a stored object or stream object takes effect immediately, while in transaction mode, the modifications made by the program to the stored object or stream object are cached and are only truly valid if committed (commit), if the revert member function is invoked, You can revert to the state when you last committed or when you first opened it.

7, structured storage characteristics-transaction mechanism

In a tree-like hierarchy of structured storage, transaction attributes can be applied to objects at all levels, so transactional attributes can be nested.

The transaction mechanism needs to consume more system resources.

8, structured storage characteristics-naming rules

In a tree hierarchy of structured storage, each storage object and stream object has a string name.

The name of the root store object is actually the file name of the compound document, so the naming rule for the root store object is affected by the file system, which adheres to the naming convention for the file system. In functions related to creating and opening a root store object, use the file name directly. All non-root storage objects and stream objects are managed by their parent objects, and because they exist within the file, their naming rules conform to the conventions that COM gives.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.