SNode.C
Loading...
Searching...
No Matches
FileReader.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef CORE_FILE_FILEREADER_H
21#define CORE_FILE_FILEREADER_H
22
23#include "core/EventReceiver.h"
24#include "core/file/File.h"
25#include "core/pipe/Source.h" // IWYU pragma: export
26
27#ifndef DOXYGEN_SHOULD_SKIP_THIS
28
29#include <cstddef>
30#include <string>
31
32#endif /* DOXYGEN_SHOULD_SKIP_THIS */
33
34namespace core::file {
35
37 : public core::EventReceiver
38 , public core::pipe::Source
39 , virtual public File {
40 private:
41 FileReader(int fd, const std::string& name, std::size_t pufferSize, int openErrno);
42
43 public:
44 static FileReader* open(const std::string& path);
45
46 bool isOpen() override;
47
48 void start() final;
49 void suspend() final;
50 void resume() final;
51 void stop() final;
52
53 private:
54 void onEvent(const utils::Timeval& currentTime) override;
55
57
58 bool suspended = false;
59
60 protected:
61 int openErrno = 0;
62 bool running = false;
63 };
64
65} // namespace core::file
66
67#endif // CORE_FILE_FILEREADER_H
constexpr int MF_READSIZE
std::size_t pufferSize
Definition FileReader.h:56
void onEvent(const utils::Timeval &currentTime) override
static FileReader * open(const std::string &path)
FileReader(int fd, const std::string &name, std::size_t pufferSize, int openErrno)
bool isOpen() override
void error(int errnum)
Definition Source.cpp:87