Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

EditableI Class Reference

Editable interface. More...

#include <EditableI.h>

Inheritance diagram for EditableI:

DataBlockI ControllerC EffectI GizmoI KeyC LayerC ParamI SceneC TimeSegmentC FileHandleC FileListC ImportableI List of all members.

Public Methods

virtual DataBlockIcreate ()=0
 Creates new datablock.

virtual DataBlockIcreate (EditableI *pOriginal)=0
 Creates new datablock, with reference to the original.

virtual void copy (EditableI *pEditable)=0
 Deep copy from a data block.

virtual void restore (EditableI *pEditable)=0
 Shallow copy of a data block.

virtual EditableI * duplicate ()
 Duplicates editable.

virtual EditableI * clone ()
 Clones editable.

virtual EditableI * get_original () const
 Returns original editable, if the editable is a clone, else returns 0.

virtual UndoCbegin_editing (UndoC *pUndo)
 Starts new editing scope, returns current undo.

virtual void end_editing (UndoC *pUndo)
 Ends current editing scope, set return previous undo.

virtual UndoCget_undo ()
 Returns current undo.

virtual PajaTypes::uint32 save (FileIO::SaveC *pSave)=0
 Save editable to a Demopaja output stream.

virtual PajaTypes::uint32 load (FileIO::LoadC *pLoad)=0
 Load editable from a Demopaja input stream.


Protected Methods

 EditableI ()
 Default constructor.

 EditableI (EditableI *m_pOriginal)
 Default constructor with reference to the original.

virtual ~EditableI ()
 Default destructor.


Detailed Description

Editable interface.

Editable interfaces is used by all the objects which are editable. The interface defines set of methods which are used for example by the undo-system in Demopaja.


Constructor & Destructor Documentation

EditableI   [protected]
 

Default constructor.

EditableI EditableI *    m_pOriginal [protected]
 

Default constructor with reference to the original.

virtual ~EditableI   [protected, virtual]
 

Default destructor.


Member Function Documentation

virtual UndoC* begin_editing UndoC   pUndo [virtual]
 

Starts new editing scope, returns current undo.

Parameters:
pUndo  Undo object to store the changes.
Begins new undo scope, sets the internal undo object to the object given as argument. The default implmentation uses clone() method to clone data and pushes the clone to the undo restore data queue.

Implemented by the system. If the class needs to store extra information which cannot be stored in the clone() method or a special flag needs to be set, override this method, but remember to call this memeber at the beginning of the overridden method!

virtual EditableI* clone   [virtual]
 

Clones editable.

Makes a clone of the editable and returns it. The duplicated editable has to be released when it is no longer used. The restore() method is used to clone the data. Also the reference to the original data is saved.

Used internally, usually from the begin_editing() method.

See also:
get_original();

virtual void copy EditableI *    pEditable [pure virtual]
 

Deep copy from a data block.

Parameters:
pBlock  Pointer to datablock of same class to data from.
This method should make a deep copy (that is, copy everything) of the instance specified by the argument.

            Example Implementation
            void
            TGAImportC::copy( EditableI* pEditable )
            {
                TGAImportC* pFile = (TGAImportC*)pBlock;

                m_i32Width = pFile->m_i32Width;
                m_i32Height = pFile->m_i32Height;
                m_i32Bpp = pFile->m_i32Bpp;
                m_sFileName = pFile->m_sFileName;

                // duplicate data
                delete m_pData;
                uint32 ui32DataSize = m_i32Width * m_i32Height * (m_i32Bpp / 8);
                m_pData = new uint8[ui32DataSize];
                memcpy( m_pData, pFile->m_pData, ui32DataSize );
            }

Implemented in AutoGizmoC, ControllerC, EffectI, FileHandleC, FileListC, GizmoI, KeyC, FloatKeyC, FileKeyC, LayerC, ParamI, ParamIntC, ParamFloatC, ParamVector2C, ParamVector3C, ParamColorC, ParamTextC, ParamFileC, SceneC, and TimeSegmentC.

virtual DataBlockI* create EditableI *    pOriginal [pure virtual]
 

Creates new datablock, with reference to the original.

Parameters:
pOriginal  Pointer to the original editable. This method is used by the undo system to create a copy of the editable while keeping reference to the original.
The method restore() is used to restore the data from the original copy.

Implemented in AutoGizmoC, ControllerC, FileHandleC, FileListC, KeyC, FloatKeyC, FileKeyC, LayerC, ParamIntC, ParamFloatC, ParamVector2C, ParamVector3C, ParamColorC, ParamTextC, ParamFileC, SceneC, and TimeSegmentC.

virtual DataBlockI* create   [pure virtual]
 

Creates new datablock.

The create method of data block class creates new instance of the same class the data block is.

Example implementation:

            DataBlockI*
            TGAImportC::create()
            {
                return new TGAImportC;
            }

Returns :
Pointer to a new instance of this class.

Implements DataBlockI.

Implemented in AutoGizmoC, ControllerC, FileHandleC, FileListC, KeyC, FloatKeyC, FileKeyC, LayerC, ParamIntC, ParamFloatC, ParamVector2C, ParamVector3C, ParamColorC, ParamTextC, ParamFileC, SceneC, and TimeSegmentC.

virtual EditableI* duplicate   [virtual]
 

Duplicates editable.

Makes a duplicate of the editable and returns it. The duplicated editable has to be released when it is no longer used. The copy() method is used to duplicate the data.

virtual void end_editing UndoC   pUndo [virtual]
 

Ends current editing scope, set return previous undo.

The default implementation sets the given undo object as current undo object.

This method is implemented by the system and used internally.

See also:
begin_editing

virtual EditableI* get_original   const [virtual]
 

Returns original editable, if the editable is a clone, else returns 0.

Every time a editable is cloned a reference to the orginal data is saved too. This methods enables to get the pointer to the original data. This methods is mainly used to determine if the released editable is a clone, hence no data will be released.

Example usage:

            TGAImportC::~TGAImportC()
            {
                // Check if this editable is a clone.
                if( get_original() )
                    return;     // It's clone, return.
                // Delete data
                delete m_pData;
            }

virtual UndoC* get_undo   [virtual]
 

Returns current undo.

Returns current undo object bind by the last begin_editing() call. The return value can be NULL.

Implemented by the system.

virtual PajaTypes::uint32 load FileIO::LoadC   pLoad [pure virtual]
 

Load editable from a Demopaja input stream.

Implemented in AutoGizmoC, ControllerC, EffectI, FileHandleC, FileListC, GizmoI, KeyC, FloatKeyC, FileKeyC, LayerC, ParamI, ParamIntC, ParamFloatC, ParamVector2C, ParamVector3C, ParamColorC, ParamTextC, ParamFileC, SceneC, and TimeSegmentC.

virtual void restore EditableI *    pEditable [pure virtual]
 

Shallow copy of a data block.

Restores the local data from the given data block. This method is used by the Demopaja undo system to restore data from a copy. This method should only do a shallow copy, that is, copy the variables which can be changed by the methods in the interface of the class.

For example if a import plugin class should not copy the data, but only pointer to the data since there isnt any method in the interface which would change the data. If the data can be changed the copy() is called automatically by the system.

Example:

            void
            TGAImportC::restore( EditableI* pEditable )
            {
                TGAImportC* pFile = (TGAImportC*)pEditable;

                m_ui32TextureId = pFile->m_ui32TextureId;
                m_pData = pFile->m_pData;
                m_i32Width = pFile->m_i32Width;
                m_i32Height = pFile->m_i32Height;
                m_i32Bpp = pFile->m_i32Bpp;
                m_sFileName = pFile->m_sFileName;
            }

See also:
DataBlockI::copy

Implemented in AutoGizmoC, ControllerC, EffectI, FileHandleC, FileListC, GizmoI, KeyC, FloatKeyC, FileKeyC, LayerC, ParamI, ParamIntC, ParamFloatC, ParamVector2C, ParamVector3C, ParamColorC, ParamTextC, ParamFileC, SceneC, and TimeSegmentC.

virtual PajaTypes::uint32 save FileIO::SaveC   pSave [pure virtual]
 

Save editable to a Demopaja output stream.

Implemented in AutoGizmoC, ControllerC, EffectI, FileHandleC, FileListC, GizmoI, KeyC, FloatKeyC, FileKeyC, LayerC, ParamI, ParamIntC, ParamFloatC, ParamVector2C, ParamVector3C, ParamColorC, ParamTextC, ParamFileC, SceneC, and TimeSegmentC.


Moppi Demopaja SDK Documentation -- Copyright © 2000-2002 Moppi Productions