Android-cuttlefish cvd tool
file_monitor_source.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <stddef.h>
20
21#include <functional>
22#include <memory>
23#include <string>
24#include <string_view>
25
28#include "cuttlefish/io/io.h"
30
31namespace cuttlefish {
32
34 public:
36 std::string path, std::unique_ptr<ReaderSeeker> file_io,
37 std::function<Result<std::string>(std::string_view)> colorize_line,
38 std::function<Result<bool>(std::string_view)> filter_line);
40
41 MonitorOutput Report(size_t rows, size_t columns) override;
42
43 SharedFD ReadyFd() override;
44
45 private:
46 std::string path_;
47 std::unique_ptr<ReaderSeeker> file_io_;
48 std::function<Result<std::string>(std::string_view)> colorize_line_;
49 std::function<Result<bool>(std::string_view)> filter_line_;
51};
52
53} // namespace cuttlefish
Definition: file_monitor_source.h:33
std::unique_ptr< ReaderSeeker > file_io_
Definition: file_monitor_source.h:47
std::function< Result< bool >(std::string_view)> filter_line_
Definition: file_monitor_source.h:49
std::string path_
Definition: file_monitor_source.h:46
SharedFD ReadyFd() override
Definition: file_monitor_source.cc:143
FileMonitorSource(std::string path, std::unique_ptr< ReaderSeeker > file_io, std::function< Result< std::string >(std::string_view)> colorize_line, std::function< Result< bool >(std::string_view)> filter_line)
Definition: file_monitor_source.cc:108
MonitorOutput Report(size_t rows, size_t columns) override
Definition: file_monitor_source.cc:125
std::function< Result< std::string >(std::string_view)> colorize_line_
Definition: file_monitor_source.h:48
SharedFD inotify_fd_
Definition: file_monitor_source.h:50
Definition: monitor_source.h:36
Definition: shared_fd.h:124
Definition: alloc_driver.h:20
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30
Definition: monitor_source.h:28