LCOV - code coverage report
Current view: top level - ipc/server/include - IIpcController.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2025-02-18 13:13:53 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2022 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #ifndef FIREBOLT_RIALTO_IPC_I_IPC_CONTROLLER_H_
      21              : #define FIREBOLT_RIALTO_IPC_I_IPC_CONTROLLER_H_
      22              : 
      23              : #include "IIpcServer.h"
      24              : #include <google/protobuf/service.h>
      25              : 
      26              : #include <map>
      27              : #include <memory>
      28              : #include <string>
      29              : 
      30              : namespace firebolt::rialto::ipc
      31              : {
      32              : /**
      33              :  * @brief Controller interface for the protobuf RPC service stubs.
      34              :  *
      35              :  * A pointer to this interface will be supplied as the first argument in every
      36              :  * RPC stub call.  It is an extensions of the google::protobuf::RpcController
      37              :  * interface and provides an additional method to get the client that made the
      38              :  * RPC call.
      39              :  */
      40              : class IController : public google::protobuf::RpcController
      41              : {
      42              : public:
      43          217 :     IController() = default;
      44          217 :     virtual ~IController() = default;
      45              : 
      46              :     IController(const IController &) = delete;
      47              :     IController &operator=(const IController &) = delete;
      48              :     IController(IController &&) = delete;
      49              :     IController &operator=(IController &&) = delete;
      50              : 
      51              : public:
      52              :     /**
      53              :      * Client-side methods
      54              :      * Calls can only be made from the client side. Calling these apis from server side
      55              :      * is undefined and could cause crashes.
      56              :      */
      57              : 
      58              :     /**
      59              :      * @brief Reset the RpcController.
      60              :      *
      61              :      * So that the RpcController can be reused for a new call, sets to the inital state.
      62              :      */
      63              :     void Reset() override = 0;
      64              : 
      65              :     /**
      66              :      * @brief Checks id the previosu call has failed.
      67              :      *
      68              :      * The reason for the failure depends on the implementaion of the RPC. Failed should only
      69              :      * be called after after the call has finished. If this call returns true, the response
      70              :      * structure returned from the failed call is undefined.
      71              :      *
      72              :      * @retval true if previous call failed.
      73              :      */
      74              :     bool Failed() const override = 0;
      75              : 
      76              :     /**
      77              :      * @brief Returns a description of the error if the previous call has failed.
      78              :      *
      79              :      * @retval error string.
      80              :      */
      81              :     std::string ErrorText() const override = 0;
      82              : 
      83              :     /**
      84              :      * @brief Starts the cancellation of a RPC call
      85              :      *
      86              :      * RPC may cancel the call immediatly, wait and cancel or not cancel at all. If a call is cancelled
      87              :      * failure will be set for the client and "done" will still be called.
      88              :      */
      89              :     void StartCancel() override = 0;
      90              : 
      91              :     /**
      92              :      * Server-side methods
      93              :      * Calls can only be made from the server side. Calling these apis from client side
      94              :      * is undefined and could cause crashes.
      95              :      */
      96              : 
      97              :     /**
      98              :      * @brief To be called during a method call. Returns a ptr to the client that made the call.
      99              :      *
     100              :      * @retval client that made the call.
     101              :      */
     102              :     virtual std::shared_ptr<IClient> getClient() const = 0;
     103              : 
     104              :     /**
     105              :      * @brief Causes failure to be returned to the client.
     106              :      *
     107              :      * Failed() shall return true. The failure reason can be fetched from the ErrorText().
     108              :      * To return machine-readable info on failure, use the method response structure rather than
     109              :      * SetFailed().
     110              :      *
     111              :      * @param[in] reason : The reason for the falure.
     112              :      */
     113              :     void SetFailed(const std::string &reason) override = 0;
     114              : 
     115              :     /**
     116              :      * @brief Not supported.
     117              :      *
     118              :      * @retval false.
     119              :      */
     120              :     bool IsCanceled() const override = 0;
     121              : 
     122              :     /**
     123              :      * @brief Not supported.
     124              :      *
     125              :      * @param[in] callback : Callback on closure.
     126              :      */
     127              :     void NotifyOnCancel(google::protobuf::Closure *callback) override = 0;
     128              : };
     129              : 
     130              : } // namespace firebolt::rialto::ipc
     131              : 
     132              : #endif // FIREBOLT_RIALTO_IPC_I_IPC_CONTROLLER_H_
        

Generated by: LCOV version 2.0-1