LCOV - code coverage report
Current view: top level - app/MessageDef - InvokeRequestMessage.h (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 1 1 100.0 %
Date: 2024-02-15 08:20:41 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /**
       2             :  *
       3             :  *    Copyright (c) 2021 Project CHIP Authors
       4             :  *
       5             :  *    Licensed under the Apache License, Version 2.0 (the "License");
       6             :  *    you may not use this file except in compliance with the License.
       7             :  *    You may obtain a copy of the License at
       8             :  *
       9             :  *        http://www.apache.org/licenses/LICENSE-2.0
      10             :  *
      11             :  *    Unless required by applicable law or agreed to in writing, software
      12             :  *    distributed under the License is distributed on an "AS IS" BASIS,
      13             :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14             :  *    See the License for the specific language governing permissions and
      15             :  *    limitations under the License.
      16             :  */
      17             : 
      18             : #pragma once
      19             : 
      20             : #include <app/AppConfig.h>
      21             : #include <app/util/basic-types.h>
      22             : #include <lib/core/CHIPCore.h>
      23             : #include <lib/core/TLV.h>
      24             : #include <lib/support/CodeUtils.h>
      25             : #include <lib/support/logging/CHIPLogging.h>
      26             : 
      27             : #include "InvokeRequests.h"
      28             : #include "MessageBuilder.h"
      29             : #include "MessageParser.h"
      30             : 
      31             : namespace chip {
      32             : namespace app {
      33             : namespace InvokeRequestMessage {
      34             : enum class Tag : uint8_t
      35             : {
      36             :     kSuppressResponse = 0,
      37             :     kTimedRequest     = 1,
      38             :     kInvokeRequests   = 2,
      39             : };
      40             : 
      41             : class Parser : public MessageParser
      42             : {
      43             : public:
      44             : #if CHIP_CONFIG_IM_PRETTY_PRINT
      45             :     CHIP_ERROR PrettyPrint() const;
      46             : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      47             : 
      48             :     /**
      49             :      *  @brief Get SuppressResponse. Next() must be called before accessing them.
      50             :      *
      51             :      *  @return #CHIP_NO_ERROR on success
      52             :      *          #CHIP_END_OF_TLV if there is no such element
      53             :      */
      54             :     CHIP_ERROR GetSuppressResponse(bool * const apSuppressResponse) const;
      55             : 
      56             :     /**
      57             :      *  @brief Get TimedRequest. Next() must be called before accessing them.
      58             :      *
      59             :      *  @return #CHIP_NO_ERROR on success
      60             :      *          #CHIP_END_OF_TLV if there is no such element
      61             :      */
      62             :     CHIP_ERROR GetTimedRequest(bool * const apTimedRequest) const;
      63             : 
      64             :     /**
      65             :      *  @brief Get a parser for an InvokeRequests.
      66             :      *
      67             :      *  @param [in] apInvokeRequests    A pointer to the invoke request list parser.
      68             :      *
      69             :      *  @return #CHIP_NO_ERROR on success
      70             :      *          #CHIP_END_OF_TLV if there is no such element
      71             :      */
      72             :     CHIP_ERROR GetInvokeRequests(InvokeRequests::Parser * const apInvokeRequests) const;
      73             : };
      74             : 
      75             : class Builder : public MessageBuilder
      76             : {
      77             : public:
      78             :     /**
      79             :      *  @brief Performs underlying StructBuilder::Init, but reserves memory need in
      80             :      *  EndOfInvokeRequestMessage() with underlying TLVWriter.
      81             :      */
      82             :     CHIP_ERROR InitWithEndBufferReserved(TLV::TLVWriter * const apWriter);
      83             : 
      84             :     /**
      85             :      *  @brief when sets to true, it means do not send a response to this action
      86             :      */
      87             :     InvokeRequestMessage::Builder & SuppressResponse(const bool aSuppressResponse);
      88             : 
      89             :     /**
      90             :      *  @brief This is flag to indication if ths action is part of a timed invoke transaction
      91             :      */
      92             :     InvokeRequestMessage::Builder & TimedRequest(const bool aTimedRequest);
      93             : 
      94             :     /**
      95             :      *  @brief Initialize a InvokeRequests::Builder for writing into the TLV stream
      96             :      *
      97             :      *  @return A reference to InvokeRequests::Builder
      98             :      */
      99             :     InvokeRequests::Builder & CreateInvokeRequests(const bool aReserveEndBuffer = false);
     100             : 
     101             :     /**
     102             :      *  @brief Get reference to InvokeRequests::Builder
     103             :      *
     104             :      *  @return A reference to InvokeRequests::Builder
     105             :      */
     106          60 :     InvokeRequests::Builder & GetInvokeRequests() { return mInvokeRequests; }
     107             : 
     108             :     /**
     109             :      *  @brief Mark the end of this InvokeRequestMessage
     110             :      *
     111             :      *  @return The builder's final status.
     112             :      */
     113             :     CHIP_ERROR EndOfInvokeRequestMessage();
     114             : 
     115             :     /**
     116             :      *  @brief Get number of bytes required in the buffer by EndOfInvokeRequestMessage()
     117             :      *
     118             :      *  @return Expected number of bytes required in the buffer by EndOfInvokeRequestMessage()
     119             :      */
     120             :     uint32_t GetSizeToEndInvokeRequestMessage();
     121             : 
     122             : private:
     123             :     InvokeRequests::Builder mInvokeRequests;
     124             :     bool mIsEndBufferReserved = false;
     125             : };
     126             : } // namespace InvokeRequestMessage
     127             : } // namespace app
     128             : } // namespace chip

Generated by: LCOV version 1.14