1 /*
2  * Copyright (c) 2024 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 SCHEDULE_HOLDER_CONTEXT_H
17 #define SCHEDULE_HOLDER_CONTEXT_H
18 
19 #include <cstdint>
20 #include <memory>
21 
22 #include "nocopyable.h"
23 
24 #include "authentication_impl.h"
25 #include "base_context.h"
26 
27 namespace OHOS {
28 namespace UserIam {
29 namespace UserAuth {
30 class ScheduleHolderContext : public Context,
31                               public std::enable_shared_from_this<ScheduleHolderContext>,
32                               public NoCopyable {
33 public:
34     ScheduleHolderContext(uint64_t contextId, std::shared_ptr<ScheduleNode> scheduleNode);
35     ~ScheduleHolderContext() override = default;
36 
37     bool Start() override;
38     bool Stop() override;
39     uint64_t GetContextId() const override;
40     ContextType GetContextType() const override;
41     std::shared_ptr<ScheduleNode> GetScheduleNode(uint64_t scheduleId) const override;
42     uint32_t GetTokenId() const override;
43     int32_t GetLatestError() const override;
44     int32_t GetUserId() const override;
45 
46 protected:
47     void SetLatestError(int32_t error) override;
48 
49 private:
50     uint64_t contextId_ = INVALID_CONTEXT_ID;
51     std::shared_ptr<ScheduleNode> scheduleNode_ = nullptr;
52 };
53 } // namespace UserAuth
54 } // namespace UserIam
55 } // namespace OHOS
56 #endif // SCHEDULE_HOLDER_CONTEXT_H