Main Page | Namespace List | Class Hierarchy | Class List | Directories | Namespace Members | Class Members

MIDI_IO Class Reference

Virtual base for all MIDI I/O classes. More...

Inheritance diagram for MIDI_IO:

DYNAMIC_OBJECT< std::string > DYNAMIC_PARAMETERS< std::string > ECA_OBJECT MIDI_IO_RAW List of all members.

Public Types

Public type definitions and constants
enum  Io_mode { io_read = 1, io_write = 2, io_readwrite = 4 }
 Input/Output mode. More...

Public Member Functions

Constructors and destructors
virtual MIDI_IOclone (void) const =0
 Virtual method that clones the current object and returns a pointer to it.
virtual MIDI_IOnew_expr (void) const =0
 Virtual method that creates a new object of current type.
 MIDI_IO (const std::string &name="unknown", int mode=io_read)
Attribute functions
virtual int supported_io_modes (void) const
 Returns info about supported I/O modes (bitwise-OR).
virtual bool supports_nonblocking_mode (void) const
 Whether device supports non-blocking I/O mode.
Configuration
For setting and getting configuration parameters.

int io_mode (void) const
 Returns info about the current I/O mode.
const std::string & label (void) const
 Returns the current label.
void io_mode (int mode)
 Set object input/output-mode.
void label (const std::string &id_label)
 Sets object label.
void toggle_nonblocking_mode (bool value)
 Enable/disbale nonblocking mode.
virtual std::string parameter_names (void) const
 A comma-separated list of parameters names.
virtual void set_parameter (int param, std::string value)
 Sets the parameter value.
virtual std::string get_parameter (int param) const
 Get parameter value.
Main functionality
virtual long int read_bytes (void *target_buffer, long int bytes)=0
 Low-level routine for reading MIDI bytes.
virtual long int write_bytes (void *target_buffer, long int bytes)=0
 Low-level routine for writing MIDI bytes.
virtual void open (void)=0
 Opens the MIDI object (possibly in exclusive mode).
virtual void close (void)=0
 Closes the MIDI object.
Runtime information
virtual int poll_descriptor (void) const
 Returns a file descriptor id suitable for poll() and select() system calls.
bool is_open (void) const
 Has device been opened (with open())?
virtual bool finished (void) const =0
 Whether all data has been processed? If opened in mode 'io_read', this means that end of stream has been reached.
virtual bool nonblocking_mode (void) const
 Is nonblocking mode is enabled?
virtual bool readable (void) const
 Is the MIDI object ready for reading?
virtual bool writable (void) const
 Is the MIDI object ready for writing?

Protected Member Functions

void toggle_open_state (bool value)
 Sets device's state to enabled or disabled.

Detailed Description

Virtual base for all MIDI I/O classes.

Author:
Kai Vehmanen


Member Enumeration Documentation

enum MIDI_IO::Io_mode
 

Input/Output mode.

See also:
io_mode()
io_read

Object is opened for input. If opening a file, it must exist.

io_write

Object is opened for output. If opening a file and and output exists, it is first truncated.

io_readwrite

Object is opened for both reading and writing. If opening a file, a new file is created if needed. When switching from read to write or vica versa, position should be reset before using the device.


Member Function Documentation

virtual MIDI_IO* MIDI_IO::clone void   )  const [pure virtual]
 

Virtual method that clones the current object and returns a pointer to it.

This must be implemented by all subclasses!

Implements DYNAMIC_OBJECT< std::string >.

Implemented in MIDI_IO_RAW.

virtual void MIDI_IO::close void   )  [pure virtual]
 

Closes the MIDI object.

After calling this routine, all resources (ie. soundcard) must be freed (they can be used by other processes).

ensure: readable() != true writable() != true

Implemented in MIDI_IO_RAW.

virtual bool MIDI_IO::finished void   )  const [pure virtual]
 

Whether all data has been processed? If opened in mode 'io_read', this means that end of stream has been reached.

If opened in 'io_write' or 'io_readwrite' modes, finished status usually means that an error has occured (no space left, etc). After finished() has returned 'true', further calls to read() and/or write() won't process any data.

Implemented in MIDI_IO_RAW.

std::string MIDI_IO::get_parameter int  param  )  const [virtual]
 

Get parameter value.

Parameters:
param parameter id, require: param > 0

Implements DYNAMIC_PARAMETERS< std::string >.

Reimplemented in MIDI_IO_RAW.

void MIDI_IO::io_mode int  mode  ) 
 

Set object input/output-mode.

If the requested mode isn't supported, the nearest supported mode is used. Because of this, it's wise to afterwards check whether the requested mode was accepted.

require: is_open() != true

void MIDI_IO::label const std::string &  id_label  ) 
 

Sets object label.

Label is used to identify the object instance. Unlike ECA_OBJECT::name(), label() is not necessarily unique among different class instances. Device and file names are typical label values.

require: is_open() != true

const std::string & MIDI_IO::label void   )  const
 

Returns the current label.

See documentation for label(const std::string&).

virtual MIDI_IO* MIDI_IO::new_expr void   )  const [pure virtual]
 

Virtual method that creates a new object of current type.

This must be implemented by all subclasses!

Implements DYNAMIC_OBJECT< std::string >.

Implemented in MIDI_IO_RAW.

virtual void MIDI_IO::open void   )  [pure virtual]
 

Opens the MIDI object (possibly in exclusive mode).

This routine is meant for opening files and devices, loading libraries, etc.

ensure: readable() == true || writable() == true

Implemented in MIDI_IO_RAW.

virtual std::string MIDI_IO::parameter_names void   )  const [inline, virtual]
 

A comma-separated list of parameters names.

Derived classes must implement this.

Implements DYNAMIC_PARAMETERS< std::string >.

Reimplemented in MIDI_IO_RAW.

virtual int MIDI_IO::poll_descriptor void   )  const [inline, virtual]
 

Returns a file descriptor id suitable for poll() and select() system calls.

If polling is not supported, returns value of '-1'.

Reimplemented in MIDI_IO_RAW.

virtual long int MIDI_IO::read_bytes void *  target_buffer,
long int  bytes
[pure virtual]
 

Low-level routine for reading MIDI bytes.

Number of read bytes is returned. This must be implemented by all subclasses.

Implemented in MIDI_IO_RAW.

void MIDI_IO::set_parameter int  param,
std::string  value
[virtual]
 

Sets the parameter value.

Implementations should be able to handle arbitrary values of 'value'. Argument validity can be tested by a combination of set_parameter() and get_parameter() calls. Parameter value is valid, if get_parameter() returns it without changes.

Parameters:
param parameter id, require: param > 0
value new value

Implements DYNAMIC_PARAMETERS< std::string >.

Reimplemented in MIDI_IO_RAW.

int MIDI_IO::supported_io_modes void   )  const [virtual]
 

Returns info about supported I/O modes (bitwise-OR).

By default, all I/O modes are supported.

Reimplemented in MIDI_IO_RAW.

bool MIDI_IO::supports_nonblocking_mode void   )  const [virtual]
 

Whether device supports non-blocking I/O mode.

By default, nonblocking mode is not supported.

Reimplemented in MIDI_IO_RAW.

void MIDI_IO::toggle_nonblocking_mode bool  value  ) 
 

Enable/disbale nonblocking mode.

require: is_open() != true

virtual long int MIDI_IO::write_bytes void *  target_buffer,
long int  bytes
[pure virtual]
 

Low-level routine for writing MIDI bytes.

Number of bytes written is returned. This must be implemented by all subclasses.

Implemented in MIDI_IO_RAW.


The documentation for this class was generated from the following files:
Generated on Fri Apr 8 01:38:02 2005 for libecasound by  doxygen 1.4.1