Line data Source code
1 : /* File: mock_remote_endpoints_manager.h 2 : * This file is part of the program hardiocore 3 : * Program description : Abstract low level I/O removing direct hardware 4 : * implementation Copyright (C) 2018-2020 - Robin Passama (CNRS / LIRMM) 5 : * Clement Rebut (EPITA / LIRMM) Charles Villard (EPITA / LIRMM). All Right 6 : * reserved. 7 : * 8 : * This software is free software: you can redistribute it and/or modify 9 : * it under the terms of the CeCILL-C license as published by 10 : * the CEA CNRS INRIA, either version 1 11 : * of the License, or (at your option) any later version. 12 : * This software is distributed in the hope that it will be useful, 13 : * but WITHOUT ANY WARRANTY without even the implied warranty of 14 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 : * CeCILL-C License for more details. 16 : * 17 : * You should have received a copy of the CeCILL-C License 18 : * along with this software. If not, it can be found on the official 19 : * website of the CeCILL licenses family (http://www.cecill.info/index.en.html). 20 : */ 21 : /** 22 : * @file test/mock_remote_endpoints_manager.h 23 : * @author Robin Passama 24 : * @brief header file for MockRemoteEndpointsManager class. 25 : * @date May 2025 26 : * @ingroup testutils 27 : */ 28 : #pragma once 29 : 30 : #include <memory> 31 : #include <map> 32 : #include <hardio/test/mock_message_interface.h> 33 : 34 : namespace hardio { 35 : 36 : namespace test { 37 : 38 : /** 39 : * @brief Management of device UDP endpoints not managed by 40 : * hardio 41 : * @details used to model device behavior in testing process 42 : * 43 : */ 44 : struct MockRemoteEndpointsManager { 45 : static MockRemoteEndpointsManager& instance(); 46 : static void reset(); 47 : 48 8 : ~MockRemoteEndpointsManager() = default; 49 : 50 : std::shared_ptr<MockMessageInterface> 51 : create_endpoint(const std::string& name, bool full_message_protocol); 52 : void remove_endpoint(const std::string& name); 53 : 54 : std::shared_ptr<MockMessageInterface> endpoint(const std::string& name); 55 : 56 : private: 57 : std::map<uint64_t, std::shared_ptr<MockMessageInterface>> endpoints_; 58 8 : MockRemoteEndpointsManager() = default; 59 : }; 60 : } // namespace test 61 : } // namespace hardio