Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

TSE3::Serializable Class Reference

Interface for serializable data. More...

#include <Serializable.h>

Inheritance diagram for TSE3::Serializable:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Serializable ()
virtual ~Serializable ()
virtual void save (std::ostream &out, int indentLevel) const
virtual void load (std::istream &in, SerializableLoadInfo &info)

Friends

std::ostream & operator<< (std::ostream &, const indent &)

Detailed Description

Interface for serializable data.

Serializable is the base class of objects that can save their state to a file in the block structure of the TSE3MDL specification. Any class that wishes to be able to persist itself needs to implement this interface.

Important note
The entry point to save/load facilities is the TSE3MDL class, you should use that rather than the Song class's Serializable interface directly.

See the TSE3MDL class documentation for more details.

File format
Data is to be saved in the TSE3MDL file format. Each object will save an amount of data in a block, whose format follows the layout below.

IDENTIFIER { DATA_TAG1:DATA DATA_TAG2:DATA }

One data item exists per line. A mechanism exists to determine the number of indentation spaces that precedes each line (it is passed as a parameter to each save() call). There are means to make it easy to produce this indentation (see the indent() method).

When parsing the data unrecognised data items should be ignored, and unrecognised chunks shall be skipped.

The file format is further described in the HTML documentation that comes with the TSE3 library, in the "doc" directory.

Author:
Pete Goodliffe
Version:
1.00
See also:
TSE3MDL


Constructor & Destructor Documentation

TSE3::Serializable::Serializable  )  [inline]
 

virtual TSE3::Serializable::~Serializable  )  [inline, virtual]
 


Member Function Documentation

virtual void TSE3::Serializable::save std::ostream &  out,
int  indentLevel
const [virtual]
 

This method causes the Serializable object to save a block representing it's state to the ostream. The block will consist of an opening "{" line, the data, zero or more sub-blocks and a closing "}" line.

It is the caller's responsibility to put an identifying tag line in the ostream before calling this method so that it can uniquely identify this Serializable.

Calls to Serializable::save naturally nest. For example, the Song Serializable class calls save on the Track Serializable class (amongst others).

The default save will save an empty block. (Not much use really ;-)

Parameters:
out ostream to send output to
indentLevel Current indent level (this will produce indentLevel*4 spaces at the start of the output lines).

Reimplemented in TSE3::App::ApplicationChoiceHandler, TSE3::App::MetronomeChoiceHandler, TSE3::App::PanicChoiceHandler, TSE3::App::MidiMapperChoiceHandler, TSE3::App::TransportChoiceHandler, TSE3::App::DestinationChoiceHandler, TSE3::DisplayParams, TSE3::FlagTrack, TSE3::KeySigTrack, TSE3::MidiFilter, TSE3::MidiParams, TSE3::Part, TSE3::Phrase, TSE3::PhraseList, TSE3::RepeatTrack, TSE3::Song, TSE3::TempoTrack, TSE3::TimeSigTrack, and TSE3::Track.

virtual void TSE3::Serializable::load std::istream &  in,
SerializableLoadInfo info
[virtual]
 

This method loads a block for this particular Serializable object. It is a precondition that it was a Serialiazble object of this particular type that saved the block.

The block tag will have been consumed from the stream, and the next line to be parsed will be the opening "{". The block and any sub-blocks (whether recognised or not) will be read from the stream up to and including the closing "}".

The default load will just skip the block without attempting to interpret the contents.

A utility class exists to aid writing the load method. This is the FileBlockParser, and it's related classes.

Parameters:
in istream to take input from
info Object holding information about the Song being loaded
See also:
FileBlockParser.

SerializableLoadInfo

Reimplemented in TSE3::App::ApplicationChoiceHandler, TSE3::App::MetronomeChoiceHandler, TSE3::App::PanicChoiceHandler, TSE3::App::MidiMapperChoiceHandler, TSE3::App::TransportChoiceHandler, TSE3::App::DestinationChoiceHandler, TSE3::DisplayParams, TSE3::FlagTrack, TSE3::KeySigTrack, TSE3::MidiFilter, TSE3::MidiParams, TSE3::Part, TSE3::PhraseList, TSE3::RepeatTrack, TSE3::Song, TSE3::TempoTrack, TSE3::TimeSigTrack, and TSE3::Track.


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  s,
const indent i
[friend]
 

Used by implementations of Serializable::save.

An implementation can call this to indent the line to the given level.

e.g. o << indent(5) << "DATA_TAG:" << data << "\n";


The documentation for this class was generated from the following file:
Generated on Wed May 25 14:46:57 2005 for TSE3 by doxygen 1.3.2