LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/arithmetic - ccu_operator_v1.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 52.6 % 19 10
Test Date: 2026-07-28 12:11:00 Functions: 52.6 % 19 10

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
       3              :  * Description: ccu representation datatype define file
       4              :  * Author: sunzhepeng
       5              :  * Create: 2024-07-06
       6              :  */
       7              : 
       8              : #ifndef CCU_OPERATOR
       9              : #define CCU_OPERATOR
      10              : 
      11              : #include <stdexcept>
      12              : 
      13              : namespace hcomm {
      14              : namespace CcuRep {
      15              : 
      16              : template <typename lhsT, typename rhsT> class CcuOperator {
      17              : public:
      18           69 :     CcuOperator(lhsT lhs, rhsT rhs) : lhs(lhs), rhs(rhs)
      19              :     {
      20           69 :     }
      21              :     lhsT lhs;
      22              :     rhsT rhs;
      23              : };
      24              : 
      25              : enum class CcuArithmeticOperatorType { ADDITION, MULTIPLICATION, SUBTRACTION, INVALID };
      26              : 
      27              : template <typename lhsT, typename rhsT> class CcuArithmeticOperator : public CcuOperator<lhsT, rhsT> {
      28              : public:
      29           63 :     CcuArithmeticOperator(lhsT lhs, rhsT rhs, CcuArithmeticOperatorType type)
      30           63 :         : CcuOperator<lhsT, rhsT>(lhs, rhs), type(type)
      31              :     {
      32           63 :         Check();
      33           63 :     }
      34              :     void Check() const
      35              :     {
      36              :         // Hccl::THROW<Hccl::CcuApiException>("Invalid Arithmetic Operator");
      37              :         throw std::runtime_error("Invalid Arithmetic Operator");
      38              :     }
      39              : 
      40              :     CcuArithmeticOperatorType type{CcuArithmeticOperatorType::INVALID};
      41              : };
      42              : 
      43              : enum class CcuRelationalOperatorType { EQUAL, NOT_EQUAL, GREATER_THAN, GREATER_EQUAL, LESS_THAN, LESS_EQUAL, INVALID };
      44              : 
      45              : template <typename lhsT, typename rhsT> class CcuRelationalOperator : public CcuOperator<lhsT, rhsT> {
      46              : public:
      47            6 :     CcuRelationalOperator(lhsT lhs, rhsT rhs, CcuRelationalOperatorType type)
      48            6 :         : CcuOperator<lhsT, rhsT>(lhs, rhs), type(type)
      49              :     {
      50            6 :         Check();
      51            6 :     }
      52              :     void Check() const
      53              :     {
      54              :         // Hccl::THROW<Hccl::CcuApiException>("Invalid Relational Operator");
      55              :         throw std::runtime_error("Invalid Relational Operator");
      56              :     }
      57              : 
      58              :     CcuRelationalOperatorType type{CcuRelationalOperatorType::INVALID};
      59              : };
      60              : 
      61              : enum class CcuLogicOperatorType { AND, OR, XOR, NOT, INVALID };
      62              : 
      63              : template <typename lhsT, typename rhsT = std::nullptr_t> class CcuLogicOperator : public CcuOperator<lhsT, rhsT> {
      64              : public:
      65              :     template <typename U = rhsT, typename std::enable_if<!std::is_same<U, std::nullptr_t>::value, int>::type = 0>
      66            0 :     CcuLogicOperator(lhsT lhs, U rhs, CcuLogicOperatorType type) : CcuOperator<lhsT, U>(lhs, rhs), type(type)
      67              :     {
      68            0 :         Check();
      69            0 :     }
      70              : 
      71              :     template <typename U = rhsT, typename std::enable_if<std::is_same<U, std::nullptr_t>::value, int>::type = 0>
      72            0 :     CcuLogicOperator(lhsT lhs, CcuLogicOperatorType type) : CcuOperator<lhsT, U>(lhs, {}), type(type)
      73              :     {
      74            0 :         Check();
      75            0 :     }
      76              : 
      77              :     void Check() const
      78              :     {
      79              :         throw std::runtime_error("Invalid LogicOperator Operator");
      80              :     }
      81              : 
      82              :     CcuLogicOperatorType type{CcuLogicOperatorType::INVALID};
      83              : };
      84              : 
      85              : enum class CcuShiftType { LEFT, RIGHT, INVALID };
      86              : 
      87              : template <typename lhsT, typename rhsT> class CcuShiftOperator : public CcuOperator<lhsT, rhsT> {
      88              : public:
      89            0 :     CcuShiftOperator(lhsT lhs, rhsT rhs, CcuShiftType type) : CcuOperator<lhsT, rhsT>(lhs, rhs), type(type)
      90              :     {
      91            0 :         Check();
      92            0 :     }
      93              :     void Check() const
      94              :     {
      95              :         //THROW<CcuApiException>("Invalid ShiftT Operator");
      96              :         throw std::runtime_error("Invalid ShiftT Operator");
      97              :     }
      98              : 
      99              :     CcuShiftType type{CcuShiftType::INVALID};
     100              : };
     101              : 
     102              : }; // namespace CcuRep
     103              : }; // namespace hcomm
     104              : 
     105              : #endif // _CCU_OPERATOR
        

Generated by: LCOV version 2.0-1