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 CCU_FUNC_CALL_H
12 : #define CCU_FUNC_CALL_H
13 :
14 : #include "ccu_rep_funccall_v1.h"
15 : #include "ccu_rep_context_v1.h"
16 :
17 : namespace hcomm {
18 :
19 : namespace CcuRep {
20 :
21 : class FuncCall {
22 : public:
23 : FuncCall(CcuRepContext* context, std::string label);
24 : FuncCall(CcuRepContext* context, const Variable& funcAddr);
25 :
26 : template <typename... Arguments>
27 : FuncCall& operator()(const Arguments&... args)
28 : {
29 : SetArgHelper(args...);
30 : AppendToContext();
31 : return *this;
32 : }
33 :
34 1 : FuncCall& operator()()
35 : {
36 1 : AppendToContext();
37 1 : return *this;
38 : }
39 :
40 : void AppendToContext();
41 :
42 : template <typename T>
43 : void SetInArg(T&& arg)
44 : {
45 : repFuncCall->SetInArg(std::forward<T>(arg));
46 : }
47 :
48 : template <typename T>
49 : void SetOutArg(T&& arg)
50 : {
51 : repFuncCall->SetOutArg(std::forward<T>(arg));
52 : }
53 :
54 : private:
55 : template <typename First>
56 : void SetArgHelper(const First& first)
57 : {
58 : repFuncCall->SetInArg(first);
59 : }
60 :
61 : template <typename First, typename... Rest>
62 : void SetArgHelper(const First& first, const Rest&... rest)
63 : {
64 : repFuncCall->SetInArg(first);
65 : SetArgHelper(rest...);
66 : }
67 :
68 : CcuRepContext* context{nullptr};
69 : std::string label;
70 :
71 : std::shared_ptr<CcuRepFuncCall> repFuncCall{nullptr};
72 : };
73 :
74 : }; // namespace CcuRep
75 : }; // namespace hcomm
76 : #endif // _CCU_FUNC_CALL_H
|