jMax documentation
Main Page   Modules   File List  

byte stream

The byte stream abstraction (fts_bytestream_t). More...

The FTS byte stream structure

Initializing a byte stream

Initialization of classes and objects implementing a byte stream.

Handling incoming data

Typedefs


Detailed Description

The byte stream abstraction (fts_bytestream_t).

The byte stream is an abstraction of classes representing byte stream in/output devices like serial lines and TCP or UDP sockets.

FTS byte streams are FTS objects.

Various i/o objects can refer to an FTS byte stream in order to receive bytes (listeners) or send bytes to an internal or external device or file. Mulitple MIDI port listeners can be registered for a single stream.

If an i/o object refers to byte stream objects by a named variable, the same program (patch) can be configured for completely different setups simply by redefining the byte stream object defining the variable.

Different implementations of FTS byte streams are developed for different platforms and byte stream protocols. In many cases i/o objects implement a protocol (encoding and decoding) in order to send more complex data structures via a serial byte stream.

The API documented by this module permits to implement FTS byte stream classes. It contains the byte stream structure itself and the initialization functions for the FTS class implementing an FTS byte stream: fts_bytestream_class_init(), fts_bytestream_init().

A byte stream class allowing input, calls fts_bytestream_set_input() in the objects initialization and uses the provided input function fts_bytestream_input() in the routines handling incoming data. These functions propagate the incoming data to the listening i/o objects refering to the byte stream.

For the output a byte stream class must implement two output functions for sending single characters and entire strings to the bytestream as well as an optional function to flush eventual output buffers. The functions are declared by fts_bytestream_set_output() in the objects initialization.


Typedef Documentation

void(* fts_bytestream_flush_t)(fts_bytestream_t *stream)
 

Flush byte streams output buffer.

This function is optional and has not be declared only for byte streams using an output buffer

fts_bytestream_t
 

The FTS byte stream structure.

The FTS byte stream "inherits" from FTS object. The structure fts_bytestream_t itself must be included by a class implementing a byte stream:

   typedef struct my_bytestream
   {
     fts_bytestream_t stream;
     ... 
   } my_bytestream_t;

A byte stream class must call fts_bytestream_init() it the objects init Method.


Function Documentation

void fts_bytestream_class_init ( fts_class_t * cl )
 

Initialize a class implementing an FTS byte stream.

Parameters:
cl   FTS class

void fts_bytestream_init ( fts_bytestream_t * stream )
 

Initialize a byte stream structure.

Parameters:
stream   the byte stream

void fts_bytestream_input ( fts_bytestream_t * stream,
int n,
const unsigned char * c )
 

Call all listeners of the byte stream.

For incoming data a function is called by the object implementing an byte stream, which calls all listeners.

Parameters:
stream   the byte stream itself
n   the number of characters
c   the characters

void fts_bytestream_set_input ( fts_bytestream_t * stream )
 

Declare initialized byte stream as input.

Parameters:
stream   the byte stream

void fts_bytestream_set_output ( fts_bytestream_t * stream,
fts_bytestream_output_t output,
fts_bytestream_output_char_t output_char,
fts_bytestream_flush_t flush )
 

Declare an initialized byte stream as output and assign it's output functions.

Parameters:
stream   the byte stream
functions   structure of implemented output functions


jMax server kernel documentation (FTS 2.5)
Generated 4 Jul 2001 Wed Jul 4 13:07:06 2001 by Doxygen 1.2.3 written by Dimitri van Heesch.