Persistent Pointer Factory
This product gives you a smart pointer class, PersistPtr.
If you replace all pointers by this pointer, your data become instantly persistent (C++ Persistence). 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
|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<B> 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.|