#include <fd_array.hh>
|
| FDArray (std::string const &input, std::string const &output, std::string const &errout) |
| Initialize the file descriptor array and set the standard file descriptors to defaults or values passed in with the process params. More...
|
|
void | updateFileOffsets () |
| Figure out the file offsets for all currently open files and save them the offsets during the calls to drain by the owning process. More...
|
|
void | restoreFileOffsets () |
| Restore all offsets for currently open files during the unserialize phase for the owning process class. More...
|
|
std::shared_ptr< FDEntry > | operator[] (int tgt_fd) |
| Treat this object like a normal array in using the subscript operator to pull entries out of it. More...
|
|
int | allocFD (std::shared_ptr< FDEntry > fdp) |
| Step through the file descriptor array and find the first available entry which is denoted as being free by being a 'nullptr'. More...
|
|
int | getSize () const |
| Return the size of the _fdArray field. More...
|
|
void | setFDEntry (int tgt_fd, std::shared_ptr< FDEntry > fdep) |
| Put the pointer specified by fdep into the _fdArray entry indexed by tgt_fd. More...
|
|
int | closeFDEntry (int tgt_fd) |
| Try to close the host file descriptor. More...
|
|
|
int | openFile (std::string const &file_name, int flags, mode_t mode) const |
| Help clarify our intention when opening files in the init and restoration code. More...
|
|
int | openInputFile (std::string const &file_name) const |
|
int | openOutputFile (std::string const &file_name) const |
|
std::shared_ptr< FDEntry > | getFDEntry (int tgt_fd) |
| Return the file descriptor entry object associated with the index provided. More...
|
|
|
std::array< std::shared_ptr
< FDEntry >, NUM_FDS > | _fdArray |
| Hold pointers to the file descriptor entries. More...
|
|
std::map< std::string, int > | imap |
| Hold strings which represent the default values which are checked against to initialize the standard file descriptors. More...
|
|
std::map< std::string, int > | oemap |
|
Definition at line 45 of file fd_array.hh.
FDArray::FDArray |
( |
std::string const & |
input, |
|
|
std::string const & |
output, |
|
|
std::string const & |
errout |
|
) |
| |
Initialize the file descriptor array and set the standard file descriptors to defaults or values passed in with the process params.
- Parameters
-
input | Used to initialize the stdin file descriptor |
output | Used to initialize the stdout file descriptor |
errout | Used to initialize the stderr file descriptor |
Definition at line 49 of file fd_array.cc.
int FDArray::allocFD |
( |
std::shared_ptr< FDEntry > |
fdp | ) |
|
Step through the file descriptor array and find the first available entry which is denoted as being free by being a 'nullptr'.
That file descriptor entry is the new target file descriptor entry that we return as the return parameter.
- Parameters
-
fdp | Allocated beforehand and passed into this method; the fdp is meant to be a generic pointer capable of pointing to different types of file descriptors. Must cast the pointer to the correct type before dereferencing to access the needed fields. |
int FDArray::closeFDEntry |
( |
int |
tgt_fd | ) |
|
Try to close the host file descriptor.
If successful, set the specified file descriptor entry object pointer to nullptr. Used to "close" the target file descriptor.
- Parameters
-
tgt_fd | Use target file descriptors to index the array. |
std::shared_ptr<FDEntry> FDArray::getFDEntry |
( |
int |
tgt_fd | ) |
|
|
private |
Return the file descriptor entry object associated with the index provided.
(The index is protected with bounds checking on the array size without the use of the array's at operator.)
- Parameters
-
tgt_fd | Use target file descriptors to index the array. |
Referenced by operator[]().
int FDArray::getSize |
( |
| ) |
const |
|
inline |
int FDArray::openFile |
( |
std::string const & |
file_name, |
|
|
int |
flags, |
|
|
mode_t |
mode |
|
) |
| const |
|
private |
Help clarify our intention when opening files in the init and restoration code.
These are helper functions which are not meant to be exposed to other objects or files.
int FDArray::openInputFile |
( |
std::string const & |
file_name | ) |
const |
|
private |
int FDArray::openOutputFile |
( |
std::string const & |
file_name | ) |
const |
|
private |
std::shared_ptr<FDEntry> FDArray::operator[] |
( |
int |
tgt_fd | ) |
|
|
inline |
Treat this object like a normal array in using the subscript operator to pull entries out of it.
- Parameters
-
tgt_fd | Use target file descriptors to index the array. |
Definition at line 84 of file fd_array.hh.
References getFDEntry().
void FDArray::restoreFileOffsets |
( |
| ) |
|
Restore all offsets for currently open files during the unserialize phase for the owning process class.
void FDArray::setFDEntry |
( |
int |
tgt_fd, |
|
|
std::shared_ptr< FDEntry > |
fdep |
|
) |
| |
Put the pointer specified by fdep into the _fdArray entry indexed by tgt_fd.
- Parameters
-
tgt_fd | Use target file descriptors to index the array. |
fdep | Incoming pointer used to set the entry pointed to by tgt_fd. |
void FDArray::updateFileOffsets |
( |
| ) |
|
Figure out the file offsets for all currently open files and save them the offsets during the calls to drain by the owning process.
std::string FDArray::_errout |
Hold pointers to the file descriptor entries.
The array size is statically defined by the operating system.
Definition at line 144 of file fd_array.hh.
Referenced by getSize().
std::string FDArray::_input |
std::string FDArray::_output |
std::map<std::string, int> FDArray::imap |
|
private |
Hold strings which represent the default values which are checked against to initialize the standard file descriptors.
If the string provided doesn't hit against these maps, then a file is opened on the host instead of using the host's standard file descriptors.
Definition at line 152 of file fd_array.hh.
const int FDArray::NUM_FDS = 1024 |
|
staticprivate |
std::map<std::string, int> FDArray::oemap |
|
private |
The documentation for this class was generated from the following files: