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