compat_mode_manager.hpp
1 /*
2  * Copyright (c) 2025, NVIDIA CORPORATION.
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 <string>
20 
21 #include <kvikio/compat_mode.hpp>
22 
23 namespace kvikio {
24 
25 // Forward declaration.
26 class FileHandle;
27 
32  private:
33  CompatMode _compat_mode_requested{CompatMode::AUTO};
34  bool _is_compat_mode_preferred{true};
35  bool _is_compat_mode_preferred_for_async{true};
36 
37  public:
41  CompatModeManager() noexcept = default;
42 
59  CompatModeManager(std::string const& file_path,
60  std::string const& flags,
61  mode_t mode,
63  FileHandle* file_handle);
64 
65  ~CompatModeManager() noexcept = default;
66  CompatModeManager(const CompatModeManager&) = default;
67  CompatModeManager& operator=(const CompatModeManager&) = default;
68  CompatModeManager(CompatModeManager&&) noexcept = default;
69  CompatModeManager& operator=(CompatModeManager&&) noexcept = default;
70 
77  bool is_compat_mode_preferred() const noexcept;
78 
85  bool is_compat_mode_preferred_for_async() const noexcept;
86 
93 
104 };
105 
106 } // 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:45
KvikIO namespace.
Definition: batch.hpp:27
CompatMode
I/O compatibility mode.
Definition: compat_mode.hpp:26