1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "hi_state.h"
17 
18 #include <cstdio>
19 
20 namespace OHOS {
HiState(std::string name)21 HiState::HiState(std::string name) : m_name(name)
22 {
23 }
24 
~HiState()25 HiState::~HiState()
26 {
27     m_transitionMap.clear();
28 }
29 
AddTransition(int32_t event,HiState & state)30 void HiState::AddTransition(int32_t event, HiState &state)
31 {
32     m_transitionMap.insert(std::pair<int32_t, HiState *>(event, &state));
33 }
34 
FindTransition(int32_t event)35 HiState *HiState::FindTransition(int32_t event)
36 {
37     std::map<int32_t, HiState *>::iterator it;
38 
39     it = m_transitionMap.find(event);
40     if (it == m_transitionMap.end()) {
41         return nullptr;
42     }
43 
44     return it->second;
45 }
46 
Name() const47 std::string HiState::Name() const
48 {
49     return m_name;
50 }
51 
operator ==(const HiState & state)52 bool HiState::operator==(const HiState &state)
53 {
54     if (m_name == state.Name()) {
55         return true;
56     } else {
57         return false;
58     }
59 }
60 
Enter()61 int32_t HiState::Enter()
62 {
63     return 0;
64 }
65 
Exit()66 int32_t HiState::Exit()
67 {
68     return 0;
69 }
70 };
71