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 :
11 : #ifndef ADX_LOG_H
12 : #define ADX_LOG_H
13 : #include <memory>
14 : #include "hdc_log.h"
15 :
16 : #define IDE_CTRL_VALUE_FAILED(err, action, logText, ...) \
17 : do { \
18 : if (!(err)) { \
19 : IDE_LOGE(logText, ##__VA_ARGS__); \
20 : action; \
21 : } \
22 : } while (0)
23 :
24 : #define IDE_CTRL_VALUE_FAILED_NODO(err, action, logText, ...) \
25 : if (!(err)) { \
26 : IDE_LOGE(logText, ##__VA_ARGS__); \
27 : action; \
28 : }
29 :
30 : #define IDE_CTRL_VALUE_WARN(err, action, logText, ...) \
31 : do { \
32 : if (!(err)) { \
33 : IDE_LOGW(logText, ##__VA_ARGS__); \
34 : action; \
35 : } \
36 : } while (0)
37 :
38 : #define IDE_CTRL_VALUE_WARN_NODO(err, action, logText, ...) \
39 : if (!(err)) { \
40 : IDE_LOGW(logText, ##__VA_ARGS__); \
41 : action; \
42 : }
43 :
44 : template <typename T, typename... Args>
45 0 : std::shared_ptr<T> MakeSharedInstance(Args&&... args)
46 : {
47 : try {
48 0 : std::shared_ptr<T> instance = std::make_shared<T>(std::forward<Args>(args)...);
49 0 : return instance;
50 0 : } catch (std::exception& ex) {
51 0 : IDE_LOGE("Make shared failed, message: %s", ex.what());
52 0 : return nullptr;
53 : }
54 : }
55 :
56 : #ifndef UNUSED
57 : #define UNUSED(x) \
58 : do { \
59 : (void)(x); \
60 : } while (0)
61 : #endif
62 : #endif
|