Emergency 20 Dokumentation  4.2.0
CommandMarkerManager.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
14 
15 #include <qsf/job/JobProxy.h>
19 
20 #include <boost/noncopyable.hpp>
21 #include <boost/container/flat_set.hpp>
22 #include <boost/container/flat_map.hpp>
23 #include <boost/signals2.hpp>
24 
25 
26 //[-------------------------------------------------------]
27 //[ Forward declarations ]
28 //[-------------------------------------------------------]
29 namespace em5
30 {
31  class Command;
32 }
33 namespace qsf
34 {
35  class Map;
36  class Entity;
37  class CameraComponent;
38  class Clock;
39 }
40 
41 
42 //[-------------------------------------------------------]
43 //[ Namespace ]
44 //[-------------------------------------------------------]
45 namespace em5
46 {
47 
48 
49  //[-------------------------------------------------------]
50  //[ Classes ]
51  //[-------------------------------------------------------]
56  class EM5_API_EXPORT CommandMarkerManager : public boost::noncopyable
57  {
58 
59 
60  //[-------------------------------------------------------]
61  //[ Public methods ]
62  //[-------------------------------------------------------]
63  public:
69 
74  virtual ~CommandMarkerManager();
75 
76 
77  //[-------------------------------------------------------]
78  //[ Private definitions ]
79  //[-------------------------------------------------------]
80  private:
81  typedef boost::container::flat_set<uint64> VisibleEntityIdSet;
82 
83  struct TargetEntityData
84  {
85  Command* mCommand;
87  qsf::WeakPtr<CommandTargetComponent> mCommandTargetComponent;
88  qsf::Time mLastCheckTime;
89  bool mValid; // Only used temporarily
90 
91  TargetEntityData(uint64 key = 0) : mCommand(nullptr), mValid(false) {}
92  };
93 
94  // Use an element manager with paged allocator here:
95  // - We need a fast find by ID functionality -> some kind of std::map-like data structure
96  // - Copying elements is not too lightweight, so the elements should stay on stable location -> that's why no simple Boost flat_map is used
97  // - Elements get inserted and removed very often -> std::map or std::unordered_map would have to allocate/deallocate internal elements all the time
99 
100 
101  //[-------------------------------------------------------]
102  //[ Private methods ]
103  //[-------------------------------------------------------]
104  private:
105  void onEntitySelected(uint64 entityId);
106  void onEntityDeselected(uint64 entityId);
107 
108  void searchNewCommandTargetEntities(qsf::Map& map);
109  void checkPossibleTargets(qsf::Map& map, const qsf::Clock& clock);
110 
111  // Show and delete highlights and icons for target entities
112  void createHighlight(TargetEntityData& targetEntityData);
113  void deleteHighlight(TargetEntityData& targetEntityData);
114 
122  void onPreCompositorWorkspaceUpdateHighlight(const qsf::CameraComponent& cameraComponent);
123 
124  // Jobs
125  void updateSearchTargetJob(const qsf::JobArguments& jobArguments);
126 
127  bool getCameraPosition(glm::vec3& positionOut);
128 
129 
130  //[-------------------------------------------------------]
131  //[ Private data ]
132  //[-------------------------------------------------------]
133  private:
134  boost::signals2::connection mSelectSignalConnection;
135  boost::signals2::connection mDeselectSignalConnection;
136 
137  qsf::JobProxy mUpdateSearchTargetsJobProxy;
138  boost::signals2::connection mPreCompositorWorkspaceUpdateHighlightConnection;
139 
140  // Management of target entities (for commands)
141  TargetEntityMap mTargetEntityMap;
142 
143  // TODO(tl): At the moment just used to disable highlight, remove it later maybe
144  bool mUseHighlights;
145 
146 
147  };
148 
149 
150 //[-------------------------------------------------------]
151 //[ Namespace ]
152 //[-------------------------------------------------------]
153 } // em5
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Map class.
Definition: Map.h:93
Clock class.
Definition: Clock.h:33
#define EM5_API_EXPORT
Definition: Export.h:28
Camera component class.
Definition: CameraComponent.h:50
Abstract EMERGENCY 5 command base class.
Definition: Command.h:44
Element manager class template.
Definition: ElementManager.h:71
uint64_t uint64
Definition: PlatformTypes.h:184
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
Definition: PickupPersonByParamedicAction.h:21
EMERGENCY 5 command target marker manager class that cares for highlighting of possible targets...
Definition: CommandMarkerManager.h:56
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32