Instruction Manual
Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
How to Create an RWCollectable Object
Here's an outline of how to make your object inherit from RWCollectable. Additional information
about how to do each step appears in the indicated section.
Define a default constructor. See below (Define a Default...).1.
Add the macro RWDECLARE_COLLECTABLE to your class declaration. See below (Add
RWDECLARE_...).
2.
Provide a class identifier for your class by adding one of two definition macros,
RWDEFINE_COLLECTABLE or RWDEFINE_NAMED_COLLECTABLE, to one and
only one source file (.cpp), to be compiled. See below (Provide a Class Ident...).
3.
Add definitions for inherited virtual functions as necessary. You may be able to use inherited
definitions. The following virtual functions are dicussed below (Add Definitions...):
Int compareTo(const RWCollectable*) const;
RWBoolean isEqual(const RWCollectable*) const;
unsigned hash() const;
4.
Consider whether you need to define a destructor. See below (Object Destruction).5.
Add persistence to the class. You may be able to use inherited definitions, or you may have
to add definitions for the following functions. See below (How to add...).
RWspace binaryStoreSize() const;
void restoreGuts(RWFile&);
void restoreGuts(RWvistream&);
void saveGuts(RWFile&) const;
void saveGuts(RWvostream&) const;
6.
A note on RWFactory follows these steps. See below (A Note on the RWFactory).
Define a Default Constructor
All RWCollectable classes must have a default constructor. The default constructor takes no
arguments. The persistence mechanism uses this constructor to create an empty object, then restore
that object with appropriate contents.