Debian Codegraph @

xbmc/guilib/GUIAction.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include <memory>
12 #include <string>
13 #include <vector>
14
15 class CGUIControl;
16 class CGUIListItem;
17
18 /**
19 * Class containing vector of condition->(action/navigation route) and handling its execution.
20 */
21 class CGUIAction
22 {
23 public:
24 /**
25 * Class which defines an executable action
26 */
27 class CExecutableAction
28 {
29 public:
30 /**
31 * Executable action constructor (without conditional execution)
32 * @param action - The action to be executed
33 */
34 explicit CExecutableAction(const std::string& action);
35 /**
36 * Executable action constructor (providing the condition and the action)
37 * @param condition - The condition that dictates the action execution
38 * @param action - The actual action
39 */
40 CExecutableAction(const std::string& condition, const std::string& action);
41
42 /**
43 * Get the condition of this executable action (may be empty)
44 * @return condition - The condition that dictates the action execution (or an empty string)
45 */
46 std::string GetCondition() const;
47
48 /**
49 * Checks if the executable action has any condition
50 * @return true if the executable action has any condition, else false
51 */
52 bool HasCondition() const;
53
54 /**
55 * Get the action string of this executable action
56 * @return action - The action string
57 */
58 std::string GetAction() const;
59
60 /**
61 * Sets/Replaces the action string of this executable action
62 * @param action - The action string
63 */
64 void SetAction(const std::string& action);
65
66 private:
67 /**
68 * Executable action default constructor
69 */
70 CExecutableAction() = delete;
71 /* The condition that dictates the action execution */
72 std::string m_condition;
73 /* The actual action */
74 std::string m_action;
75 };
76
77 CGUIAction() = default;
78 explicit CGUIAction(int controlID);
79 /**
80 * Execute actions without specifying any target control or parent control. Action will use the default focused control.
81 */
82 bool ExecuteActions() const;
83 /**
84 * Execute actions (no navigation paths); if action is paired with condition - evaluate condition first
85 */
86 bool ExecuteActions(int controlID,
87 int parentID,
88 const std::shared_ptr<CGUIListItem>& item = nullptr) const;
89 /**
90 * Check if there are any conditional actions
91 */
92 bool HasConditionalActions() const;
93 /**
94 * Check if there is any action that meet its condition
95 */
96 bool HasActionsMeetingCondition() const;
97 /**
98 * Check if there is any action
99 */
100 bool HasAnyActions() const;
101 /**
102 * Get the total number of actions
103 */
104 size_t GetActionCount() const;
105 /**
106 * Get navigation route that meet its conditions first
107 */
108 int GetNavigation() const;
109 /**
110 * Set navigation route
111 */
112 void SetNavigation(int id);
113 /**
114 * Configure CGUIAction to send threaded messages
115 */
116 void EnableSendThreadMessageMode();
117 /**
118 * Add an executable action to the CGUIAction container
119 */
120 void Append(const CExecutableAction& action);
121 /**
122 * Prune any executable actions stored in the CGUIAction
123 */
124 void Reset();
125
126 private:
127 std::vector<CExecutableAction> m_actions;
128 bool m_sendThreadMessages = false;
129 };