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_LOOP_CALL_H
8 : #define CCU_LOOP_CALL_H
9 :
10 : #include "ccu_rep_loopcall_v1.h"
11 : #include "ccu_rep_context_v1.h"
12 :
13 : namespace hcomm {
14 : namespace CcuRep {
15 :
16 : class LoopCall {
17 : public:
18 : LoopCall(CcuRepContext* context, const std::string& label);
19 1 : const std::string& GetLabel() const { return label; }
20 :
21 : template <typename... Arguments>
22 : LoopCall& operator()(const Arguments&... args)
23 : {
24 : SetArgHelper(args...);
25 : AppendToContext();
26 : return *this;
27 : }
28 :
29 : LoopCall& operator()()
30 : {
31 : AppendToContext();
32 : return *this;
33 : }
34 :
35 : void AppendToContext();
36 :
37 : private:
38 : template <typename First>
39 : void SetArgHelper(const First& first)
40 : {
41 : repLoopCall->SetInArg(first);
42 : }
43 :
44 : template <typename First, typename... Rest>
45 : void SetArgHelper(const First& first, const Rest&... rest)
46 : {
47 : repLoopCall->SetInArg(first);
48 : SetArgHelper(rest...);
49 : }
50 :
51 : CcuRepContext* context{nullptr};
52 : std::string label;
53 :
54 : std::shared_ptr<CcuRepLoopCall> repLoopCall{nullptr};
55 : };
56 :
57 : }; // namespace CcuRep
58 : }; // namespace hcomm
59 : #endif // _CCU_LOOP_CALL_H
|