class Serializable

Interface for serializable data. More...

Full nameTSE3::Serializable
Definition#include <Serializable.h>
Inherited byDisplayParams, FlagTrack, Header, KeySigTrack, MidiFilter, MidiParams, Part, Phrase, PhraseList, RepeatTrack, Song, TempoTrack, TimeSigTrack, Track
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Types

Protected Methods


Detailed Description

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.

See also: TSE3MDL

 Serializable ()

Serializable

 ~Serializable ()

~Serializable

[virtual]

void  save (std::ostream &out, int indentLevel)

save

[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:
outostream to send output to
indentLevelCurrent indent level (this will produce indentLevel*4 spaces at the start of the output lines).

void  load (std::istream &in, SerializableLoadInfo &info)

load

[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:
inistream to take input from
infoObject holding information about the Song being loaded

See also: FileBlockParser., SerializableLoadInfo

indent (class)

indent

[protected]

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

operator<<

[protected]