NAG CPP Interface
class IOManager : IOManagerBase
A class for translating between std::istream or std::ostream (referred to as Input channel and Output channel respectively in the rest of this documentation) and the Input/Output unit numbers used in the algorithmic engine.
The Input/Output unit numbers (usually just referred to as unit numbers) are roughly synonymous with Unix file descriptors, with Input channels registered to a particular unit number using IOManager::register_istream
and Output channels using IOManager::register_ostream
The documentation for a number of functions in the NAG CPP Interface refer to error unit or advisory unit (see for example majorprintlevel
), which can be thought of as being analogous to standard error, std::cerr
and standard output, std::cout
, respectively. The convenience methods, IOManager::register_to_error_message_unit
, are supplied to associate channels with the error unit and the advisory unit. The error unit and advisory unit can be reset to their default values (std::cerr
respectively), via IOManager::reset_error_message_unit
Resource management (opening/closing/deleting etc. files) remains the reponsibility of the user. In particular, files used for channels must have been opened before their associated unit numbers are used.
To communicate unit numbers to a function, the value returned either when a channel is registered, or from IOManager::unit_from_istream
must be used.
The actual writing and reading of information is carried out via IOManager::print_rec
When a channel is no longer required it may be deregistered by calling IOManager::deregister_ostream
. The special nature of the error unit and the advisory unit means that these must have persistent channel associations; therefore if a channel associated with their unit number is deregistered then they are reset to their default values.
A global variable GLOBAL_IOMANAGER
is supplied for convenience and will be used by all functions unless it is specifically overridden in the optional argument class as described in Optional Arguments