Permanent File Store

A permanent file store implements most of the operations defined by the store abstract framework.

Streams in a permanent file store can be:

  • overwritten

  • replaced

  • deleted

  • created in advance of being written to.

A permanent file store is useful for the type of application which treats the data in the store as its prime copy. Typically, the object network comprising the application’s data is structured so that sections of data can be loaded in, and, if changed, written back to the store. Memory is used as a workplace for changing data. Such an application never replaces the entire store. This approach requires a sophisticated structure and greater sophistication within the application.

Typically, a permanent file store is used by an application, such as a database, which maintains all its data in a file, but occasionally edits some entries in that database.

In this paradigm:

  • the database file is initially created

  • when an entry is created, it as added to the database

  • the program maintains an internal, non-persistent, copy of the indexes in the database file

  • when an entry is selected for display or editing, its data is retrieved from the database; all such entries’ data are maintained in an internal, non-persistent, form

  • when an entry is edited and saved, just that single entry is replaced in the database

  • when the application exits, there is nothing to do to the database, since there should be no data that was not already saved (except, perhaps, the current entry if it was being edited)

Such an application never replaces the entire store. The database file itself is permanent; it is not erased when an entry is saved. Because of this, much more care is needed when maintaining this type of store. All links within the database must be maintained without corruption, and no stream subnetworks in the database should become inaccessible, otherwise space is wasted. The order in which streams are written to a permanent file store is not important as streams can be changed and rewritten.

Overwriting an existing stream does not change its length. However, attempting to write beyond the end of the stream fails and results in a leave. Replacing a stream can result in a stream which is longer or shorter than the original.

Note the difference between a persistent store (one that can be closed and re-opened), and a permanent file store (it is not replaced wholesale; rather, its individual entries are edited, inserted and deleted, but the store itself is permanent). A permanent file store is, of course, persistent.

When the content of a permanent file store is naturally represented by a relational database, it is usually much more convenient to manipulate it using the relational database manager.

Permanent file stores are encapsulated by the CPermanentFileStore class.

Related concepts