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 in
e04ucf), 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 and
IOManager::register_to_advisory_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 and
std::cout respectively), via
IOManager::reset_error_message_unit and
IOManager::reset_advisory_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 or
IOManager::unit_from_ostream must be used.
The actual writing and reading of information is carried out via
IOManager::print_rec and
IOManager::read_rec respectively.
When a channel is no longer required it may be deregistered by calling
IOManager::deregister_ostream or
IOManager::deregister_istream. 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.
None.