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(
17 : init_ != nullptr, return IDE_DAEMON_ERROR, "common component %d null init",
18 : static_cast<int32_t>(componentType_));
19 1 : return init_();
20 : }
21 :
22 3 : const std::string AdxCommonComponent::GetInfo() { return "Common hdc server process"; }
23 :
24 4 : ComponentType AdxCommonComponent::GetType() { return componentType_; }
25 :
26 1 : int32_t AdxCommonComponent::Process(const CommHandle& handle, const SharedPtr<MsgProto>& proto)
27 : {
28 1 : IDE_CTRL_VALUE_FAILED(
29 : process_ != nullptr, return IDE_DAEMON_ERROR, "common component %d process error",
30 : static_cast<int32_t>(componentType_));
31 1 : return process_(&handle, proto.get(), sizeof(MsgProto) + proto->sliceLen);
32 : }
33 :
34 1 : int32_t AdxCommonComponent::UnInit()
35 : {
36 1 : IDE_CTRL_VALUE_WARN(
37 : uninit_ != nullptr, return IDE_DAEMON_ERROR, "common component %d null uninit",
38 : static_cast<int32_t>(componentType_));
39 1 : return uninit_();
40 : }
41 :
42 1 : void AdxCommonComponent::SetType(ComponentType componentType) { componentType_ = componentType; }
43 :
44 15 : AdxCommonComponent::~AdxCommonComponent()
45 : {
46 10 : init_ = nullptr;
47 10 : process_ = nullptr;
48 10 : uninit_ = nullptr;
49 15 : }
50 : } // namespace Adx
|