Line data Source code
1 : /*
2 : * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved.
3 : * Description: ccu representation base header file
4 : * Create: 2025-02-18
5 : */
6 :
7 : #ifndef CCU_FUNC_CALL_H
8 : #define CCU_FUNC_CALL_H
9 :
10 : #include "ccu_rep_funccall_v1.h"
11 : #include "ccu_rep_context_v1.h"
12 :
13 : namespace hcomm {
14 :
15 : namespace CcuRep {
16 :
17 : class FuncCall {
18 : public:
19 : FuncCall(CcuRepContext *context, std::string label);
20 : FuncCall(CcuRepContext *context, const Variable &funcAddr);
21 :
22 : template <typename... Arguments> FuncCall &operator()(const Arguments &...args)
23 : {
24 : SetArgHelper(args...);
25 : AppendToContext();
26 : return *this;
27 : }
28 :
29 1 : FuncCall &operator()()
30 : {
31 1 : AppendToContext();
32 1 : return *this;
33 : }
34 :
35 : void AppendToContext();
36 :
37 : template <typename T> void SetInArg(T &&arg)
38 : {
39 : repFuncCall->SetInArg(std::forward<T>(arg));
40 : }
41 :
42 : template <typename T> void SetOutArg(T &&arg)
43 : {
44 : repFuncCall->SetOutArg(std::forward<T>(arg));
45 : }
46 :
47 : private:
48 : template <typename First> void SetArgHelper(const First &first)
49 : {
50 : repFuncCall->SetInArg(first);
51 : }
52 :
53 : template <typename First, typename... Rest> void SetArgHelper(const First &first, const Rest &...rest)
54 : {
55 : repFuncCall->SetInArg(first);
56 : SetArgHelper(rest...);
57 : }
58 :
59 : CcuRepContext *context{nullptr};
60 : std::string label;
61 :
62 : std::shared_ptr<CcuRepFuncCall> repFuncCall{nullptr};
63 : };
64 :
65 : }; // namespace CcuRep
66 : }; // namespace hcomm
67 : #endif // _CCU_FUNC_CALL_H
|