Menu
Your Cart

Persistent Pointer Factory

Persistent Pointer Factory

Need more information on this product?

Please contact us on +44 (0)20 8733 7100 or via our online form.

Contact Us

If you are not currently a customer, you can apply for an account.

Register here


  • SKU: PEPOFA


Replace all pointers by this pointer, your data become instantly persistent (C++ Persistence).The total source is under 100kB, the binary version 35kB.
Persistent Pointer Factory is single class smart pointer that makes objects persistent automatically. It is suitable for building databases of any size with paging of data to memory (transactions) controlled individually by class.

Features include:

  • Storing data on disk and paging transactions to memory
  • Smart pointer that makes data structures persistent
  • Prime storage on disk paged to memory on demand
  • Pure C++ templates with one disk file per class
  • Storage with a binary of 35 KB.

Persistent Pointer Factory - Features

This product gives you a smart pointer class, PersistPtr

If you replace all pointers by this pointer, your data become instantly persistent. This is a simple, fast, and elegant implementation. The total source is under 100kB, the binary version 35kB. It is also simple to use, the entire documentation consists of only 10 pages.

Objects and arrays of each class are stored in one disk file, and paged to memory on demand. There is no limit on the size of your data except for the available space on your disk drive. You control the size of one page, and how many pages you want in memory, as you can see from the following code sample:

#include "factory.h" // definition of the smart pointer class A { PersistClass(A); // register class A as persistent     int a; public:     void prt(){cout << a << "
";}     // ... }; class B { PersistClass(B);         // register class B as persistent     PersistPtr p;     // equivalent of A *p; public:     void prt(){if(p==NULL)return; else p->prt();}     // ... }; int main(){     A::startPager(1024,5,2000000); // pageSize=1024, max=5 pages, estim=2MB     B::startPager(64,1,256);       // pageSize=64,   max=1 page,  estim=256B     // ...     PersistPtr pb=new B;     PersistPtr pa=new A;     // ...     pb.freeObj(); // equivalent of delete pb;     pa.freeObj(); // equivalent of delete pb;     // ...     A::closePager();     B::closePager();     return 0;  
 

Note that when starting the Pager (storage to disk), you must specify the size of one page, and how many pages will be in the memory. You also can provide an estimate of the entire space required for this class. Providing a good estimate is not necessary, but it helps to avoid gradual growing and repeated re-allocation of the internal data structures. Also note that removal of the objects must be done differently than expected; operator delete() cannot be used, because pa and pb are objects, not pointers. Also, you cannot use delete &pb in order to delete object of type B, because then there would not be distinction between destroying B and destroying PersistPtr itself.

The call pa.freeObj() provides essentially the same service as you would expect from (syntactically incorrect) call: delete pa; Here is what happens in the background: Each class keeps a list of free objects, and if the data file can be truncated, these objects are released.

The data is kept on file *.ppf, so after running the code fragment shown above, you will have on your disk files A.ppf and B.ppf. When running the same program again, startPager() opens the same file again. You can chose the same, or completely different paging parameters.