aboutsummaryrefslogtreecommitdiff
path: root/profiling/client/src/ProfilingStateMachine.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'profiling/client/src/ProfilingStateMachine.hpp')
-rw-r--r--profiling/client/src/ProfilingStateMachine.hpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/profiling/client/src/ProfilingStateMachine.hpp b/profiling/client/src/ProfilingStateMachine.hpp
new file mode 100644
index 0000000000..b507f1a50b
--- /dev/null
+++ b/profiling/client/src/ProfilingStateMachine.hpp
@@ -0,0 +1,67 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <client/include/ProfilingState.hpp>
+
+#include <common/include/IgnoreUnused.hpp>
+
+#include <atomic>
+
+namespace arm
+{
+
+namespace pipe
+{
+
+class ProfilingStateMachine
+{
+public:
+ ProfilingStateMachine() : m_State(ProfilingState::Uninitialised) {}
+ ProfilingStateMachine(ProfilingState state) : m_State(state) {}
+
+ ProfilingState GetCurrentState() const;
+ void TransitionToState(ProfilingState newState);
+ void Reset();
+
+ bool IsOneOfStates(ProfilingState state1)
+ {
+ arm::pipe::IgnoreUnused(state1);
+ return false;
+ }
+
+ template<typename T, typename... Args >
+ bool IsOneOfStates(T state1, T state2, Args... args)
+ {
+ if (state1 == state2)
+ {
+ return true;
+ }
+ else
+ {
+ return IsOneOfStates(state1, args...);
+ }
+ }
+
+private:
+ std::atomic<ProfilingState> m_State;
+};
+
+constexpr char const* GetProfilingStateName(ProfilingState state)
+{
+ switch (state)
+ {
+ case ProfilingState::Uninitialised: return "Uninitialised";
+ case ProfilingState::NotConnected: return "NotConnected";
+ case ProfilingState::WaitingForAck: return "WaitingForAck";
+ case ProfilingState::Active: return "Active";
+ default: return "Unknown";
+ }
+}
+
+} // namespace pipe
+
+} // namespace arm