Interface class for making object serializable. More...
#include <mi32/serializable.h>

Public Member Functions | |
| virtual ERRVALUE | SerialRead (SERIALIZER &serializer)=0 |
| virtual ERRVALUE | SerialWrite (SERIALIZER &serializer, const char *tagname=0) const =0 |
Interface class for making object serializable.
Objects may be serialized without inheriting from this interface provided they are serialized as part of a container object. In general there are two reasons to inherit from SERIALIZABLE.
1. If the object will be a top=level item in the serialization. This makes it easy to read and write the object via the SERIALIZER Read() and Write() methods pertaining to SERIALIZABLE objects. Simple objects which may be represented by an ITEMDEF array do not need to be made serializable as there are Read/Write methods which may use this array. The GRE::LAYOUT and GRE::GROUP classes are examples.
2. If an object is contained within another object and has complicated serialization which must be implemented via functions rather than using and ITEMDEF array. This allows use of TYPE_SERIALIZABLE and TYPE_SERIALIZABLEPTR in the containing object's ITEMDEF array, thus simplifying its definition. The GRE::LAYER::DISPPARM class is an example of this case.
By convention, if an object implements SerialRead and/or SerialWrite() the method signatures should match those used in SERIALIZABLE even if the class does not actually implement the SERIALIZABLE interface. This allows easy modification should it become necessary to implement the interface in the future. The GRE::LAYER class is an example of this case in that it defines both SerialRead() and SerialWrite() methods but does not specifically inherit from SERIALIZABLE.
| virtual ERRVALUE SERIALIZABLE::SerialRead | ( | SERIALIZER & | serializer | ) | [pure virtual] |
Read component from serialization.
This method must be called only after the tag name has been read and is responsible for determining how to deserialize the component elements. When beginning a deserialization, usually the SERIALIZER::Read(tagname,object) method should be used to match the desired tag name which was used in writing. A default implementation is not possible due to multiple inheritance resulting in a different "this" pointer being passed than the actual object, which causes the offset values in the ITEMDEF arrays to be wrong.
Implemented in GRE::GROUP, GRE::LAYOUT, GRE::LAYER_RASTER::DISPPARM, GRE::VIEWABLE::MAINSCRIPT, GRE::MACROSCRIPT, GRE::TOOLSCRIPT, GRAPHICLAYOUT::ITEM, GRAPHICLAYOUT, and MATTE.
| virtual ERRVALUE SERIALIZABLE::SerialWrite | ( | SERIALIZER & | serializer, | |
| const char * | tagname = 0 | |||
| ) | const [pure virtual] |
Write object to serialization.
This method must write the tag name provided, using SERIALIZER::PutBegin(). If the tagname is 0 (default) then it must determine the proper tag name to write. After writing the object this method must write the ending tag using SERIALIZER::PutEnd(). When inheriting this interface, the default value of 0 for the tag name must NOT be redefined. (See Meyers, Effective C++, item #38) A default implementation is not possible due to multiple inheritance resulting in a different "this" pointer being passed than the actual object, which causes the offset values in the ITEMDEF arrays to be wrong.
Implemented in GRE::GROUP, GRE::LAYOUT, GRE::LAYER_RASTER::DISPPARM, GRE::VIEWABLE::MAINSCRIPT, GRE::MACROSCRIPT, GRE::TOOLSCRIPT, GRAPHICLAYOUT::ITEM, GRAPHICLAYOUT, and MATTE.
1.6.1