Line data Source code
1 : /* File: io.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 common/io.h 23 : * @author Robin Passama 24 : * @brief header file for IO class 25 : * @date May 2025 26 : * @ingroup core 27 : */ 28 : #pragma once 29 : 30 : #include <hardio/common/interface.h> 31 : #include <cstdint> 32 : #include <string> 33 : 34 : namespace hardio { 35 : 36 : class IOBoard; 37 : 38 : /** 39 : * @brief Abstract class that represents any hardware interface directly 40 : * provided by a board. 41 : * @details this class is specializd for each type of IO. 42 : * 43 : */ 44 : class IO : public Interface { 45 : public: 46 : IO() = delete; 47 : IO(const IO&) = delete; 48 149 : virtual ~IO() = default; 49 : 50 : /** 51 : * @brief get the name of the interface 52 : * 53 : * @return std::string the name 54 : */ 55 : virtual std::string name() const final; 56 : 57 : /** 58 : * @brief get the unique id of the interface 59 : * 60 : * @return std::string the id 61 : */ 62 : std::string id() const override; 63 : 64 : virtual bool check(const IOBoard& card, std::string& reason) const; 65 : 66 : /** 67 : * @brief get id of the IO concrete type 68 : * 69 : * @return type id as a uint64_t 70 : */ 71 : virtual uint64_t type_id() const final; 72 : 73 : /** 74 : * @brief get nice name of the IO concrete type 75 : * 76 : * @return IO name as a std string_view 77 : */ 78 : virtual std::string_view io_name() const = 0; 79 : 80 : protected: 81 : /** 82 : * @brief Construct a new IO object 83 : * 84 : * @param type_id type of the concrete IO 85 : * @param id of the concrete IO instance 86 : */ 87 : IO(uint64_t type_id, std::string_view id); 88 : 89 : private: 90 : friend class IOBoard; 91 : std::string id_; 92 : uint64_t type_id_; 93 : }; 94 : 95 : } // namespace hardio