Tools.h++ Manual
17-14 104011 Tandem Computers Incorporated
17
Virtual functions restoreGuts(RWFile&) and restoreGuts(RWvistream&)
In a similar manner to 
saveGuts()
, these virtual functions are used to restore 
the internal state of an 
RWCollectable 
from a file or stream. Here is a 
definition for 
Bus
:
Note how the pointer passengers_ is restored using
RWvistream& operator>>(RWvistream&, RWCollectable*&);
If the original 
passengers_ 
was non-nil, then this function will restore a new 
RWSet 
off the heap and return a pointer to it. Otherwise, it will return a nil 
pointer. Either way, the old contents of 
passengers_ 
will be replaced. 
Hence, we must call "
delete passengers_
" first.
Virtual function binaryStoreSize()
The virtual function
virtual RWspace binaryStoreSize() const;
void Bus::restoreGuts(RWFile& f)
{
RWCollectable::restoreGuts(f); // Restore base class
f.Read(busNumber_); // Restore primitive
f >> driver_ >> customers_; // Uses Tools.h++ provided
versions
delete passengers_; // Delete old RWSet
f >> passengers_; // Replace with a new one
}
void Bus::restoreGuts(RWvistream& strm)
{
RWCollectable::restoreGuts(strm);// Restore base class
strm >> busNumber_ >> driver_ >> customers_;
delete passengers_; // Delete old RWSet
strm >> passengers_; // Replace with a new one
}










