Cafu Engine
ToolManager.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_TOOL_MANAGER_HPP_INCLUDED
8 #define CAFU_TOOL_MANAGER_HPP_INCLUDED
9 
10 #include "ObserverPatternTools.hpp"
11 #include "Templates/Array.hpp"
12 
13 
14 class MapDocumentT;
15 class ToolT;
16 class wxWindow;
17 namespace cf { namespace TypeSys { class TypeInfoT; } }
18 
19 
21 {
22  public:
23 
24  /// The constructor.
25  ToolManagerT(MapDocumentT& MapDoc, wxWindow* ParentToolOptions);
26 
27  /// The destructor.
28  ~ToolManagerT();
29 
30 
31  /// Returns the array of all tools registered with and known to the tool manager.
32  const ArrayT<ToolT*>& GetTools() const { return m_Tools; }
33 
34  /// Returns the tool instance matching the given type.
35  /// NULL is returned when Type is not a type of a valid tool.
36  ToolT* GetTool(const cf::TypeSys::TypeInfoT& Type);
37 
38  /// Returns the currently active tool.
39  ToolT* GetActiveTool() const { return m_ActiveTool; }
40 
41  /// Returns the type of the currently active tool.
42  /// This method is just a convenience method that saves the caller the explicit check for NULL when calling GetActiveTool().
44 
45  /// Sets the tool of the given type as the currently active tool.
46  void SetActiveTool(const cf::TypeSys::TypeInfoT* Type);
47 
48 
49  private:
50 
51  ToolManagerT(const ToolManagerT&); ///< Use of the Copy Constructor is not allowed.
52  void operator = (const ToolManagerT&); ///< Use of the Assignment Operator is not allowed.
53 
54 
55  MapDocumentT& m_MapDoc; ///< The MapDocumentT whose tool manager we are.
56  ArrayT<ToolT*> m_Tools; ///< The list of all tools available for editing the map document.
57  ToolT* m_ActiveTool; ///< One of the tools in m_Tools, this is the currently active one. NULL when no tool is currently active.
58 };
59 
60 #endif
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
~ToolManagerT()
The destructor.
Definition: ToolManager.cpp:34
ToolManagerT(MapDocumentT &MapDoc, wxWindow *ParentToolOptions)
The constructor.
Definition: ToolManager.cpp:11
void SetActiveTool(const cf::TypeSys::TypeInfoT *Type)
Sets the tool of the given type as the currently active tool.
Definition: ToolManager.cpp:58
const cf::TypeSys::TypeInfoT * GetActiveToolType() const
Returns the type of the currently active tool.
Definition: ToolManager.cpp:52
ToolT * GetActiveTool() const
Returns the currently active tool.
Definition: ToolManager.hpp:39
ToolT * GetTool(const cf::TypeSys::TypeInfoT &Type)
Returns the tool instance matching the given type.
Definition: ToolManager.cpp:41
const ArrayT< ToolT * > & GetTools() const
Returns the array of all tools registered with and known to the tool manager.
Definition: ToolManager.hpp:32
This file provides the classes for the Observer pattern as described in the book by the GoF...
Definition: ToolManager.hpp:20
This is the base class for all tools in the map editor.
Definition: Tool.hpp:34
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79
Definition: ObserverPatternTools.hpp:49