Creating an RWCollectable Object
Here is an outline of how to make your object inherit from
RWCollectable. Additional information about how to do each step appears in the indicated section.
3. Provide a class identifier for your class by adding one of two definition macros,
RW_DEFINE_COLLECTABLE_CLASS_BY_ID or
RW_DEFINE_COLLECTABLE_CLASS_BY_NAME, to one and only one source file (
.cpp), to be compiled. See
Provide a Class Identifier for Your Class. 4. Add definitions for inherited virtual functions as necessary. You may be able to use inherited definitions.
Add Definitions for Virtual Functions discusses the following virtual functions:
Int compareTo(const RWCollectable*) const;
bool isEqual(const RWCollectable*) const;
unsigned hash() const;
6. 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
How to Add Polymorphic Persistence.
RWspace binaryStoreSize() const;
void restoreGuts(RWFile&);
void restoreGuts(RWvistream&);
void saveGuts(RWFile&) const;
void saveGuts(RWvostream&) const;
A note on
RWFactory follows these steps. See
A Note on the RWFactory.