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

            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_IPC_SERVER_CONTROLLER_IMPL_H_
      21              : #define FIREBOLT_RIALTO_IPC_IPC_SERVER_CONTROLLER_IMPL_H_
      22              : 
      23              : #include "IIpcController.h"
      24              : #include "IpcClientImpl.h"
      25              : #include <memory>
      26              : #include <string>
      27              : 
      28              : namespace firebolt::rialto::ipc
      29              : {
      30              : /**
      31              :  * @brief Implementation of the RialtoIpcServerController interface, a pointer to an
      32              :  * object of this type is supplied in each RPC call handler.
      33              :  *
      34              :  * This object is inherited from RialtoIpcServerController interface which in turn
      35              :  * is inherited from google::protobuf::RpcController, and therefore meets the
      36              :  * requirements of the protobuf RPC service handler.
      37              :  *
      38              :  * It implements the google::protobuf::RpcController::SetFailed(...) method
      39              :  * which allows the server to return a failure on an RPC call.
      40              :  *
      41              :  * It also implements the RialtoIpcController::getClient(...) method which
      42              :  * allows for returning a pointer to the RialtoIpc client that made the request.
      43              :  * This is an extension to the google::protobuf::RpcController interface.
      44              :  * If clients need this API then they are expected to perform a dynamic_cast
      45              :  * on the controller pointer to a RialtoIpcController pointer.
      46              :  */
      47              : class ServerControllerImpl final : public IController
      48              : {
      49              : public:
      50           30 :     ~ServerControllerImpl() final = default;
      51              : 
      52              : public:
      53              :     /**
      54              :      * Ignore Client-side methods
      55              :      */
      56              :     void Reset() final {}
      57            0 :     bool Failed() const final { return false; }
      58            0 :     std::string ErrorText() const final { return std::string(); }
      59              :     void StartCancel() final {}
      60              : 
      61              : public:
      62              :     /**
      63              :      * Server-side methods
      64              :      */
      65              :     void SetFailed(const std::string &reason) final;
      66              :     bool IsCanceled() const final;
      67              :     void NotifyOnCancel(google::protobuf::Closure *callback) final;
      68              :     std::shared_ptr<IClient> getClient() const final;
      69              : 
      70              : protected:
      71              :     friend class ServerImpl;
      72              :     ServerControllerImpl(std::shared_ptr<ClientImpl> client, uint64_t serialId);
      73              : 
      74              :     const std::shared_ptr<ClientImpl> m_kClient;
      75              :     const uint64_t m_serialId{};
      76              :     const uint64_t m_kSerialId;
      77              : 
      78              :     bool m_failed = false;
      79              :     std::string m_failureReason;
      80              : };
      81              : 
      82              : } // namespace firebolt::rialto::ipc
      83              : 
      84              : #endif // FIREBOLT_RIALTO_IPC_IPC_SERVER_CONTROLLER_IMPL_H_
        

Generated by: LCOV version 2.0-1