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