beautypg.com

HP Integrity NonStop J-Series User Manual

Page 183

background image

T(T& t); // copy constructor

Class T must have an assignment operator defined as a member or as a global function:

T& operator=(const T& t); // member function

T& operator=(T& lhs, const T& rhs); // global function

Class T cannot have any non-type template parameters. For example, in

RWTBitVec

,

"size" is placeholder for a value rather than a type. No present compiler accepts function
templates with non-type template parameters, and the global functions used to implement
isomorphic persistence (rwRestoreGuts and RWSaveGuts) are function templates when they
are used to persist templatized classes.

Class T must use the macros RW_DECLARE_PERSISTABLE and
RW_DEFINE_PERSISTABLE or their equivalents. More about this in

Add

RWDECLARE_PERSISTABLE to Your Header File

and

Add RWDEFINE_PERSISTABLE to

One Source File

.

All the data necessary to recreate an instance of Class T must be globally available (have
accessor functions). If you can't make this data available, you can't implement isomorphic
persistence. More about this in the next section.

If your class T will be stored in a Standard C++ Library container or a Standard C++ Library-based
collection, you may need to implement operator<(const T&, const T&) and operator==(const T&,
const T&). See

Chapter 11 (

Migration Guide...

)

for more information.

To create an isomorphically persistent class or to add isomorphic persistence to an existing class,
follow these steps:

Make all necessary class data available.

1.

Add RWDECLARE_PERSISTABLE to your header file.

2.

Add RWDEFINE_PERSISTABLE to one source file.

3.

Check for possible problems.

4.

Define rwSaveGuts and rwRestoreGuts.

5.

Make All Necessary Class Data Available

All class data that will be isomorphically persisted must be accessible to the global functions,
rwSaveGuts and rwRestoreGuts, used to implement persistence for the class.

Note that only the information necessary to recreate an object of that class must be accessible to
rwSaveGuts and rwRestoreGuts. Other data can be kept protected or private.

There are several ways to make protected and private data members of classes accessible.

First, your class could make friends with rwSaveGuts and rwRestoreGuts:

class Friendly {
// These global functions access private members.

This manual is related to the following products: