Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
jm::Document Class Referenceabstract

This class represents the "model" in the MVC context. This class is also the ideal parent class for all document-based applications, because basic functionalities that every user expects are already predefined here. In addition, development time is saved. These include: More...

Inheritance diagram for jm::Document:
jm::Object

Public Member Functions

 Document ()
 Constructor.
 
 ~Document () override
 Destructor.
 
virtual void closeUndoStep ()
 Closes the undo step. This method should be called by applications.
 
UndoManagerundoManager ()
 Returns the undo manager if it exists.
 
void setUndoManager (bool status)
 Determines whether an undo manager exists or not.
 
bool hasUndoManager () const
 Returns the status of whether an undo manager exists.
 
bool isDocumentChanged () const
 Returns the status of whether the document has been edited since last saving.
 
void setDocumentChanged (bool status)
 Sets the status of whether the file has been changed.
 
void setFile (const File &file)
 Sets the file for this document.
 
const Filefile () const
 Returns the File object of this document.
 
FilefileRef ()
 
virtual bool saveDocument ()=0
 Saves the file on the drive.
 
virtual bool loadDocument ()=0
 Loads the file from the drive.
 
virtual Status initNewDocument (Preferences *props)=0
 Initializes an "empty" document, ready for the user to work with it.
 
virtual void regenerate ()
 Determines that the visual representation should be renewed for this document in the next run.
 
virtual void regenerationDone ()
 This method should be called by the regeneration method after the visual representation of this object has been updated.
 
virtual bool shouldRegenerate () const
 Returns the regeneration status.
 
- Public Member Functions inherited from jm::Object
 Object () noexcept
 Constructor.
 
virtual ~Object () noexcept
 Destructor.
 
void release () noexcept
 Decreases the reference counter and releases the object immediately when the reference counter becomes 0.
 
Objectretain () noexcept
 Increases the reference counter of this object by 1.
 
Objectautorelease () noexcept
 Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object.
 
int32 referenceCount () const noexcept
 Returns the value of the reference counter.
 
virtual bool equals (const Object *other) const
 Comparison of objects.
 
virtual String displayName () const
 Returns the display name of the object intended to present to a user.
 
virtual void printDiffInfo (DiffOperation operation, Object *other) const
 Output method for outputting the diff results for the diff algorithm.
 
void setHighBit (bool status) noexcept
 
bool highBit () const noexcept
 

Detailed Description

This class represents the "model" in the MVC context. This class is also the ideal parent class for all document-based applications, because basic functionalities that every user expects are already predefined here. In addition, development time is saved. These include:

Constructor & Destructor Documentation

◆ Document()

jm::Document::Document ( )

Constructor.

Shall create an empty not initialized document.

In the constructor here, the UndoManager is already activated. This means that, for example, the entire process of reading a document from the hard disk is already "logged" as a single undo step. This is absolutely necessary, however, so that when objects are deleted, they are retained on the UndoStack, because the LinkedList, for example, does not manage the pointers itself, but only via the UndoStack.

◆ ~Document()

jm::Document::~Document ( )
override

Destructor.

Member Function Documentation

◆ closeUndoStep()

virtual void jm::Document::closeUndoStep ( )
virtual

Closes the undo step. This method should be called by applications.

◆ file()

const File & jm::Document::file ( ) const

Returns the File object of this document.

◆ fileRef()

File * jm::Document::fileRef ( )

◆ hasUndoManager()

bool jm::Document::hasUndoManager ( ) const

Returns the status of whether an undo manager exists.

◆ initNewDocument()

virtual Status jm::Document::initNewDocument ( Preferences props)
pure virtual

Initializes an "empty" document, ready for the user to work with it.

The constructor creates an empty, uninitialised document. However, an "empty" and new document from the user's point of view may contain content that is mandatory or preset. However, this content must not be present when a document is loaded. Therefore, this content must be deliberately created here.

Warning
If this method is to be called, loadDocument() must not be called and vice versa.
Parameters
propsSettings, which pass programme settings to the file, if applicable.

◆ isDocumentChanged()

bool jm::Document::isDocumentChanged ( ) const

Returns the status of whether the document has been edited since last saving.

This value is set to false when saving. Nevertheless, the undo manager can contain steps for undo.

◆ loadDocument()

virtual bool jm::Document::loadDocument ( )
pure virtual

Loads the file from the drive.

This method shall called by your software when the file shall be loaded. file() returns the file.

Warning
If this method is to be called, initNewDocument() must not be called and vice versa.

Must be implemented by derived classes.

◆ regenerate()

virtual void jm::Document::regenerate ( )
virtual

Determines that the visual representation should be renewed for this document in the next run.

◆ regenerationDone()

virtual void jm::Document::regenerationDone ( )
virtual

This method should be called by the regeneration method after the visual representation of this object has been updated.

◆ saveDocument()

virtual bool jm::Document::saveDocument ( )
pure virtual

Saves the file on the drive.

This method shall called by your software when the file shall be saved. file() returns the file.

Must be implemented by derived classes.

◆ setDocumentChanged()

void jm::Document::setDocumentChanged ( bool  status)

Sets the status of whether the file has been changed.

This method is primary intended for internal use. Setting this value affects whether the file is "marked" as changed. Whenever the file is saved, this value is set to false. In the undo mechanism, this value is set automatically and only needs to be changed manually if you do not use the undo mechanism.

Parameters
statusstatus if whether the file hase been changed (true) or not (\ false)

◆ setFile()

void jm::Document::setFile ( const File file)

Sets the file for this document.

◆ setUndoManager()

void jm::Document::setUndoManager ( bool  status)

Determines whether an undo manager exists or not.

If the value is set to yes and no undomanager exists, one is created. If one already exists, nothing happens. If the value is set to no, a possible undo manager is released.

Parameters
statusTurn undo manager on (true) or off (false).

◆ shouldRegenerate()

virtual bool jm::Document::shouldRegenerate ( ) const
virtual

Returns the regeneration status.

◆ undoManager()

UndoManager * jm::Document::undoManager ( )

Returns the undo manager if it exists.