beautypg.com

Designing your class to use isomorphic persistence – HP Integrity NonStop J-Series User Manual

Page 182

background image

f >> dlist2;
// restore dlist2 from f
// dlist2 now contains 2 pointers
// to the same RWCollectableInt of value 1.
// However, this RWCollectableInt isn't at
// the same address as the value
// that "one" points to.
}
// See Figure 6 below to see what dlist1 and dlist2
// now look like in memory.
assert(dlist2[0] == dlist2[1] && (*dlist2[0]) == *one);
// dlist2[0] and dlist2[1] point to the same place
// and that place has the same value as "one".
delete dlist2[0];
delete one;
// The developer must allocate and delete objects.
// The templatized collection member function
// clearAndDestroy() doesn't check that a given
// pointer is deleted only once.
// So in this case, delete the shared
// pointer manually.

return 0;
}

Figure 6: After Isomorphic Save and Restore of RWTPtrDlist

Designing Your Class to Use Isomorphic Persistence

Table 2 lists the Tools.h++ classes that implement isomorphic persistence. You can also add
isomorphic persistence to an existing class, even if you only have the header files for that class.
Before you can add isomorphic persistence to a class, it must meet the following requirements:

Class T must have appropriate default and copy constructors defined or generated by the
compiler:

T(); // default constructor

This manual is related to the following products: