1b0e7dd80Sopenharmony_ci/*
2b0e7dd80Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3b0e7dd80Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4b0e7dd80Sopenharmony_ci * you may not use this file except in compliance with the License.
5b0e7dd80Sopenharmony_ci * You may obtain a copy of the License at
6b0e7dd80Sopenharmony_ci *
7b0e7dd80Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8b0e7dd80Sopenharmony_ci *
9b0e7dd80Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10b0e7dd80Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11b0e7dd80Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12b0e7dd80Sopenharmony_ci * See the License for the specific language governing permissions and
13b0e7dd80Sopenharmony_ci * limitations under the License.
14b0e7dd80Sopenharmony_ci */
15b0e7dd80Sopenharmony_ci
16b0e7dd80Sopenharmony_ci#include "hitracechain_impl.h"
17b0e7dd80Sopenharmony_ci#include <string>
18b0e7dd80Sopenharmony_ci
19b0e7dd80Sopenharmony_ciusing namespace OHOS::HiviewDFX;
20b0e7dd80Sopenharmony_ci
21b0e7dd80Sopenharmony_cinamespace OHOS {
22b0e7dd80Sopenharmony_cinamespace CJSystemapi {
23b0e7dd80Sopenharmony_ci
24b0e7dd80Sopenharmony_ciHiTraceId HiTraceChainImpl::Begin(const char* name, int flags)
25b0e7dd80Sopenharmony_ci{
26b0e7dd80Sopenharmony_ci    return HiTraceChain::Begin(std::string(name), flags);
27b0e7dd80Sopenharmony_ci}
28b0e7dd80Sopenharmony_ci
29b0e7dd80Sopenharmony_civoid HiTraceChainImpl::End(const HiTraceId& id)
30b0e7dd80Sopenharmony_ci{
31b0e7dd80Sopenharmony_ci    return HiTraceChain::End(id);
32b0e7dd80Sopenharmony_ci}
33b0e7dd80Sopenharmony_ci
34b0e7dd80Sopenharmony_ciHiTraceId HiTraceChainImpl::GetId()
35b0e7dd80Sopenharmony_ci{
36b0e7dd80Sopenharmony_ci    return HiTraceChain::GetId();
37b0e7dd80Sopenharmony_ci}
38b0e7dd80Sopenharmony_ci
39b0e7dd80Sopenharmony_civoid HiTraceChainImpl::SetId(const HiTraceId& id)
40b0e7dd80Sopenharmony_ci{
41b0e7dd80Sopenharmony_ci    return HiTraceChain::SetId(id);
42b0e7dd80Sopenharmony_ci}
43b0e7dd80Sopenharmony_ci
44b0e7dd80Sopenharmony_civoid HiTraceChainImpl::ClearId()
45b0e7dd80Sopenharmony_ci{
46b0e7dd80Sopenharmony_ci    return HiTraceChain::ClearId();
47b0e7dd80Sopenharmony_ci}
48b0e7dd80Sopenharmony_ci
49b0e7dd80Sopenharmony_ciHiTraceId HiTraceChainImpl::CreateSpan()
50b0e7dd80Sopenharmony_ci{
51b0e7dd80Sopenharmony_ci    return HiTraceChain::CreateSpan();
52b0e7dd80Sopenharmony_ci}
53b0e7dd80Sopenharmony_ci
54b0e7dd80Sopenharmony_civoid HiTraceChainImpl::Tracepoint(uint32_t mode, uint32_t type, HiTraceId id, const char* fmt)
55b0e7dd80Sopenharmony_ci{
56b0e7dd80Sopenharmony_ci    HiTraceCommunicationMode communicationMode = HiTraceCommunicationMode(mode);
57b0e7dd80Sopenharmony_ci    HiTraceTracepointType tracePointType = HiTraceTracepointType(type);
58b0e7dd80Sopenharmony_ci    return HiTraceChain::Tracepoint(communicationMode, tracePointType, id, "%s", fmt);
59b0e7dd80Sopenharmony_ci}
60b0e7dd80Sopenharmony_ci
61b0e7dd80Sopenharmony_cibool HiTraceChainImpl::IsValid(const HiTraceId& id)
62b0e7dd80Sopenharmony_ci{
63b0e7dd80Sopenharmony_ci    return id.IsValid();
64b0e7dd80Sopenharmony_ci}
65b0e7dd80Sopenharmony_ci
66b0e7dd80Sopenharmony_cibool HiTraceChainImpl::IsFlagEnabled(const HiTraceId& traceId, int32_t flag)
67b0e7dd80Sopenharmony_ci{
68b0e7dd80Sopenharmony_ci    HiTraceFlag traceFlag = HiTraceFlag(flag);
69b0e7dd80Sopenharmony_ci    bool isFalgEnabled = traceId.IsFlagEnabled(traceFlag);
70b0e7dd80Sopenharmony_ci    return isFalgEnabled;
71b0e7dd80Sopenharmony_ci}
72b0e7dd80Sopenharmony_ci
73b0e7dd80Sopenharmony_civoid HiTraceChainImpl::EnableFlag(HiTraceId& traceId, int32_t flag)
74b0e7dd80Sopenharmony_ci{
75b0e7dd80Sopenharmony_ci    HiTraceFlag traceFlag = HiTraceFlag(flag);
76b0e7dd80Sopenharmony_ci    traceId.EnableFlag(traceFlag);
77b0e7dd80Sopenharmony_ci}
78b0e7dd80Sopenharmony_ci
79b0e7dd80Sopenharmony_ci} // CJSystemapi
80b0e7dd80Sopenharmony_ci} // OHOS
81b0e7dd80Sopenharmony_ci
82