Debian Codegraph @

plugins/dm.objectives/ObjectiveCondition.h

raw
1 #pragma once
2
3 #include <memory>
4 #include "Objective.h"
5
6 namespace objectives
7 {
8
9 /**
10 * greebo: An objective condition is providing a way to change
11 * a single objective in this mission based on the status of one
12 * in a previous mission.
13 */
14 class ObjectiveCondition
15 {
16 public:
17 // The index of the source mission (0-based)
18 int sourceMission;
19
20 // The index of the source objective (0-based)
21 int sourceObjective;
22
23 // Source objective state
24 Objective::State sourceState;
25
26 // The index of the target objective (0-based)
27 int targetObjective;
28
29 enum Type
30 {
31 CHANGE_STATE, // changes state of target objective
32 CHANGE_VISIBILITY, // changes visibility of target objective
33 CHANGE_MANDATORY, // changes mandatory flag of target objetive
34 INVALID_TYPE, // not a valid type
35 };
36
37 Type type;
38
39 // The value, can have different meanings depending on type (-1 == invalid)
40 int value;
41
42 // Default constructor, will construct an empty/invalid condition
43 ObjectiveCondition() :
44 sourceMission(-1),
45 sourceObjective(-1),
46 sourceState(Objective::NUM_STATES),
47 targetObjective(-1),
48 type(INVALID_TYPE),
49 value(-1)
50 {}
51
52 bool isValid() const
53 {
54 // Some checks to see whether this is an empty or invalid condition
55 return type != INVALID_TYPE && sourceMission != -1 && sourceState != Objective::NUM_STATES &&
56 sourceObjective != -1 && targetObjective != -1 && value != -1;
57 }
58 };
59 typedef std::shared_ptr<ObjectiveCondition> ObjectiveConditionPtr;
60
61 } // namespace