#include <SessionItemSerializer.h>
Public Member Functions | |
| virtual void | reserve (int64_t size)=0 |
| virtual bool | serialize (const std::vector< unsigned char > &data)=0 |
| virtual bool | serialize (const void *pData, int64_t size)=0 |
| virtual bool | serialize (XMLWriter &writer)=0 |
| virtual void | endBlock ()=0 |
Protected Member Functions | |
| virtual | ~SessionItemSerializer () |
The data stored via the SessionItemSerializer will be restored to the SessionItem on loading a session via the SessionItemDeserializer. If a SessionItem needs to be restored, but does not need to save any state information, it should call serialize(NULL,0) to ensure that it will be recreated on session load. If a SessionItem does not do at least this on serialization, it will not be recreated on session restore. Conversely, if a SessionItem does not need to be recreated on session load, it should not call any of the serialize methods on the SessionItemSerializer.
Definition at line 31 of file SessionItemSerializer.h.
| virtual SessionItemSerializer::~SessionItemSerializer | ( | ) | [protected, virtual] |
Destroys the SessionItemSerializer object.
The SessionItemSerializer object is automatically deleted by SessionManager. Plug-ins do not need to destroy it.
Definition at line 141 of file SessionItemSerializer.h.
| virtual void SessionItemSerializer::reserve | ( | int64_t | size | ) | [pure virtual] |
Reserves a specified number of bytes in the session.
This method is called by a SessionItem during session serialization to specify the total number of bytes that the SessionItem will be saving to the session. If serialize() will only be called once, this method need not be called since the size can be inferred from the data - this method need only be called if serialize() will be called more than once. If this method is called more than once, only the first call will be applied. When using multiple blocks, reserve() should be used to reserve the space needed for each block, not for then entire SessionItem.
| size | The total number of bytes that will be serialized to this object. |
| virtual bool SessionItemSerializer::serialize | ( | const std::vector< unsigned char > & | data | ) | [pure virtual] |
Saves the specified data in the session file.
This method is called by a SessionItem during session serialization to save the state of the SessionItem. The data provided to this method will be retrieved upon deserialization to recreate the SessionItem. If this method is to be called more than once, the reserve() method must be called to specify the total amount of space to reserve.
| data | The data to be saved in the session. It can be in any format. |
| virtual bool SessionItemSerializer::serialize | ( | const void * | pData, | |
| int64_t | size | |||
| ) | [pure virtual] |
Saves the specified data in the session file.
This method is called by a SessionItem during session serialization to save the state of the SessionItem. The data provided to this method will be retrieved upon deserialization to recreate the SessionItem.
If the size is 0, this method will return true and the current block will be created. This can be used to force the creation of a size 0 block.
| pData | A pointer to the data to be written. The method will return false if this pointer is NULL and size is not 0. | |
| size | The size of the data in bytes |
| virtual bool SessionItemSerializer::serialize | ( | XMLWriter & | writer | ) | [pure virtual] |
Saves the specified data in the session file.
This method is called by a SessionItem during session serialization to save the state of the SessionItem. The data provided to this method will be retrieved upon deserialization to recreate the SessionItem. This method may not be called more than once. This is a convenience method for saving session information in XML format.
| writer | An XMLWriter in which the state of the SessionItem has been written. |
| virtual void SessionItemSerializer::endBlock | ( | ) | [pure virtual] |
Creates a new session item block.
Typically, SessionItem data can be saved as a single block of data either with a single call to serialize() or a call to reserve() followed by multiple calls to serialize(). It may be desirable in certain cases to block the data for a single SessionItem. The first block may contain an XML header, for example, and further blocks contain raw binary data. In this case, the XML is more easily separable from the binary data and can be more easily passed to an XML parser without the raw binary data interfering or slowing down the parse.
A SessionItem wishing to use this feature should call serialize() once, or reserve() followed by serialize() to write the first block. When finished with the block, call endBlock() to close the block and prepare the SessionItemSerializer for the next block. Call serialize() or reserve() followed by serialize() for the second block. Repeat this for additional blocks of data. The final block will implicitly call endBlock().