Document::Document Class Reference

The set of data the editor exists to manipulate. More...

#include <Document.h>

List of all members.

Public Member Functions

 Document (const Track::Theme &theme)
 Initalise an default document for a given theme.
 Document (std::istream &source, const Track::Theme &theme)
 Initalise from a stream.
virtual ~Document ()
void do_command (boost::shared_ptr< DocumentDelta > delta)
 Perform a command This clears any avaliable redos, and adds it to the stack of undo commands.
void preview_command (boost::shared_ptr< DocumentDelta > delta)
 Show the effect of a command for a preview.
void cancel_preview ()
 Undo the last preview_command().
void undo_command ()
 Undo the last command done.
void redo_command ()
 Redo a command that was previously undone.
sigc::signal< void > signal_command_run ()
 Signal that is emitted whenever a command is run.
bool get_undo_avaliable () const
 Check if there are commands to be undone.
bool get_redo_avaliable () const
 Check if there are commands to be redone.
void save (std::ostream &destination)
 Save the document.
bool is_saved () const
 Is the document in the state it was saved in?
unsigned int get_changes_since_save () const
 Return the number of commands done (or undone) since the last save.
const Track::Trackget_track () const
 Return the track so it can be displayed.

Protected Attributes

Track::Track track
 The track in the document in its current state.
std::vector< boost::shared_ptr<
DocumentDelta > > 
done
 Stack of commands that have been done.
std::vector< boost::shared_ptr<
DocumentDelta > > 
undone
 Stack of commands that have been undone.
sigc::signal< void > m_signal_command_run
 Signal to emit when a delta is applied or unapplied.
signed int commands_from_save
 Count undo / redo history to the point where the file is saved.
bool saved_in_history
 True if the state when the document was saved is stored in the undo / redo history.
boost::shared_ptr< DocumentDeltatemporary_command
 Command to preview the effects of.


Detailed Description

The set of data the editor exists to manipulate.

Anything that responds to open, save, undo, or redo is in a document. The editor has a single document it works on at once.

Definition at line 34 of file Document.h.


Constructor & Destructor Documentation

Document::Document::Document ( const Track::Theme theme  ) 

Initalise an default document for a given theme.

Called when a theme is selected for a new document.

Document::Document::Document ( std::istream &  source,
const Track::Theme theme 
)

Initalise from a stream.

Most likely caused from an open command. This should behave exactly like

 Track::Track(source, theme) 
Parameters:
source The stream to extract data from. It is advanced to the end of the document.
theme The theme of the track.

virtual Document::Document::~Document (  )  [virtual]


Member Function Documentation

void Document::Document::cancel_preview (  ) 

Undo the last preview_command().

This action is also performed when do_command(), undo_command(), redo_command(), preview_command(), or save() are used.

void Document::Document::do_command ( boost::shared_ptr< DocumentDelta delta  ) 

Perform a command This clears any avaliable redos, and adds it to the stack of undo commands.

Parameters:
delta The command to perform. If 0, no command is performed, but any previewed command is undone.

unsigned int Document::Document::get_changes_since_save (  )  const

Return the number of commands done (or undone) since the last save.

bool Document::Document::get_redo_avaliable (  )  const

Check if there are commands to be redone.

Returns:
 true 
if a command can be redone,
 false
if there are no commands to be redone.

const Track::Track& Document::Document::get_track (  )  const

Return the track so it can be displayed.

bool Document::Document::get_undo_avaliable (  )  const

Check if there are commands to be undone.

Returns:
 true 
if a command can be undone,
 false
if all commands have already been undone.

bool Document::Document::is_saved (  )  const

Is the document in the state it was saved in?

Returns:
true if the document is in the state it was saved in, false if it has been modified.

void Document::Document::preview_command ( boost::shared_ptr< DocumentDelta delta  ) 

Show the effect of a command for a preview.

This performs a command, but it is automatically undone later. It is useful for showing the effect of a command while varying parameters.

The command is performed immediately, but undone if any of these functions are performed: do_command(), undo_command(), redo_command(), preview_command(), cancel_preview(), and save().

To accept the change, call do_command() with the final delta. To cancel undo it with no other side effects, call cancel_preview().

The redo history is not lost when using preview_command().

Parameters:
delta The command to perform. If 0, no command is performed, but the previous preview may be undone.

void Document::Document::redo_command (  ) 

Redo a command that was previously undone.

void Document::Document::save ( std::ostream &  destination  ) 

Save the document.

sigc::signal<void> Document::Document::signal_command_run (  ) 

Signal that is emitted whenever a command is run.

This incudes when a command is undone. Use this to update the display in the editor. The prototype function for the handler is:

 void on_command_run(); 

void Document::Document::undo_command (  ) 

Undo the last command done.


Member Data Documentation

signed int Document::Document::commands_from_save [protected]

Count undo / redo history to the point where the file is saved.

For every action undone, this is decrement, for every action redone, it is incremented. If it is 0 and

is
 true 
, the document is in the saved state.

Definition at line 145 of file Document.h.

std::vector<boost::shared_ptr<DocumentDelta> > Document::Document::done [protected]

Stack of commands that have been done.

Definition at line 132 of file Document.h.

sigc::signal<void> Document::Document::m_signal_command_run [protected]

Signal to emit when a delta is applied or unapplied.

Definition at line 138 of file Document.h.

bool Document::Document::saved_in_history [protected]

True if the state when the document was saved is stored in the undo / redo history.

Definition at line 150 of file Document.h.

boost::shared_ptr<DocumentDelta> Document::Document::temporary_command [protected]

Command to preview the effects of.

If 0, we are not previewing any command. Otherwise, we should undo the command before doing anything else.

Definition at line 156 of file Document.h.

Track::Track Document::Document::track [protected]

The track in the document in its current state.

Definition at line 129 of file Document.h.

std::vector<boost::shared_ptr<DocumentDelta> > Document::Document::undone [protected]

Stack of commands that have been undone.

Definition at line 135 of file Document.h.


The documentation for this class was generated from the following file:
Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:16 2010 by Doxygen version 1.4.7 for Racer version svn335.