Emergency 20 Dokumentation  4.2.0
ObjectiveList.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 <boost/container/flat_map.hpp>
16 
17 
18 //[-------------------------------------------------------]
19 //[ Namespace ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23 
24 
25  //[-------------------------------------------------------]
26  //[ Classes ]
27  //[-------------------------------------------------------]
32  class EM5_API_EXPORT ObjectiveList : public boost::noncopyable
33  {
34 
35 
36  //[-------------------------------------------------------]
37  //[ Public definitions ]
38  //[-------------------------------------------------------]
39  public:
40  typedef boost::container::flat_map<uint32, Objective*> ObjectiveInstanceMap;
41  typedef std::pair<uint32, Objective*> ObjectiveInstancePair;
42 
43  typedef boost::container::flat_map<uint32, uint32> ObjectiveOrderPriorityMap;
44 
45 
46  //[-------------------------------------------------------]
47  //[ Public methods ]
48  //[-------------------------------------------------------]
49  public:
54  ObjectiveList();
55 
60  virtual ~ObjectiveList();
61 
62  const ObjectiveInstanceMap& getObjectives() const;
63  void getObjectivesSorted(std::vector<Objective*>& outObjectives) const;
64 
65  void clearObjectives();
66  void insertObjective(Objective& objective);
67 
68  Objective* getObjectiveByTypeId(uint32 typeId);
69  const Objective* getObjectiveByTypeId(uint32 typeId) const;
70 
71  Objective& getOrCreateObjective(uint32 typeId, Objective::ObjectiveType type, uint32 eventId, uint32 orderPriority = 100);
72 
73  void removeObjective(uint32 typeId);
74 
75  void defineObjectiveOrderPriority(uint32 typeId, uint32 orderPriority);
76  void defineObjectiveOrderPriorities(const std::vector<uint32>& typeIds, uint32 orderPriorityStart = 10, uint32 orderPriorityStep = 10);
77 
78  void swapWith(ObjectiveList& otherList);
79 
80  uint32 countObjectivesOfType(Objective::ObjectiveType type) const;
81 
82  bool checkSuccess() const;
83  bool checkFailure() const;
84 
85  void debugLogFailure() const;
86 
87  //[-------------------------------------------------------]
88  //[ Serialization ]
89  //[-------------------------------------------------------]
90  void serialize(qsf::BinarySerializer& serializer);
91 
92 
93  //[-------------------------------------------------------]
94  //[ Private methods ]
95  //[-------------------------------------------------------]
96  private:
97  void countObjectivesOfType(Objective::ObjectiveType type, uint32& number, uint32& accomplished) const;
98 
99 
100  //[-------------------------------------------------------]
101  //[ Private data ]
102  //[-------------------------------------------------------]
103  private:
104  ObjectiveInstanceMap mObjectives;
105  ObjectiveOrderPriorityMap mOrderPriorityMap;
106 
107 
108  };
109 
110 
111 //[-------------------------------------------------------]
112 //[ Namespace ]
113 //[-------------------------------------------------------]
114 } // em5
Definition: ActionPriority.h:13
unsigned int uint32
Definition: PlatformTypes.h:181
boost::container::flat_map< uint32, Objective * > ObjectiveInstanceMap
Definition: ObjectiveList.h:40
#define EM5_API_EXPORT
Definition: Export.h:28
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
EMERGENCY 5 objective class.
Definition: Objective.h:51
ObjectiveType
Definition: Objective.h:70
boost::container::flat_map< uint32, uint32 > ObjectiveOrderPriorityMap
Definition: ObjectiveList.h:43
EMERGENCY 5 objective list class.
Definition: ObjectiveList.h:32
std::pair< uint32, Objective * > ObjectiveInstancePair
Definition: ObjectiveList.h:41
Binary serializer class.
Definition: BinarySerializer.h:35