2D Graphics > Managers > Basic Manager Features > Saving and Reading
 
Saving and Reading
Manager objects and their properties can be saved and read from particular streams. To make it easy to save and restore a set of IlvGraphic objects, two classes are provided:
*IlvManagerOutputFile (a subtype of IlvOutputFile)
*IlvManagerInputFile (a subtype of IlvInputFile)
These two classes add only manager-specific information to the object description blocks.
The IlvManagerInputFile class reads the files that have been created using IlvManagerOutputFile.
Example: Using the IlvManagerOutputFile Class
The following is an example of subtyping of the IlvOutputFile class, where the IlvOutputFile::writeObject member function is implemented to add the manager-specific information for each object:
void
IlvManagerOutputFile::writeObject(const IlvGraphic* object)
{
if (getManager()->isManaged(object))
getStream() << getManager()->getLayer(object) << IlvSpc();
else
getStream() << "-1 ";
writeObjectBlock(object);
}
New information is added before the object descriptor block is written. It indicates the layer where the graphic object lies. If the object was not managed by the manager, Rogue Wave Views writes the value -1 to getStream (which is not a valid layer index). The value -1 indicates that the object should not be added to the manager object set.
Note: Specialized Rogue Wave Views graphic objects called “gadgets” need the following subclasses: IlvGadgetManagerInputFile (subclass of IlvInputFile) and IlvGadgetManagerOutputFile (subclass of IlvOutputFile). These subclasses handle the persistence of gadget-related properties. Subtyping these two classes is allowed, but it is mandatory to insert the string “Gadget” in the subtyped C++ class name.
The C++ code used to implement the IlvManagerInputFile::readObject member function is shown here:
IlvGraphic*
IlvManagerInputFile::readObject()
{
IlvGraphic* object;
int layer;
getStream() >> layer;
IlUInt dummyIndex;
IlvGraphic* object = readObjectBlock(dummyIndex);
if (object && (layer >= 0))
getManager()->addObject(object, IlFalse, layer);
return object;
}
The object read is added to the manager only if its layer index is greater than or equal to 0.

Version 6.2.1
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.