I/O Classes
Magnum also contains a rich set of support classes for input and output. Both stream based and file based I/O is supported by different classes. By using stream based I/O at as much places as possible, Magnum is able to load many files directly from the web using HTTP instead of first storing them in a temporory file and opening them later.
The I/O module implements the following features amongst others:
- File based I/O. This is the easiest and most common type of I/O operations: File based I/O. It is characterised by the ability of seeking, and thus is the most flexible way of accessing data.
- Stream basaed I/O. Stream based I/O lacks the possibility of seeking and is often used with networking (HTTP or sockets). Magnnum tries to use stream based I/O as much as possible in order to enable direct opening of files via HTTP etc.
- Input and Output buffering. In order to improve the I/O speed of slow devices and to minimise system calls while parsing text information, Magnum offers optional input and output buffering for streams.
- Support for Archives. A basic support for archive files enables the transparent usage of packed files contained in ZIP or PAK archives.
- Memory Files. In some it is sufficient to create a file in main memory without a physical representation on the harddisc. Here memory files jump in and offer unparalleled access speed for reading and writing.
- Translators. At many places Magnum uses the concept of so called Translators in order to read or write data files. A translator is a class that knows to handle a specific file type with a unified API. All image loaders (BMP, PCX, GF, JPG etc) and all 3d model loaders (3DS, OBJ, LWO etc) are implemented as translators offering a common API for easy usage.