/workspaces/astro/sol3-sdk/cpp/sol3/core/file_descriptor.h Source File

Space-ng SDK: /workspaces/astro/sol3-sdk/cpp/sol3/core/file_descriptor.h Source File
Space-ng SDK
file_descriptor.h
Go to the documentation of this file.
1 // Copyright (c) Space-ng, inc. All rights reserved.
2 
3 #pragma once
4 
5 namespace sol3::core {
6 
13  public:
16  explicit FileDescriptor(int fd = -1);
18  FileDescriptor(FileDescriptor const&) = delete;
20  FileDescriptor(FileDescriptor&& other) noexcept;
22 
24  bool isOpen() const;
25 
27  int get() const;
28 
30  void reset(int fd = -1);
31 
32  private:
34  void close();
35 
36  int fd_;
37 };
38 
39 } // namespace sol3::core
RAII wrapper for POSIX file descriptors.
Definition: file_descriptor.h:12
FileDescriptor(FileDescriptor &&other) noexcept
FileDescriptor(int fd=-1)
Constructs a FileDescriptor.
bool isOpen() const
Return true if the file descriptor is open, false otherwise.
FileDescriptor(FileDescriptor const &)=delete
FileDescriptor & operator=(FileDescriptor &&other) noexcept
void reset(int fd=-1)
Closes and replaces the underlying file descriptor.
FileDescriptor & operator=(FileDescriptor const &)=delete
int get() const
Return the underlying file descriptor.
Definition: any_message_input.h:15