Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 : #include "adx_common_component.h"
11 : #include "adx_log.h"
12 : #include "extra_config.h"
13 : namespace Adx {
14 1 : int32_t AdxCommonComponent::Init()
15 : {
16 1 : IDE_CTRL_VALUE_WARN(init_ != nullptr, return IDE_DAEMON_ERROR, "common component %d null init",
17 : static_cast<int32_t>(componentType_));
18 1 : return init_();
19 : }
20 :
21 1 : const std::string AdxCommonComponent::GetInfo()
22 : {
23 2 : return "Common hdc server process";
24 : }
25 :
26 6 : ComponentType AdxCommonComponent::GetType()
27 : {
28 6 : return componentType_;
29 : }
30 :
31 1 : int32_t AdxCommonComponent::Process(const CommHandle &handle, const SharedPtr<MsgProto> &proto)
32 : {
33 1 : IDE_CTRL_VALUE_FAILED(process_ != nullptr, return IDE_DAEMON_ERROR, "common component %d process error",
34 : static_cast<int32_t>(componentType_));
35 1 : return process_(&handle, proto.get(), sizeof(MsgProto) + proto->sliceLen);
36 : }
37 :
38 1 : int32_t AdxCommonComponent::UnInit()
39 : {
40 1 : IDE_CTRL_VALUE_WARN(uninit_ != nullptr, return IDE_DAEMON_ERROR, "common component %d null uninit",
41 : static_cast<int32_t>(componentType_));
42 1 : return uninit_();
43 : }
44 :
45 1 : void AdxCommonComponent::SetType(ComponentType componentType)
46 : {
47 1 : componentType_ = componentType;
48 1 : }
49 :
50 15 : AdxCommonComponent::~AdxCommonComponent()
51 : {
52 10 : init_ = nullptr;
53 10 : process_ = nullptr;
54 10 : uninit_ = nullptr;
55 15 : }
56 : }
|