Data Storage

Normally, all data structures provided by Open CASCADE are run-time structures, in other words, transient data. As transient data, they exist only while an application is running and are not stored permanently. However, the Data Storage module provides resources, which enable an application to store data on disk as persistent data.

Data storage services also provide libraries of persistent classes and translation functions needed to translate data from transient to persistent state and vice-versa.

### Libraries of persistent classes

Libraries of persistent classes are extensible libraries of elementary classes you use to define the database schema of your application. They include:

- Unicode (8-bit or 16-bit character type) strings

- Collections of any kind of persistent data such as arrays, stacks, queues, and graphs

All persistent classes are derived from the Persistent base class, which defines a unique way of creating and handling persistent objects. You create new persistent classes by inheriting from this base class.

### Translation Functions

Translation functions allow you to convert persistent objects to transient ones and vice-versa. These translation functions are used to build Storage and Retrieval drivers of an application.

For each class of 2D and 3D geometric types, and for the general shape class in the topological data structure library, there are corresponding persistent class libraries, which allow you to translate your data with ease.

### Creation of Persistent Classes

If you are using Unix platforms as well as WOK and CDL, you can create your own persistent classes. In this case, data storage is achieved by implementing Storage and Retrieval drivers.

The Storage package is used to write and read persistent objects. These objects are read and written by a retrieval or storage algorithm (Storage_Schema object) in a container (disk, memory, network ...). Drivers (FSD_File objects) assign a physical container for data to be stored or retrieved.

The standard procedure for an application in reading a container is the following:

- open the driver in reading mode,

- call the Read function from the schema, setting the driver as a parameter. This function returns an instance of the Storage_Data class which contains the data being read,

- close the driver.

The standard procedure for an application in writing a container is the following:

- open the driver in writing mode,

- create an instance of the Storage_Data class, then add the persistent data to write with the function AddRoot,

- call the function Write from the schema, setting the driver and the Storage_Data instance as parameters,

- close the driver.