Mapper  0.9.0
API documentation
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
OpenOrienteering::ObjectModifyingUndoStep Class Reference

Base class for undo steps which modify objects of a single map part. More...

#include <object_undo.h>

Inheritance diagram for OpenOrienteering::ObjectModifyingUndoStep:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::ObjectModifyingUndoStep:
Collaboration graph
[legend]

Public Member Functions

 ObjectModifyingUndoStep (Type type, Map *map)
 Creates an ObjectModifyingUndoStep for the given map and its current part. More...
 
 ObjectModifyingUndoStep (Type type, Map *map, int part_index)
 Creates an ObjectModifyingUndoStep for the given map and part. More...
 
 ~ObjectModifyingUndoStep () override
 Destructor. More...
 
int getPartIndex () const
 Returns the index of the map part modified by this undo step. More...
 
void setPartIndex (int part_index)
 Set the index of the map part modified by this undo step. More...
 
virtual bool isEmpty () const
 Returns true if no objects are modified by this undo step. More...
 
virtual void addObject (int index)
 Adds an object (by index) to this step. More...
 
bool getModifiedParts (PartSet &out) const override
 Adds the the step's modified part to the container provided by out. More...
 
void getModifiedObjects (int part_index, ObjectSet &out) const override
 Adds the list of the step's modified objects to the container provided by out. More...
 
- Public Member Functions inherited from OpenOrienteering::UndoStep
 UndoStep (Type type, Map *map)
 Constructs an undo step having the given type. More...
 
 UndoStep (const UndoStep &)=delete
 
 UndoStep (UndoStep &&)=delete
 
virtual ~UndoStep ()
 Destructor. More...
 
UndoStepoperator= (const UndoStep &)=delete
 
UndoStepoperator= (UndoStep &&)=delete
 
Type getType () const
 Returns the type of the undo step. More...
 
virtual bool isValid () const
 Returns true if the step can still be undone. More...
 
virtual UndoStepundo ()=0
 Undoes the action and returns a new UndoStep. More...
 
void save (QXmlStreamWriter &xml) const
 Saves the undo step to the stream in xml format. More...
 

Protected Types

typedef std::vector< int > ObjectList
 A list of indices referring to objects in a map part. More...
 

Protected Member Functions

void saveImpl (QXmlStreamWriter &xml) const override
 Saves undo properties to the the xml stream. More...
 
virtual void saveObject (XmlElementWriter &xml, int index) const
 Saves object details to the the xml stream. More...
 
void loadImpl (QXmlStreamReader &xml, SymbolDictionary &symbol_dict) override
 Loads undo properties from the the xml stream. More...
 
virtual void loadObject (XmlElementReader &xml, int index)
 Loads object details from the the xml stream. More...
 

Protected Attributes

ObjectList modified_objects
 Indices of the existing objects that are modified by this step. More...
 
- Protected Attributes inherited from OpenOrienteering::UndoStep
Type const type
 The type of the undo step. More...
 
Map *const map
 The map this undo step belongs. More...
 

Additional Inherited Members

- Public Types inherited from OpenOrienteering::UndoStep
enum  Type {
  ReplaceObjectsUndoStepType = 0, DeleteObjectsUndoStepType = 1, AddObjectsUndoStepType = 2, SwitchSymbolUndoStepType = 3,
  SwitchDashesUndoStepType = 4, CombinedUndoStepType = 5, ValidNoOpUndoStepType = 6, ObjectTagsUndoStepType = 7,
  MapPartUndoStepType = 8, SwitchPartUndoStepTypeV0 = 9, SwitchPartUndoStepType = 10, InvalidUndoStepType = 999
}
 Types of undo steps for identification. More...
 
typedef std::set< int > PartSet
 A set of integers referring to parts. More...
 
typedef std::set< Object * > ObjectSet
 A set of pointers to objects. More...
 
- Static Public Member Functions inherited from OpenOrienteering::UndoStep
static UndoStepgetUndoStepForType (Type type, Map *map)
 Constructs an undo step of the given type. More...
 
static UndoStepload (QXmlStreamReader &xml, Map *map, SymbolDictionary &symbol_dict)
 Loads the undo step from the stream in xml format. More...
 

Detailed Description

Base class for undo steps which modify objects of a single map part.

Member Typedef Documentation

◆ ObjectList

typedef std::vector<int> OpenOrienteering::ObjectModifyingUndoStep::ObjectList
protected

A list of indices referring to objects in a map part.

Constructor & Destructor Documentation

◆ ObjectModifyingUndoStep() [1/2]

OpenOrienteering::ObjectModifyingUndoStep::ObjectModifyingUndoStep ( Type  type,
Map map 
)

Creates an ObjectModifyingUndoStep for the given map and its current part.

◆ ObjectModifyingUndoStep() [2/2]

OpenOrienteering::ObjectModifyingUndoStep::ObjectModifyingUndoStep ( Type  type,
Map map,
int  part_index 
)

Creates an ObjectModifyingUndoStep for the given map and part.

◆ ~ObjectModifyingUndoStep()

OpenOrienteering::ObjectModifyingUndoStep::~ObjectModifyingUndoStep ( )
override

Destructor.

Member Function Documentation

◆ addObject()

void OpenOrienteering::ObjectModifyingUndoStep::addObject ( int  index)
virtual

Adds an object (by index) to this step.

The object must belong to the step's part.

Reimplemented in OpenOrienteering::ObjectTagsUndoStep, and OpenOrienteering::ObjectCreatingUndoStep.

◆ getModifiedObjects()

void OpenOrienteering::ObjectModifyingUndoStep::getModifiedObjects ( int  part_index,
ObjectSet out 
) const
overridevirtual

Adds the list of the step's modified objects to the container provided by out.

Only adds objects when the given part_index matches this step's part index.

Reimplemented from OpenOrienteering::UndoStep.

Reimplemented in OpenOrienteering::SwitchPartUndoStep, OpenOrienteering::DeleteObjectsUndoStep, and OpenOrienteering::ObjectCreatingUndoStep.

◆ getModifiedParts()

bool OpenOrienteering::ObjectModifyingUndoStep::getModifiedParts ( PartSet out) const
overridevirtual

Adds the the step's modified part to the container provided by out.

Returns
True if there are objects modified by this undo step, false otherwise.

Reimplemented from OpenOrienteering::UndoStep.

Reimplemented in OpenOrienteering::SwitchPartUndoStep, and OpenOrienteering::DeleteObjectsUndoStep.

◆ getPartIndex()

int OpenOrienteering::ObjectModifyingUndoStep::getPartIndex ( ) const
inline

Returns the index of the map part modified by this undo step.

◆ isEmpty()

bool OpenOrienteering::ObjectModifyingUndoStep::isEmpty ( ) const
virtual

Returns true if no objects are modified by this undo step.

◆ loadImpl()

void OpenOrienteering::ObjectModifyingUndoStep::loadImpl ( QXmlStreamReader xml,
SymbolDictionary symbol_dict 
)
overrideprotectedvirtual

Loads undo properties from the the xml stream.

Implementations in derived classes shall first check the element's name for one of their own elements, and otherwise call the parent class' implementation.

Reimplemented from OpenOrienteering::UndoStep.

Reimplemented in OpenOrienteering::SwitchSymbolUndoStep, OpenOrienteering::SwitchPartUndoStep, and OpenOrienteering::ObjectCreatingUndoStep.

◆ loadObject()

void OpenOrienteering::ObjectModifyingUndoStep::loadObject ( XmlElementReader xml,
int  index 
)
protectedvirtual

Loads object details from the the xml stream.

The default implemenentation does nothing.

Reimplemented in OpenOrienteering::ObjectTagsUndoStep.

◆ saveImpl()

void OpenOrienteering::ObjectModifyingUndoStep::saveImpl ( QXmlStreamWriter xml) const
overrideprotectedvirtual

Saves undo properties to the the xml stream.

Implementations in derived classes shall first call the parent class' implementation, and then start a new element for additional properties.

Reimplemented from OpenOrienteering::UndoStep.

Reimplemented in OpenOrienteering::SwitchSymbolUndoStep, OpenOrienteering::SwitchPartUndoStep, and OpenOrienteering::ObjectCreatingUndoStep.

◆ saveObject()

void OpenOrienteering::ObjectModifyingUndoStep::saveObject ( XmlElementWriter xml,
int  index 
) const
protectedvirtual

Saves object details to the the xml stream.

The default implemenentation does nothing.

Reimplemented in OpenOrienteering::ObjectTagsUndoStep.

◆ setPartIndex()

void OpenOrienteering::ObjectModifyingUndoStep::setPartIndex ( int  part_index)

Set the index of the map part modified by this undo step.

This must not be called after object have been added.

Member Data Documentation

◆ modified_objects

ObjectList OpenOrienteering::ObjectModifyingUndoStep::modified_objects
protected

Indices of the existing objects that are modified by this step.


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