next up previous contents
Next: The StdioDevice Up: Reference of C stdio Previous: Architecture of Stdio

The StdioDeviceType

# include  <StdioDevice.h>

class StdioDeviceType {
    public:
      StdioDeviceType(const char*name);
      virtual StdioDevice* open(const char*name) =0;
      virtual void close(StdioDevice*) =0;
};

This class is principly responsible for matching device type names to device types, and instance names to the actual devices. Each instance of StdioDeviceType represents a device type and has a single unique name. This name is stored in a static table and used by the stdio library to locate the named instance of StdioDeviceType.

Once the stdio library locates the StdioDeviceType instance, it uses the open method to map the instance name to a StdioDevice instance. This instance may be dynamically allocated, or statically allocated-the stdio library doesn't know or care. It will use the close method to tell the device type that the device is no longer needed and can be freed, if that is the case.

The open and close methods roughly correspond to the fopen and fclose functions of the stdio library. The StdioDeviceType object can cause the fopen to fail by returning a null pointer from open, and this can be used to enforce exclusive access, or any other access restrictions or errors.



Stephen Williams
9/2/1997