ONE - On-device Neural Engine
Loading...
Searching...
No Matches
cwrap::Fildes Class Referencefinal

POSIX File Descriptor. More...

#include <Fildes.h>

Public Member Functions

 Fildes ()
 
 Fildes (int value)
 
 Fildes (const Fildes &)=delete
 
 Fildes (Fildes &&)
 
 ~Fildes ()
 
Fildesoperator= (Fildes &&)
 
int get (void) const
 
void set (int value)
 
int release (void)
 

Detailed Description

POSIX File Descriptor.

Note
Fildes owns underlying file descriptor

Definition at line 28 of file Fildes.h.

Constructor & Destructor Documentation

◆ Fildes() [1/4]

cwrap::Fildes::Fildes ( )

Definition at line 38 of file Fildes.cpp.

38 : _value{-1}
39{
40 // DO NOTHING
41}

◆ Fildes() [2/4]

cwrap::Fildes::Fildes ( int  value)
explicit

Definition at line 43 of file Fildes.cpp.

43 : _value{value}
44{
45 // DO NOTHING
46 assert(error_value(value) || valid_value(value));
47}

◆ Fildes() [3/4]

cwrap::Fildes::Fildes ( const Fildes )
delete

◆ Fildes() [4/4]

cwrap::Fildes::Fildes ( Fildes &&  fildes)

Definition at line 49 of file Fildes.cpp.

50{
51 set(fildes.release());
52 assert(error_value(fildes.get()));
53}
void set(int value)
Definition Fildes.cpp:76

References set().

◆ ~Fildes()

cwrap::Fildes::~Fildes ( )

Definition at line 55 of file Fildes.cpp.

56{
57 assert(error_value(_value) || valid_value(_value));
58
59 if (valid_value(_value))
60 {
61 close(_value);
62 _value = -1;
63 }
64
65 assert(error_value(_value));
66}

Member Function Documentation

◆ get()

int cwrap::Fildes::get ( void  ) const

Definition at line 74 of file Fildes.cpp.

74{ return _value; }

Referenced by release(), and cwrap::valid().

◆ operator=()

Fildes & cwrap::Fildes::operator= ( Fildes &&  fildes)

Definition at line 68 of file Fildes.cpp.

69{
70 set(fildes.release());
71 return (*this);
72}

References set().

◆ release()

int cwrap::Fildes::release ( void  )

Definition at line 91 of file Fildes.cpp.

92{
93 int res = get();
94 _value = -1;
95 return res;
96}
int get(void) const
Definition Fildes.cpp:74

References get().

◆ set()

void cwrap::Fildes::set ( int  value)

Definition at line 76 of file Fildes.cpp.

77{
78 assert(error_value(_value) || valid_value(_value));
79
80 if (valid_value(_value))
81 {
82 close(_value);
83 _value = -1;
84 }
85 assert(error_value(_value));
86
87 _value = value;
88 assert(_value == value);
89}

Referenced by Fildes(), and operator=().


The documentation for this class was generated from the following files: