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

# Edit::EditableI Class Reference

Editable interface. More...

`#include <EditableI.h>`

Inheritance diagram for Edit::EditableI:

List of all members.

## Public Methods

- virtual DataBlockI* create () = 0
- virtual DataBlockI* create ( EditableI* pOriginal ) = 0
- virtual void copy ( DataBlockI* pBlock ) = 0
- virtual void restore ( EditableI* pEditable ) = 0
- virtual EditableI* duplicate ()
- virtual EditableI* clone ()
- virtual EditableI* get_original () const
- virtual UndoC* begin_editing ( UndoC* pUndo )
- virtual void end_editing ( UndoC* pUndo )
- virtual UndoC* get_undo ()
- virtual PajaTypes::uint32 save ( FileIO::SaveC* pSave ) = 0
- virtual PajaTypes::uint32 load ( FileIO::LoadC* pLoad ) = 0

## Protected Methods

- EditableI ()
- EditableI ( EditableI* m_pOriginal )
- virtual ~EditableI ()

## 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.

~EditableI ( | )`[protected, virtual]`

| Default destructor.

## Member Function Documentation

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!

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 ( | DataBlockI * pBlock )`[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( DataBlockI* pBlock )
                {
                    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 );
                }
Reimplemented from Edit::DataBlockI. Reimplemented in Composition::ControllerC, Composition::EffectI, Import::FileHandleC, Import::FileListC, Composition::GizmoI, Composition::KeyC, Composition::LayerC, Composition::ParamI, Composition::ParamIntC, Composition::ParamFloatC, Composition::ParamVector2C, Composition::ParamVector3C, Composition::ParamColorC, Composition::ParamTextC, Composition::ParamFileC, Composition::SceneC, and Composition::TimeSegmentC.

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. Reimplemented in Composition::ControllerC, Import::FileHandleC, Import::FileListC, Composition::KeyC, Composition::LayerC, Composition::ParamIntC, Composition::ParamFloatC, Composition::ParamVector2C, Composition::ParamVector3C, Composition::ParamColorC, Composition::ParamTextC, Composition::ParamFileC, Composition::SceneC, and Composition::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. Reimplemented from Edit::DataBlockI. Reimplemented in Composition::ControllerC, Import::FileHandleC, Import::FileListC, Composition::KeyC, Composition::LayerC, Composition::ParamIntC, Composition::ParamFloatC, Composition::ParamVector2C, Composition::ParamVector3C, Composition::ParamColorC, Composition::ParamTextC, Composition::ParamFileC, Composition::SceneC, and Composition::TimeSegmentC.

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.

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

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;
                }

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.

PajaTypes::uint32 load ( | FileIO::LoadC * pLoad )`[pure virtual]`

| Load editable from a Demopaja input stream. Reimplemented in Composition::ControllerC, Composition::EffectI, Import::FileHandleC, Import::FileListC, Composition::GizmoI, Composition::KeyC, Composition::LayerC, Composition::ParamI, Composition::ParamIntC, Composition::ParamFloatC, Composition::ParamVector2C, Composition::ParamVector3C, Composition::ParamColorC, Composition::ParamTextC, Composition::ParamFileC, Composition::SceneC, and Composition::TimeSegmentC.

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 Reimplemented in Composition::ControllerC, Composition::EffectI, Import::FileHandleC, Import::FileListC, Composition::GizmoI, Composition::KeyC, Composition::LayerC, Composition::ParamI, Composition::ParamIntC, Composition::ParamFloatC, Composition::ParamVector2C, Composition::ParamVector3C, Composition::ParamColorC, Composition::ParamTextC, Composition::ParamFileC, Composition::SceneC, and Composition::TimeSegmentC.

PajaTypes::uint32 save ( | FileIO::SaveC * pSave )`[pure virtual]`

| Save editable to a Demopaja output stream. Reimplemented in Composition::ControllerC, Composition::EffectI, Import::FileHandleC, Import::FileListC, Composition::GizmoI, Composition::KeyC, Composition::LayerC, Composition::ParamI, Composition::ParamIntC, Composition::ParamFloatC, Composition::ParamVector2C, Composition::ParamVector3C, Composition::ParamColorC, Composition::ParamTextC, Composition::ParamFileC, Composition::SceneC, and Composition::TimeSegmentC.

The documentation for this class was generated from the following file:

- EditableI.h