1 /*
2  * Copyright (c) 2023 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 IAM_FINITE_STATE_MACHINE_BUILDER_H
17 #define IAM_FINITE_STATE_MACHINE_BUILDER_H
18 
19 #include <cstdint>
20 #include <memory>
21 #include <string>
22 
23 #include "nocopyable.h"
24 
25 #include "finite_state_machine_impl.h"
26 
27 namespace OHOS {
28 namespace UserIam {
29 namespace FaceAuth {
30 class FiniteStateMachineBuilder final : public FiniteStateMachine::Builder,
31                                         public std::enable_shared_from_this<FiniteStateMachineBuilder>,
32                                         public NoCopyable {
33 public:
34     FiniteStateMachineBuilder(std::string name, uint32_t initialState);
35     ~FiniteStateMachineBuilder() override;
36     std::shared_ptr<FiniteStateMachine::Builder> MakeTransition(uint32_t state, uint32_t event, uint32_t nextState,
37         const FiniteStateMachine::Action &action) override;
38     std::shared_ptr<FiniteStateMachine::Builder> MakeTransition(uint32_t state, uint32_t event,
39         uint32_t nextState) override;
40     std::shared_ptr<Builder> MakeOnStateEnter(uint32_t state, const FiniteStateMachine::Action &action) override;
41     std::shared_ptr<Builder> MakeOnStateLeave(uint32_t state, const FiniteStateMachine::Action &action) override;
42     std::shared_ptr<FiniteStateMachine> Build() override;
43 
44 private:
45     std::string name_;
46     uint32_t initstate_;
47     bool valid_;
48     FiniteStateMachineImpl::TransitionMap transitionMap_;
49     FiniteStateMachineImpl::EnterMap enterMap_;
50     FiniteStateMachineImpl::LeaveMap leaveMap_;
51 };
52 } // namespace FaceAuth
53 } // namespace UserIam
54 } // namespace OHOS
55 
56 #endif // IAM_FINITE_STATE_MACHINE_BUILDER_H