Cafu Engine
Delete.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_COMMAND_DELETE_HPP_INCLUDED
8 #define CAFU_COMMAND_DELETE_HPP_INCLUDED
9 
10 #include "../../CommandPattern.hpp"
11 #include "Templates/Pointer.hpp"
12 
13 
14 namespace cf { namespace GameSys { class EntityT; } }
15 namespace MapEditor { class CompMapEntityT; }
16 class MapDocumentT;
17 class MapElementT;
18 class MapPrimitiveT;
19 class CommandSelectT;
20 
21 
22 class CommandDeleteT : public CommandT
23 {
24  public:
25 
26  /// Constructor to delete an individual object.
27  CommandDeleteT(MapDocumentT& MapDoc, MapElementT* DeleteElem);
28 
29  /// Constructor to delete an array of objects.
30  CommandDeleteT(MapDocumentT& MapDoc, const ArrayT<MapElementT*>& DeleteElems);
31 
32  /// Destructor.
34 
35  // Implementation of the CommandT interface.
36  bool Do();
37  void Undo();
38  wxString GetName() const;
39 
40 
41  private:
42 
43  void Init(const ArrayT<MapElementT*>& DeleteElems);
44 
45  MapDocumentT& m_MapDoc;
46  ArrayT< IntrusivePtrT<cf::GameSys::EntityT> > m_Entities; ///< The entities to delete.
47  ArrayT< IntrusivePtrT<cf::GameSys::EntityT> > m_EntityParents; ///< The parents of the above entities.
48  ArrayT<unsigned long> m_EntityIndices; ///< The indices of the entities in their respective parent.
49  ArrayT<MapPrimitiveT*> m_DeletePrims; ///< The primitives to delete.
50  ArrayT< IntrusivePtrT<MapEditor::CompMapEntityT> > m_DeletePrimsParents; ///< The parents of the above primitives (the world or any custom entity).
51  CommandSelectT* m_CommandSelect; ///< The command that unselects all elements before they are deleted.
52 };
53 
54 #endif
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
CommandDeleteT(MapDocumentT &MapDoc, MapElementT *DeleteElem)
Constructor to delete an individual object.
Definition: Delete.cpp:19
This class adds no functionality of its own, but only exists for proper type separation.
Definition: MapPrimitive.hpp:21
~CommandDeleteT()
Destructor.
Definition: Delete.cpp:139
bool Do()
This method executes the command.
Definition: Delete.cpp:154
Definition: Select.hpp:18
void Undo()
This method un-does the command.
Definition: Delete.cpp:196
Definition: Delete.hpp:22
wxString GetName() const
Returns the name (a description) of the command.
Definition: Delete.cpp:224
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
This is the base class for all elements ("objects") that can exist in a map.
Definition: MapElement.hpp:57