Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MCIOBase Class Reference

Base class for all IO classes. More...

#include <mcllib/MCIOBase.h>

Inheritance diagram for MCIOBase:

MCBase MCFile MCSocket MCCLSocket MCCOSocket MCUDPSocket MCCOUDPSocket MCStreamSocket MCTCPSocket List of all members.

Public Member Functions

mcllib::mcint64 available () const
 Get the amount of data available from the IO object.
void close ()
 Close the IO object.
void * getHandle () const
 Get a pointer to the implementation of the IO object.
bool isOpen () const
 Test to see if the object is open.
bool poll (mcintn pollFlags, mcinterval_t timeout) const
 Poll the IO object.
mcllib::mcint32 read (void *buf, mcllib::mcint32 size)
 Read data from the IO object.
void setInherit (bool inherit)
 Allow/disallow an IO object to be inherited by child processes.
MCString toString () const
 Get representation of the IO object as string for diagnostic purposes.
mcllib::mcint32 write (const void *buf, mcllib::mcint32 size)
 Write data to the IO object.
 ~MCIOBase ()
 Destructor.

Static Public Attributes

const mcintn MCPOLLALL
 Convenience indicating all poll flags.
const mcintn MCPOLLEX
 Flag indicating interest in knowning about exception on the IO object.
const mcintn MCPOLLRD
 Flag indicating interest in reading the IO object.
const mcintn MCPOLLWR
 Flag indicating interest in writing the IO object.

Protected Member Functions

 MCIOBase (void *impl)
 Constructor from an implementation handle.
 MCIOBase ()
 Default constructor.

Detailed Description

Base class for all IO classes.

This base class provides methods which are common to all types of IO.

Derived class constructors may provide a pointer to a private implementation class derived from mclpriv::MCIOBaseImpl which is reference counted to allow fast and simple copying. It is still better to pass as const references instead of by value to avoid the reference counting overhead.

Todo:
Implement static poll method for several IO objects at once


Constructor & Destructor Documentation

~MCIOBase  ) 
 

Destructor.

The close method is called to ensure resource are freed up.

MCIOBase  )  [protected]
 

Default constructor.

Creates an unnamed, unopen IO object.

MCIOBase void *  impl  )  [protected]
 

Constructor from an implementation handle.

impl must point to an object derived from MCIOBaseImpl.


Member Function Documentation

mcllib::mcint64 available  )  const
 

Get the amount of data available from the IO object.

If the operation fails an exception is thrown.

Returns:
the number of bytes of data available

void close  ) 
 

Close the IO object.

Frees up any resources that may have been allocated. All calls to close() after the first one are ignored.

void* getHandle  )  const
 

Get a pointer to the implementation of the IO object.

Returns:
a pointer to the implementation object

bool isOpen  )  const
 

Test to see if the object is open.

Returns:
true if the IO object is open.

bool poll mcintn  pollFlags,
mcinterval_t  timeout
const
 

Poll the IO object.

Poll is used to test whether it is possible to read from or write to the object, or if the object is in error.

Parameters:
pollFlags indicates what to poll for.
timeout indicates how long to wait.
Returns:
false if the timeout elapses before the read or write can occur or before the object is in error. Otherwise returns true.

mcllib::mcint32 read void *  buf,
mcllib::mcint32  size
 

Read data from the IO object.

If the read fails an exception is thrown.

Parameters:
buf must point to a region of memory of at least size bytes
size the number of bytes to read into the buffer
Returns:
the number of bytes actually read. A return value of zero indicates that no more data is available.

void setInherit bool  inherit  ) 
 

Allow/disallow an IO object to be inherited by child processes.

If the IO object cannot have its inherit state changed an exception will be thrown.

Parameters:
inherit specifies whether the object can be inherited. If inherit is true the IO object will be inherited by child processes. If inherit is false the IO object will not be inherited by child processes. When IO objects are created they are not automatically inherited by child processes.

MCString toString  )  const
 

Get representation of the IO object as string for diagnostic purposes.

Returns:
a string representing the IO object

mcllib::mcint32 write const void *  buf,
mcllib::mcint32  size
 

Write data to the IO object.

If the write fails an exception is thrown.

Parameters:
buf must point to a region of memory of at least size bytes
size the number of bytes to read into the buffer
Returns:
the number of bytes actually written.


Generated on Wed Jan 12 19:05:49 2005 for MCLLIB by  doxygen 1.3.9.1