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 #ifndef HI_STATE_H 17 #define HI_STATE_H 18 19 #include <string> 20 #include <vector> 21 #include <map> 22 #include "fsm_message.h" 23 24 namespace OHOS { 25 class HiState { 26 public: 27 explicit HiState(std::string name); 28 virtual ~HiState(); 29 30 virtual void AddTransition(int32_t event, HiState &state); 31 32 virtual HiState *FindTransition(int32_t event); 33 34 virtual int32_t HandleMessage(const MsgInfo &msg) = 0; 35 36 virtual int32_t Enter(); 37 38 virtual int32_t Exit(); 39 40 std::string Name() const; 41 42 bool operator==(const HiState &state); 43 44 friend class HiStateMachine; 45 46 private: 47 std::map<int32_t, HiState *> m_transitionMap; 48 std::string m_name; 49 }; 50 }; 51 52 #endif // HI_STATE_H 53