Emergency 2017 Dokumentation  v3.0.1
qsf::editor::base::Operation Class Referenceabstract

Abstract operation base class. More...

#include <Operation.h>

Public Member Functions

virtual ~Operation ()
 Destructor. More...
 
std::string getText () const
 Return the text of the operation. More...
 
void setText (const std::string &text)
 Set the text of the operation. More...
 
uint32 getUserId () const
 Return the ID of the user issuing the operation. More...
 
void setUserId (uint32 userId)
 Set the ID of the user issuing the operation. More...
 
bool isSealed () const
 
void seal ()
 Seal the operation after constructing it using the default constructor and explicitly using setters for all parameters. More...
 
void undo ()
 Undo the operation. More...
 
void redo ()
 Redo the operation. More...
 
virtual uint32 getId () const =0
 Return the unique operation identifier. More...
 
virtual bool isReversible () const
 Return whether or not the operation will end up in the undo/redo stack. More...
 
virtual bool isLocal () const
 Return whether or not the operation is local only. More...
 
virtual bool isReplicated () const
 Return whether or not the operation is replicated by the server to all other relevant clients. More...
 
virtual size_t getMemoryConsumption () const
 Return the memory consumption of this operation. More...
 
virtual void sealImpl ()
 Seal the operation after constructing it using the default constructor and explicitly using setters for all parameters. More...
 
virtual void undoImpl ()
 Undo the operation (common actions to always be executed) More...
 
virtual void redoImpl ()
 Redo the operation (common actions to always be executed) More...
 
- Public Member Functions inherited from qsf::Object
virtual ~Object ()
 Destructor. More...
 
const camp::Class & getCampClass () const
 Return the CAMP class. More...
 
int getPropertyIndexById (const StringHash &propertyId) const
 Return the CAMP property index by using the unique class property ID. More...
 
uint32 getPropertyIdByIndex (int index) const
 Return the unique class property ID with the given index. More...
 
std::string getPropertyNameById (const StringHash &propertyId) const
 Return the CAMP property name by using the unique class property ID. More...
 
const camp::Property * getCampPropertyById (const StringHash &propertyId) const
 Return the CAMP property by using the unique class property ID. More...
 
void setPropertyValuesByString (const std::string &values)
 Set CAMP reflection property values by using a given string. More...
 
void setPropertiesToDefaultValues ()
 Set all CAMP reflection system properties to their default values. More...
 
void serializeToBoostPTree (boost::property_tree::ptree &pTree, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
void serializeToBoostPTree (boost::property_tree::ptree &pTree, const camp::Class &campClass, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
bool deserializeFromBoostPTree (const boost::property_tree::ptree &pTree, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL)
 
bool deserializeFromBoostPTree (const boost::property_tree::ptree &pTree, const camp::Class &campClass, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL)
 
void serializeToBinarySerializer (BinarySerializer &serializer, SerializationMode mode=MODE_MINIMAL, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
void deserializeFromBinarySerializer (BinarySerializer &serializer, SerializationMode mode=MODE_MINIMAL, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL, bool setOverrideState=true)
 
virtual camp::Value getPropertyDefaultValue (const StringHash &propertyId) const
 
virtual PropertyOverrideState getPropertyOverrideState (const StringHash &propertyId) const
 
virtual bool setPropertyOverrideState (const StringHash &propertyId, PropertyOverrideState overrideState)
 
virtual void onPreDeserialize ()
 Called right before the object is deserialized using any of the above methods. Default implementation is empty. More...
 
virtual void onPostDeserialize ()
 Called right after the object was deserialized using any of the above methods. Default implementation is empty. More...
 
virtual ScriptgetAssociatedScript () const
 Return the script instance associated with this object instance. More...
 

Protected Member Functions

 Operation ()
 Default constructor. More...
 
- Protected Member Functions inherited from qsf::Object
 Object ()
 Default constructor. More...
 

Protected Attributes

CompoundOperationmParentOperation
 Parent compound operation, can be a null pointer, do not destroy the instance. More...
 

Friends

class CompoundOperation
 

Additional Inherited Members

- Public Types inherited from qsf::Object
enum  PropertyOverrideState { PROPERTY_INVALID, PROPERTY_DEFAULT, PROPERTY_OVERRIDE, PROPERTY_REMOVED }
 
enum  SerializationMethod { SERIALIZE_FLAT, SERIALIZE_COMPLETE, SERIALIZE_DIFFERENTIAL, SERIALIZE_IGNORE_UNKNOWN }
 
enum  SerializationMode { MODE_MINIMAL, MODE_COMPATIBLE }
 

Detailed Description

Abstract operation base class.

Note
  • Base class for undo/redo and cooperative work operations
  • This class is using the command design pattern as described within the book "Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1994). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley. ISBN 0-201-63361-2."
Todo:
  • TODO(co) Optimization: We might want to use "qsf::PagedAllocator" in order to avoid overusing the C++ memory heap

Definition at line 66 of file Operation.h.

Constructor & Destructor Documentation

virtual qsf::editor::base::Operation::~Operation ( )
virtual

Destructor.

qsf::editor::base::Operation::Operation ( )
protected

Default constructor.

Member Function Documentation

virtual uint32 qsf::editor::base::Operation::getId ( ) const
pure virtual

Return the unique operation identifier.

Returns
The unique operation identifier
Note
  • The unique operation identifier is generated by "qsf::StringHash" by using the class name

Implemented in qsf::editor::base::SetComponentPropertyOperation, qsf::editor::base::CompoundOperation, qsf::editor::base::SetLayerPropertyOperation, qsf::editor::base::CreateEntityOperation, qsf::editor::base::PasteComponentDataOperation, qsf::editor::base::DestroyEntityOperation, qsf::editor::base::DestroyLayerOperation, qsf::editor::base::DestroyComponentOperation, qsf::editor::TerrainOperation, qsf::editor::base::DeselectEntityHiddenOperation, qsf::editor::base::SelectEntityHiddenOperation, qsf::editor::SelectLayerOperation, qsf::editor::SelectEdgeOperation, qsf::editor::UnselectEdgeOperation, qsf::editor::SelectNodeOperation, qsf::editor::SelectObjectOperation, qsf::editor::base::CreateComponentOperation, qsf::editor::base::TriggerMessageOperation, qsf::editor::AddEdgesToSelectionOperation, qsf::editor::RemoveEdgesFromSelectionOperation, qsf::editor::AddNodesToSelectionOperation, qsf::editor::RemoveNodesFromSelectionOperation, qsf::editor::base::CreateLayerOperation, qsf::editor::base::SetParentLayerOperation, qsf::editor::base::ChatMessageOperation, qsf::editor::HideEntityOperation, qsf::editor::HideLayerOperation, qsf::editor::SelectComponentOperation, qsf::editor::base::AddEntitiesToSelectionOperation, qsf::editor::base::RemoveEntitiesFromSelectionOperation, qsf::editor::base::SelectEntityOperation, qsf::editor::SetCurrentEntityOperation, qsf::editor::base::EntitySelectionOperation, qsf::editor::base::CommitOperation, qsf::editor::RebuildGuiOperation, qsf::editor::SequenceChangeSelectionOperation, qsf::editor::SequenceMovePlayheadOperation, qsf::editor::SequenceModifyTrackKeyValueOperation, qsf::editor::SequenceAddTrackKeyOperation, qsf::editor::base::LockEntityOperation, qsf::editor::base::UnlockEntityOperation, qsf::editor::SequenceRemoveTrackKeyOperation, qsf::editor::SequenceRemoveTrackOperation, qsf::editor::SequenceAddTrackOperation, and qsf::editor::SequenceAddDirectorTrackOperation.

virtual size_t qsf::editor::base::Operation::getMemoryConsumption ( ) const
virtual

Return the memory consumption of this operation.

Returns
The memory consumption in bytes of this operation
Note
  • The memory consumption of cooperative work operations is usually lower because there's no need to store data required for undoing an operation
  • The default implementation returns 0

Reimplemented in qsf::editor::base::SetComponentPropertyOperation, qsf::editor::base::CompoundOperation, qsf::editor::base::SetLayerPropertyOperation, qsf::editor::base::CreateEntityOperation, qsf::editor::base::PasteComponentDataOperation, qsf::editor::base::DestroyEntityOperation, qsf::editor::base::DestroyLayerOperation, qsf::editor::base::DestroyComponentOperation, qsf::editor::TerrainOperation, qsf::editor::base::LayerOperation, qsf::editor::SelectLayerOperation, qsf::editor::base::EntityOperation, qsf::editor::SelectEdgeOperation, qsf::editor::UnselectEdgeOperation, qsf::editor::SelectNodeOperation, qsf::editor::base::CreateComponentOperation, qsf::editor::base::TriggerMessageOperation, qsf::editor::base::ComponentOperation, qsf::editor::AddEdgesToSelectionOperation, qsf::editor::RemoveEdgesFromSelectionOperation, qsf::editor::AddNodesToSelectionOperation, qsf::editor::RemoveNodesFromSelectionOperation, qsf::editor::base::CreateLayerOperation, qsf::editor::base::SetParentLayerOperation, qsf::editor::base::MapOperation, qsf::editor::base::ChatMessageOperation, qsf::editor::HideEntityOperation, qsf::editor::HideLayerOperation, qsf::editor::base::AddEntitiesToSelectionOperation, qsf::editor::base::RemoveEntitiesFromSelectionOperation, qsf::editor::SetCurrentEntityOperation, qsf::editor::base::SelectEntityOperation, qsf::editor::SequenceOperation, qsf::editor::SequenceChangeSelectionOperation, qsf::editor::SequenceMovePlayheadOperation, qsf::editor::SequenceTrackOperation, qsf::editor::SequenceModifyTrackKeyValueOperation, qsf::editor::SequenceAddTrackKeyOperation, qsf::editor::SequenceRemoveTrackKeyOperation, qsf::editor::SequenceRemoveTrackOperation, qsf::editor::SequenceAddTrackOperation, and qsf::editor::SequenceAddDirectorTrackOperation.

std::string qsf::editor::base::Operation::getText ( ) const

Return the text of the operation.

Returns
The UTF-8 text of the operation
uint32 qsf::editor::base::Operation::getUserId ( ) const

Return the ID of the user issuing the operation.

Returns
The ID of the user issuing the operation
virtual bool qsf::editor::base::Operation::isLocal ( ) const
virtual

Return whether or not the operation is local only.

Returns
"true" if it's a local operation, else "false"
Remarks
Inside the QSF editor, operations have to use cases:
  • Undo/redo
  • cooperative work

For example the select layer operation is considered to be a local operation. While it is necessary that this operation will end up on the undo/redo stack, it does not make any sense to commit this operation to the server for cooperative work. Most of the operations are not local only.

Note
  • The default implementation returns "false"

Reimplemented in qsf::editor::TerrainOperation, qsf::editor::SelectLayerOperation, qsf::editor::SelectObjectOperation, qsf::editor::HideEntityOperation, qsf::editor::HideLayerOperation, qsf::editor::SelectComponentOperation, qsf::editor::SetCurrentEntityOperation, qsf::editor::EdgeSelectionOperation, qsf::editor::NodeSelectionOperation, and qsf::editor::RebuildGuiOperation.

virtual bool qsf::editor::base::Operation::isReplicated ( ) const
virtual

Return whether or not the operation is replicated by the server to all other relevant clients.

Returns
"true" if it's a replicated operation, else "false"
Remarks
Some non-local operations are not meant to be replicated by the server. (e.g. EntitySelectOperation)
Note
  • The default implementation returns "true"

Reimplemented in qsf::editor::base::EntitySelectionOperation, and qsf::editor::base::CommitOperation.

virtual bool qsf::editor::base::Operation::isReversible ( ) const
virtual

Return whether or not the operation will end up in the undo/redo stack.

Returns
"true" if the operation will end up in the undo/redo stack, else "false"
Note
  • The default implementation returns "true"

Reimplemented in qsf::editor::base::DeselectEntityHiddenOperation, qsf::editor::base::SelectEntityHiddenOperation, qsf::editor::base::TriggerMessageOperation, qsf::editor::base::ChatMessageOperation, qsf::editor::base::CommitOperation, qsf::editor::RebuildGuiOperation, qsf::editor::base::LockEntityOperation, and qsf::editor::base::UnlockEntityOperation.

bool qsf::editor::base::Operation::isSealed ( ) const
Note
Use ease-of-use define for setters: QSF_OPERATION_CHECK_SEAL
Returns
true if the operation is sealed and no setters may be used anymore
void qsf::editor::base::Operation::redo ( )

Redo the operation.

Note
This method barely contains some boilerplate code see/override redoImpl() for actual implementation
virtual void qsf::editor::base::Operation::redoImpl ( )
virtual

Redo the operation (common actions to always be executed)

Note
Must ensure to call it's parent's implementation.

Reimplemented in qsf::editor::base::SetComponentPropertyOperation, qsf::editor::base::CompoundOperation, qsf::editor::base::SetLayerPropertyOperation, qsf::editor::base::CreateEntityOperation, qsf::editor::base::PasteComponentDataOperation, qsf::editor::base::DestroyEntityOperation, qsf::editor::base::DestroyLayerOperation, qsf::editor::base::DestroyComponentOperation, qsf::editor::TerrainOperation, qsf::editor::SelectLayerOperation, qsf::editor::SelectEdgeOperation, qsf::editor::UnselectEdgeOperation, qsf::editor::SelectNodeOperation, qsf::editor::base::CreateComponentOperation, qsf::editor::base::TriggerMessageOperation, qsf::editor::AddEdgesToSelectionOperation, qsf::editor::RemoveEdgesFromSelectionOperation, qsf::editor::AddNodesToSelectionOperation, qsf::editor::RemoveNodesFromSelectionOperation, qsf::editor::base::CreateLayerOperation, qsf::editor::base::SetParentLayerOperation, qsf::editor::HideEntityOperation, qsf::editor::HideLayerOperation, qsf::editor::SetCurrentEntityOperation, qsf::editor::SequenceChangeSelectionOperation, qsf::editor::SequenceMovePlayheadOperation, qsf::editor::AddEntitiesToSelectionOperation, qsf::editor::LockEntityOperation, qsf::editor::RemoveEntitiesFromSelectionOperation, qsf::editor::SelectEntityOperation, qsf::editor::UnlockEntityOperation, qsf::editor::SequenceModifyTrackKeyValueOperation, qsf::editor::SequenceAddTrackKeyOperation, qsf::editor::SequenceRemoveTrackKeyOperation, qsf::editor::SequenceRemoveTrackOperation, qsf::editor::SequenceAddTrackOperation, and qsf::editor::SequenceAddDirectorTrackOperation.

void qsf::editor::base::Operation::seal ( )

Seal the operation after constructing it using the default constructor and explicitly using setters for all parameters.

Note
  • May be called multiple times and ensures to not change any property after seal has been placed
  • This method barely contains some boilerplate code see/override sealImpl() for actual implementation
virtual void qsf::editor::base::Operation::sealImpl ( )
virtual

Seal the operation after constructing it using the default constructor and explicitly using setters for all parameters.

Note
Must ensure to call it's parent's implementation. Will only be called once.

Reimplemented in qsf::editor::base::SetComponentPropertyOperation, qsf::editor::base::CompoundOperation, qsf::editor::base::SetLayerPropertyOperation, qsf::editor::base::CreateEntityOperation, qsf::editor::base::PasteComponentDataOperation, qsf::editor::base::DestroyEntityOperation, qsf::editor::base::DestroyLayerOperation, qsf::editor::base::DestroyComponentOperation, qsf::editor::TerrainOperation, qsf::editor::SelectLayerOperation, qsf::editor::base::DeselectEntityHiddenOperation, qsf::editor::base::SelectEntityHiddenOperation, qsf::editor::base::CreateLayerOperation, qsf::editor::base::SetParentLayerOperation, qsf::editor::HideEntityOperation, qsf::editor::HideLayerOperation, qsf::editor::base::AddEntitiesToSelectionOperation, qsf::editor::base::RemoveEntitiesFromSelectionOperation, qsf::editor::SetCurrentEntityOperation, qsf::editor::base::SelectEntityOperation, qsf::editor::SequenceChangeSelectionOperation, qsf::editor::SequenceMovePlayheadOperation, qsf::editor::SequenceModifyTrackKeyValueOperation, qsf::editor::SequenceAddTrackKeyOperation, qsf::editor::base::LockEntityOperation, qsf::editor::base::UnlockEntityOperation, qsf::editor::SequenceAddDirectorTrackOperation, qsf::editor::SequenceRemoveTrackKeyOperation, qsf::editor::SequenceRemoveTrackOperation, and qsf::editor::SequenceAddTrackOperation.

void qsf::editor::base::Operation::setText ( const std::string &  text)

Set the text of the operation.

Parameters
[in]textThe UTF-8 text of the operation, do not localize the text because there's no reason to put that much effort into something the normal user will not see
void qsf::editor::base::Operation::setUserId ( uint32  userId)

Set the ID of the user issuing the operation.

Parameters
[in]userIdThe ID of the user issuing the operation
void qsf::editor::base::Operation::undo ( )

Undo the operation.

Note
This method barely contains some boilerplate code see/override undoImpl() for actual implementation
virtual void qsf::editor::base::Operation::undoImpl ( )
virtual

Undo the operation (common actions to always be executed)

Note
Must ensure to call it's parent's implementation.

Reimplemented in qsf::editor::base::SetComponentPropertyOperation, qsf::editor::base::CompoundOperation, qsf::editor::base::SetLayerPropertyOperation, qsf::editor::base::CreateEntityOperation, qsf::editor::base::PasteComponentDataOperation, qsf::editor::base::DestroyEntityOperation, qsf::editor::base::DestroyLayerOperation, qsf::editor::base::DestroyComponentOperation, qsf::editor::TerrainOperation, qsf::editor::SelectLayerOperation, qsf::editor::SelectEdgeOperation, qsf::editor::UnselectEdgeOperation, qsf::editor::SelectNodeOperation, qsf::editor::base::CreateComponentOperation, qsf::editor::base::TriggerMessageOperation, qsf::editor::AddEdgesToSelectionOperation, qsf::editor::RemoveEdgesFromSelectionOperation, qsf::editor::AddNodesToSelectionOperation, qsf::editor::RemoveNodesFromSelectionOperation, qsf::editor::base::CreateLayerOperation, qsf::editor::base::SetParentLayerOperation, qsf::editor::HideEntityOperation, qsf::editor::HideLayerOperation, qsf::editor::SetCurrentEntityOperation, qsf::editor::SequenceChangeSelectionOperation, qsf::editor::SequenceMovePlayheadOperation, qsf::editor::AddEntitiesToSelectionOperation, qsf::editor::LockEntityOperation, qsf::editor::RemoveEntitiesFromSelectionOperation, qsf::editor::SelectEntityOperation, qsf::editor::UnlockEntityOperation, qsf::editor::SequenceModifyTrackKeyValueOperation, qsf::editor::SequenceAddTrackKeyOperation, qsf::editor::SequenceRemoveTrackKeyOperation, qsf::editor::SequenceRemoveTrackOperation, qsf::editor::SequenceAddTrackOperation, and qsf::editor::SequenceAddDirectorTrackOperation.

Friends And Related Function Documentation

friend class CompoundOperation
friend

Definition at line 73 of file Operation.h.

Member Data Documentation

CompoundOperation* qsf::editor::base::Operation::mParentOperation
protected

Parent compound operation, can be a null pointer, do not destroy the instance.

Definition at line 283 of file Operation.h.


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