• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "ts_sdk_api.h"
16 namespace SysTuning {
17 namespace TraceStreamer {
18 extern "C" {
19 DemoRpcServer* rpcServer_;
20 bool g_isUseExternalModify = true;
SDK_SetTableName(const char * counterTableName,const char * counterObjectTableName,const char * sliceTableName,const char * sliceObjectName)21 int32_t SDK_SetTableName(const char* counterTableName,
22                          const char* counterObjectTableName,
23                          const char* sliceTableName,
24                          const char* sliceObjectName)
25 {
26     rpcServer_->demoTs_->sdkDataParser_->SetTableName(counterTableName, counterObjectTableName, sliceTableName,
27                                                       sliceObjectName);
28     if (g_isUseExternalModify) {
29         TS_LOGE("If you want to use the SDK_SetTableName, please modify g_isUseExternalModify to false.");
30     }
31     return 0;
32 }
33 
SDK_AppendCounterObject(int32_t counterId,const char * columnName)34 int32_t SDK_AppendCounterObject(int32_t counterId, const char* columnName)
35 {
36     return rpcServer_->demoTs_->sdkDataParser_->AppendCounterObject(counterId, columnName);
37 }
SDK_AppendCounter(int32_t counterId,uint64_t ts,int32_t value)38 int32_t SDK_AppendCounter(int32_t counterId, uint64_t ts, int32_t value)
39 {
40     return rpcServer_->demoTs_->sdkDataParser_->AppendCounter(counterId, ts, value);
41 }
SDK_AppendSliceObject(int32_t sliceId,const char * columnName)42 int32_t SDK_AppendSliceObject(int32_t sliceId, const char* columnName)
43 {
44     return rpcServer_->demoTs_->sdkDataParser_->AppendSliceObject(sliceId, columnName);
45 }
SDK_AppendSlice(int32_t sliceId,uint64_t ts,uint64_t endTs,int32_t value)46 int32_t SDK_AppendSlice(int32_t sliceId, uint64_t ts, uint64_t endTs, int32_t value)
47 {
48     return rpcServer_->demoTs_->sdkDataParser_->AppendSlice(sliceId, ts, endTs, value);
49 }
SetRpcServer(DemoRpcServer * rpcServer)50 void SetRpcServer(DemoRpcServer* rpcServer)
51 {
52     rpcServer_ = std::move(rpcServer);
53 }
54 }
55 } // namespace TraceStreamer
56 } // namespace SysTuning
57