Unravel Engine C++ Reference
Loading...
Searching...
No Matches
seq_inspector.cpp
Go to the documentation of this file.
1#include "seq_inspector.h"
2
3namespace seq
4{
5namespace inspector
6{
7void add_sequence_info(seq_action& action, const std::vector<seq_action>& actions)
8{
9#ifdef SEQ_INSPECTOR_ENABLE
10 seq_inspect_info::ptr info = std::make_shared<seq_inspect_info>();
11 info->id = action.get_id();
12 info->updater_type = "sequence";
13 info->modified_type = "action";
14
15 info->begin_value = "0";
16 info->current_value = "0";
17 info->end_value = to_str(actions.size());
18
19 info->duration = seq_private::get_duration(action);
20
21 for(const auto& act : actions)
22 {
23 if(act.info)
24 {
25 info->children.emplace_back(act.info);
26 }
27 }
28
29 action.info = std::move(info);
30#endif
31}
32
33void add_together_info(seq_action& action, const std::vector<seq_action>& actions)
34{
35#ifdef SEQ_INSPECTOR_ENABLE
36 seq_inspect_info::ptr info = std::make_shared<seq_inspect_info>();
37 info->id = action.get_id();
38 info->updater_type = "together";
39 info->modified_type = "action";
40
41 info->begin_value = "n/a";
42 info->current_value = "n/a";
43 info->end_value = "n/a";
44
45 info->duration = seq_private::get_duration(action);
46
47 for(const auto& act : actions)
48 {
49 if(act.info)
50 {
51 info->children.emplace_back(act.info);
52 }
53 }
54
55 action.info = std::move(info);
56#endif
57}
58
60{
61#ifdef SEQ_INSPECTOR_ENABLE
62 seq_inspect_info::ptr info = std::make_shared<seq_inspect_info>();
63 info->id = action.get_id();
64 info->updater_type = "delay";
65 info->modified_type = "n/a";
66
67 info->begin_value = "n/a";
68 info->current_value = "n/a";
69 info->end_value = "n/a";
70
71 info->duration = seq_private::get_duration(action);
72
73 action.info = std::move(info);
74#endif
75}
76
77void add_repeat_info(seq_action& repeat_action, const seq_action& action, size_t times)
78{
79#ifdef SEQ_INSPECTOR_ENABLE
80 seq_inspect_info::ptr info = std::make_shared<seq_inspect_info>();
81 info->id = repeat_action.get_id();
82 info->updater_type = "repeat";
83
84 if(times == 0)
85 {
86 info->begin_value = "infinity";
87 info->current_value = "infinity";
88 info->end_value = "infinity";
89 info->duration = 0ms;
90 }
91 else
92 {
93 info->begin_value = "0";
94 info->current_value = "0";
95 info->end_value = std::to_string(times);
96 info->duration = duration_t(seq_private::get_duration(repeat_action).count() * times);
97 }
98
99 if(action.info)
100 {
101 info->children.emplace_back(action.info);
102 }
103 repeat_action.info = std::move(info);
104#endif
105}
106
108{
109#ifdef SEQ_INSPECTOR_ENABLE
110 if(action.info)
111 {
112 action.info->state = to_str(state);
113 }
114#endif
115}
116
118{
119#ifdef SEQ_INSPECTOR_ENABLE
120 if(action.info)
121 {
122 update_action_status(action, 0);
123 action.info->current_value = "n/a";
124 }
125#endif
126}
127
128void add_location(seq_action& action, const hpp::source_location& location)
129{
130#ifdef SEQ_INSPECTOR_ENABLE
131 if(action.info)
132 {
133 action.info->file_name = location.file_name();
134 action.info->function_name = location.function_name();
135 action.info->line_number = location.line();
136 action.info->column_offset = location.column();
137 }
138#endif
139}
140
141} // end of namespace inspector
142} // namespace seq
Provides utilities for inspecting and converting sequence-related types to strings.
void add_repeat_info(seq_action &repeat_action, const seq_action &action, size_t times)
void add_together_info(seq_action &action, const std::vector< seq_action > &actions)
auto to_str(const T &t) -> std::string
Converts a value to a string using ADL (Argument-Dependent Lookup).
Definition seq_common.h:280
void update_action_state(seq_action &action, state_t state)
void add_location(seq_action &action, const hpp::source_location &location)
void add_sequence_info(seq_action &action, const std::vector< seq_action > &actions)
void update_action_status(seq_action &action)
void add_delay_info(seq_action &action)
Provides a sequence-based action management system for controlling and scheduling actions.
state_t
Represents the state of a sequence action.
Definition seq_common.h:81
std::chrono::nanoseconds duration_t
Represents a duration in nanoseconds.
Definition seq_common.h:41
Represents an action within the sequence management system. Contains lifecycle events and management ...
Definition seq_action.h:18
auto get_id() const -> seq_id_t
Gets the unique ID of the action.
seq_inspect_info::ptr info
Gets a pointer to the action's inspection information.
Definition seq_action.h:75
std::shared_ptr< seq_inspect_info > ptr
Shared pointer type.
Definition seq_common.h:142
static auto get_duration(const seq_action &self) -> duration_t
Gets the total duration of a given action.