compat_mode_manager.hpp
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <string>
9 
10 #include <kvikio/compat_mode.hpp>
11 
12 namespace kvikio {
13 
14 // Forward declaration.
15 class FileHandle;
16 
21  private:
22  CompatMode _compat_mode_requested{CompatMode::AUTO};
23  bool _is_compat_mode_preferred{true};
24  bool _is_compat_mode_preferred_for_async{true};
25 
26  public:
30  CompatModeManager() noexcept = default;
31 
48  CompatModeManager(std::string const& file_path,
49  std::string const& flags,
50  mode_t mode,
52  FileHandle* file_handle);
53 
54  ~CompatModeManager() noexcept = default;
55  CompatModeManager(const CompatModeManager&) = default;
56  CompatModeManager& operator=(const CompatModeManager&) = default;
57  CompatModeManager(CompatModeManager&&) noexcept = default;
58  CompatModeManager& operator=(CompatModeManager&&) noexcept = default;
59 
66  bool is_compat_mode_preferred() const noexcept;
67 
74  bool is_compat_mode_preferred_for_async() const noexcept;
75 
82 
93 };
94 
95 } // namespace kvikio
Store and manage the compatibility mode data associated with a FileHandle.
CompatMode compat_mode_requested() const noexcept
Retrieve the original compatibility mode requested.
bool is_compat_mode_preferred_for_async() const noexcept
Check if the compatibility mode for asynchronous I/O of the associated FileHandle is expected to be C...
bool is_compat_mode_preferred() const noexcept
Check if the compatibility mode for synchronous I/O of the associated FileHandle is expected to be Co...
CompatModeManager() noexcept=default
Construct an empty compatibility mode manager.
void validate_compat_mode_for_async() const
Determine if asynchronous I/O can be performed or not (throw exceptions) according to the existing co...
Handle of an open file registered with cufile.
Definition: file_handle.hpp:32
KvikIO namespace.
Definition: batch.hpp:16
CompatMode
I/O compatibility mode.
Definition: compat_mode.hpp:15