#include <Serializable.h>
Inheritance diagram for TSE3::Serializable:
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 &) |
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.
See the TSE3MDL class documentation for more details.
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.
|
|
|
|
|
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 ;-)
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. |
|
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.
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. |
|
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"; |