aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/ProfilingStateMachine.hpp
blob: 66f8b2cd17c6547a6552527859c0746764a0fcd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once

#include <atomic>

namespace armnn
{

namespace  profiling
{

enum class ProfilingState
{
    Uninitialised,
    NotConnected,
    WaitingForAck,
    Active
};

class ProfilingStateMachine
{
public:
    ProfilingStateMachine(): m_State(ProfilingState::Uninitialised) {};
    ProfilingStateMachine(ProfilingState state): m_State(state) {};

    ProfilingState GetCurrentState() const;
    void TransitionToState(ProfilingState newState);

    bool IsOneOfStates(ProfilingState 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 profiling

} //namespace armnn