Source File Changes
Moving on to the source files, you must now:
Define the
streamContents() function using the following macro set:
RW_BEGIN_STREAM_CONTENTS(className) RW_STREAM_PARENT(parentClass) RW_STREAM_ATTR_MEMBER(variableLabel,variableName) RW_END_STREAM_CONTENTS() The definitions generated through these macros guarantee symmetry between the serialization output and input operations.
Define the global insertion and extraction operators that support the serialization of pointers to objects, using the following macro set:
RW_DEFINE_STREAMABLE_POINTER(className) Apply this macro to all classes involved in the serialization.
RW_DEFINE_STREAMABLE_AS_SELF(className) Apply this macro to a class if its instantiations will be serialized as pointers directly to the instantiations.
RW_DEFINE_STREAMABLE_AS_BASE(derivedClass,baseClass) Apply this macro to a class derived from a base class if its instantiations will be serialized as pointers to the base class.
If you want to allow for the possibility that these objects might be serialized as pointers directly to themselves, you need to apply RW_DEFINE_STREAMABLE_AS_SELF as well. In the code that follows, both RW_DEFINE_STREAMABLE_AS_BASE and RW_DEFINE_STREAMABLE_AS_SELF are applied.
Here is the source code for your three classes, modified as needed with the macros described above:
// from real_property.cpp
RW_BEGIN_STREAM_CONTENTS(real_property) //1
{
RW_STREAM_ATTR_MEMBER(address, address_) //2
RW_STREAM_ATTR_MEMBER(size, size_)
}
RW_END_STREAM_CONTENTS //3
// from residential.cpp
RW_BEGIN_STREAM_CONTENTS(residential)
{
RW_STREAM_PARENT(real_property) //1
RW_STREAM_ATTR_MEMBER(footage, footage_) //2
}
RW_END_STREAM_CONTENTS
Note that the code below parallels the code for residential.
// from rural_land.cpp
RW_BEGIN_STREAM_CONTENTS(rural_land)
{
RW_STREAM_PARENT(real_property)
RW_STREAM_ATTR_MEMBER(irrigation, irrigation_)
}
RW_END_STREAM_CONTENTS