added kdoc-style documentation

This commit is contained in:
darkeye 2000-11-11 12:33:13 +00:00
parent 23d0175ba1
commit 469ff7b60c
11 changed files with 854 additions and 361 deletions

View File

@ -9,13 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
A Sink with a First-In First-Out buffer
This buffer can always be written to, it overwrites any
data contained if needed
The class is not thread-safe
the buffer is filled like this: the buffer is filled like this:
buffer bufferEnd buffer bufferEnd
@ -46,8 +39,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -380,6 +372,9 @@ BufferedSink :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.4 2000/11/11 12:33:13 darkeye
added kdoc-style documentation
Revision 1.3 2000/11/10 20:16:21 darkeye Revision 1.3 2000/11/10 20:16:21 darkeye
first real tests with multiple streaming first real tests with multiple streaming

View File

@ -9,13 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
A Sink First-In First-Out buffer
This buffer can always be written to, it overwrites any
data contained if needed
The class is not thread-safe
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -30,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#ifndef BUFFERED_SINK_H #ifndef BUFFERED_SINK_H
@ -56,38 +48,96 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* A Sink First-In First-Out buffer.
* This buffer can always be written to, it overwrites any
* data contained if needed.
* The class is not thread-safe.
* *
*----------------------------------------------------------------------------*/ * @author $Author$
* @version $Revision$
*/
class BufferedSink : public Sink class BufferedSink : public Sink
{ {
private: private:
/**
* The buffer.
*/
unsigned char * buffer; unsigned char * buffer;
/**
* The end of the buffer.
*/
unsigned char * bufferEnd; unsigned char * bufferEnd;
/**
* The size of the buffer.
*/
unsigned int bufferSize; unsigned int bufferSize;
/**
* The highest usage of the buffer.
*/
unsigned int peak; unsigned int peak;
/**
* All data written to this BufferedSink is handled by chuncks
* of this size.
*/
unsigned int chunkSize; unsigned int chunkSize;
/**
* Number of bytes the underlying stream is misaligned with
* chunkSize. (It needs this many bytes more to be aligned.)
*/
unsigned int misalignment; unsigned int misalignment;
/**
* Start of free territory in buffer.
*/
unsigned char * inp; unsigned char * inp;
/**
* Start of sensible data in buffer.
*/
unsigned char * outp; unsigned char * outp;
/**
* The underlying Sink.
*/
Ref<Sink> sink; Ref<Sink> sink;
/**
* Initialize the object.
*
* @param sink the Sink to attach this BufferedSink to.
* @param size the size of the internal buffer to use.
* @param chunkSize size of chunks to handle data in.
* @exception Exception
*/
void void
init ( Sink * sink, init ( Sink * sink,
unsigned int size, unsigned int size,
unsigned int chunkSize ) throw ( Exception ); unsigned int chunkSize ) throw ( Exception );
/**
* De-initialize the object.
*
* @exception Exception
*/
void void
strip ( void ) throw ( Exception ); strip ( void ) throw ( Exception );
/**
* Slide a pointer in the internal buffer by offset. If the pointer
* would reach beyond the end of the buffer, it goes wraps around.
*
* @param p the pointer to slide.
* @param offset the amount to slide with.
* @return pointer p + offset, wrapped around if needed.
*/
inline unsigned char * inline unsigned char *
slidePointer ( slidePointer (
unsigned char * p, unsigned char * p,
@ -101,9 +151,13 @@ class BufferedSink : public Sink
return p; return p;
} }
/**
* Update the peak buffer usage indicator.
*
* @see #peak
*/
inline void inline void
updatePeak ( void ) updatePeak ( void ) throw ()
{ {
unsigned int u; unsigned int u;
@ -113,7 +167,13 @@ class BufferedSink : public Sink
} }
} }
/**
* If the underlying Sink is misaligned on chunkSize, write as
* many 0s as needed to get it aligned.
*
* @see #misalignment
* @see #chunkSize
*/
inline bool inline bool
align ( void ) align ( void )
{ {
@ -139,20 +199,37 @@ class BufferedSink : public Sink
protected: protected:
/**
* Default constructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
BufferedSink ( void ) throw ( Exception ) BufferedSink ( void ) throw ( Exception )
{ {
throw Exception( __FILE__, __LINE__); throw Exception( __FILE__, __LINE__);
} }
/**
* Get the size of the buffer.
*
* @return the size of the buffer.
*/
inline unsigned int inline unsigned int
getSize ( void ) const throw () getSize ( void ) const throw ()
{ {
return bufferSize; return bufferSize;
} }
/**
* Store data in the internal buffer. If there is not enough space,
* discard all in the buffer and the beginning of the supplied
* buffer if needed.
*
* @param buffer the data to store.
* @param bufferSize the amount of data to store in bytes.
* @return number of bytes really stored.
*/
unsigned int unsigned int
store ( const void * buffer, store ( const void * buffer,
unsigned int bufferSize ) throw ( Exception ); unsigned int bufferSize ) throw ( Exception );
@ -160,6 +237,15 @@ class BufferedSink : public Sink
public: public:
/**
* Constructor by an underlying Sink, buffer size and chunk size.
*
* @param sink the Sink to attach this BufferSink to.
* @param size the size of the buffer to use for buffering.
* @param chunkSize hanlde all data in write() as chunks of
* chunkSize
* @exception Exception
*/
inline inline
BufferedSink ( Sink * sink, BufferedSink ( Sink * sink,
unsigned int size, unsigned int size,
@ -168,42 +254,78 @@ class BufferedSink : public Sink
init( sink, size, chunkSize); init( sink, size, chunkSize);
} }
/**
* Copy constructor.
*
* @param buffer the object to copy.
* @exception Exception
*/
BufferedSink ( const BufferedSink & buffer ) throw ( Exception ); BufferedSink ( const BufferedSink & buffer ) throw ( Exception );
/**
* Destructor.
*
* @exception Exception
*/
inline virtual inline virtual
~BufferedSink ( void ) throw ( Exception ) ~BufferedSink ( void ) throw ( Exception )
{ {
strip(); strip();
} }
/**
* Assignment operator.
*
* @param bs the object to assign to this one.
* @return a reference to this object.
* @exception Exception
*/
virtual BufferedSink & virtual BufferedSink &
operator= ( const BufferedSink & bs ) throw ( Exception ); operator= ( const BufferedSink & bs ) throw ( Exception );
/**
* Get the peak usage of the internal buffer.
*
* @return the peak usage of the internal buffer.
*/
inline unsigned int inline unsigned int
getPeak ( void ) const throw () getPeak ( void ) const throw ()
{ {
return peak; return peak;
} }
/**
* Open the BufferedSink. Opens the underlying Sink.
*
* @return true if opening was successful, false otherwise.
* @exception Exception
*/
inline virtual bool inline virtual bool
open ( void ) throw ( Exception ) open ( void ) throw ( Exception )
{ {
return sink->open(); return sink->open();
} }
/**
* Check if a BufferedSink is open.
*
* @return true if the BufferedSink is open, false otherwise.
*/
inline virtual bool inline virtual bool
isOpen ( void ) const throw ( Exception ) isOpen ( void ) const throw ()
{ {
return sink->isOpen(); return sink->isOpen();
} }
/**
* Check if the BufferedSink is ready to accept data.
* Always returns true immediately.
*
* @param sec the maximum seconds to block.
* @param usec micro seconds to block after the full seconds.
* @return true
* @exception Exception
*/
inline virtual bool inline virtual bool
canWrite ( unsigned int sec, canWrite ( unsigned int sec,
unsigned int usec ) throw ( Exception ) unsigned int usec ) throw ( Exception )
@ -211,12 +333,28 @@ class BufferedSink : public Sink
return true; return true;
} }
/**
* Write data to the BufferedSink.
* Always reads the maximum number of chunkSize chunks buf
* holds. If the data can not be written to the underlying
* stream, it is buffered. If the buffer overflows, the oldest
* data is discarded.
*
* @param buf the data to write.
* @param len number of bytes to write from buf.
* @return the number of bytes written (may be less than len).
* @exception Exception
*/
virtual unsigned int virtual unsigned int
write ( const void * buf, write ( const void * buf,
unsigned int len ) throw ( Exception ); unsigned int len ) throw ( Exception );
/**
* Flush all data that was written to the BufferedSink to the
* underlying Sink.
*
* @exception Exception
*/
inline virtual void inline virtual void
flush ( void ) throw ( Exception ) flush ( void ) throw ( Exception )
{ {
@ -225,7 +363,11 @@ class BufferedSink : public Sink
write( b, 0); write( b, 0);
} }
/**
* Close the BufferedSink. Closes the underlying Sink.
*
* @exception Exception
*/
virtual void virtual void
close ( void ) throw ( Exception ); close ( void ) throw ( Exception );
}; };
@ -246,6 +388,9 @@ class BufferedSink : public Sink
$Source$ $Source$
$Log$ $Log$
Revision 1.4 2000/11/11 12:33:13 darkeye
added kdoc-style documentation
Revision 1.3 2000/11/10 20:16:21 darkeye Revision 1.3 2000/11/10 20:16:21 darkeye
first real tests with multiple streaming first real tests with multiple streaming

View File

@ -9,14 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
An exception class
This class should not depend on any other class
(note: Cloneable is an interface) and should not throw
any exceptions itself
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -31,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -212,6 +203,9 @@ Exception :: strip ( void ) throw ()
$Source$ $Source$
$Log$ $Log$
Revision 1.4 2000/11/11 12:33:13 darkeye
added kdoc-style documentation
Revision 1.3 2000/11/09 22:05:44 darkeye Revision 1.3 2000/11/09 22:05:44 darkeye
added multiple-string constructors added multiple-string constructors

View File

@ -9,14 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
An exception class
This class should not depend on any other class
(note: Cloneable is an interface) and should not throw
any exceptions itself
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -31,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#ifndef EXCEPTION_H #ifndef EXCEPTION_H
@ -56,26 +47,62 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* An exception class.
* *
*----------------------------------------------------------------------------*/ * This class should not depend on any other class
* should not throw any exceptions itself.
*
* Typical usage:
*
* <pre>
* throw Exception( __FILE__, __LINE__, "describe the exception", code);
* </pre>
*
* @author $Author$
* @version $Revision$
*/
class Exception class Exception
{ {
private: private:
/**
* Source file the exception was thrown in.
*/
char * file; char * file;
/**
* Line number in the source file the exception was thrown in.
*/
unsigned int line; unsigned int line;
/**
* Textual description of the exception.
*/
char * description; char * description;
/**
* Numerical error code.
*/
int code; int code;
/**
* Initalize the object.
*
* @param file the source file the exception was thrown in.
* @param line the line in the source file.
* @param description textual description of the exception.
* @param code numerical error code.
*/
void void
init ( const char * file, init ( const char * file,
unsigned int line, unsigned int line,
const char * description, const char * description,
int code ) throw (); int code ) throw ();
/**
* De-initalize the object.
*/
void void
strip () throw (); strip () throw ();
@ -85,20 +112,30 @@ class Exception
public: public:
/**
* Default constructor.
*/
inline inline
Exception ( void ) throw () Exception ( void ) throw ()
{ {
init( 0, 0, 0, 0); init( 0, 0, 0, 0);
} }
/**
* Copy constructor.
*/
inline inline
Exception ( const Exception & e ) throw () Exception ( const Exception & e ) throw ()
{ {
init( e.file, e.line, e.description, e.code); init( e.file, e.line, e.description, e.code);
} }
/**
* Construct by a description and error code.
*
* @param description textual description of the exception.
* @param code numerical error code.
*/
inline inline
Exception ( const char * description, Exception ( const char * description,
int code = 0 ) throw () int code = 0 ) throw ()
@ -106,7 +143,14 @@ class Exception
init( 0, 0, description, code); init( 0, 0, description, code);
} }
/**
* Construct by source file information, a description and error code.
*
* @param file the source file the exception was thrown in.
* @param line the line in the source file.
* @param description textual description of the exception.
* @param code numerical error code.
*/
inline inline
Exception ( const char * file, Exception ( const char * file,
unsigned int line, unsigned int line,
@ -116,14 +160,35 @@ class Exception
init( file, line, description, code); init( file, line, description, code);
} }
/**
* Construct by source file information, a description and error code.
* The description is constructed from two strings, any of which
* may be NULL.
*
* @param file the source file the exception was thrown in.
* @param line the line in the source file.
* @param description1 textual description of the exception part 1.
* @param description2 textual description of the exception part 2.
* @param code numerical error code.
*/
Exception ( const char * file, Exception ( const char * file,
unsigned int line, unsigned int line,
const char * description1, const char * description1,
const char * description2, const char * description2,
int code = 0 ) throw (); int code = 0 ) throw ();
/**
* Construct by source file information, a description and error code.
* The description is constructed from three strings, any of
* which may be NULL.
*
* @param file the source file the exception was thrown in.
* @param line the line in the source file.
* @param description1 textual description of the exception part 1.
* @param description2 textual description of the exception part 2.
* @param description3 textual description of the exception part 3.
* @param code numerical error code.
*/
Exception ( const char * file, Exception ( const char * file,
unsigned int line, unsigned int line,
const char * description1, const char * description1,
@ -131,14 +196,21 @@ class Exception
const char * description3, const char * description3,
int code = 0 ) throw (); int code = 0 ) throw ();
/**
* Desctructor.
*/
inline inline
~Exception ( void ) throw () ~Exception ( void ) throw ()
{ {
strip(); strip();
} }
/**
* Assignment operator.
*
* @param e the Exception to assign this to.
* @return a reference to this Exception.
*/
inline Exception & inline Exception &
operator= ( const Exception & e ) throw () operator= ( const Exception & e ) throw ()
{ {
@ -150,33 +222,51 @@ class Exception
return *this; return *this;
} }
/**
* Return the textual description of the Exception.
*
* @return the textual description of the Exception.
*/
inline const char * inline const char *
getDescription( void ) const throw () getDescription( void ) const throw ()
{ {
return description; return description;
} }
/**
* Return the line number in the source file this Exception was
* thrown in.
*
* @return the line number in the source file this Exception was
* thrown in.
*/
inline unsigned int inline unsigned int
getLine ( void ) const throw () getLine ( void ) const throw ()
{ {
return line; return line;
} }
/**
* Return the source file this Exception was thrown in.
*
* @return the source file this Exception was thrown in.
*/
inline const char * inline const char *
getFile ( void ) const throw () getFile ( void ) const throw ()
{ {
return file; return file;
} }
/**
* Return the numerical code of the Exception.
*
* @return the numerical code of the Exception.
*/
inline int inline int
getCode ( void ) const throw () getCode ( void ) const throw ()
{ {
return code; return code;
} }
}; };
@ -185,9 +275,13 @@ class Exception
/* ====================================================== function prototypes */ /* ====================================================== function prototypes */
/*------------------------------------------------------------------------------ /**
* Print a Exception to an ostream * Print an Exception to an ostream.
*----------------------------------------------------------------------------*/ *
* @param os the output stream to print to.
* @param e the Exception to print.
* @return a reference to the supplied output stream.
*/
inline ostream & inline ostream &
operator<< ( ostream & os, operator<< ( ostream & os,
const Exception & e ) const Exception & e )
@ -206,6 +300,9 @@ operator<< ( ostream & os,
$Source$ $Source$
$Log$ $Log$
Revision 1.4 2000/11/11 12:33:13 darkeye
added kdoc-style documentation
Revision 1.3 2000/11/09 22:05:44 darkeye Revision 1.3 2000/11/09 22:05:44 darkeye
added multiple-string constructors added multiple-string constructors

View File

@ -9,10 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
File data output
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -27,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -311,6 +306,9 @@ FileSink :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/11 12:33:13 darkeye
added kdoc-style documentation
Revision 1.2 2000/11/05 14:08:27 darkeye Revision 1.2 2000/11/05 14:08:27 darkeye
changed builting to an automake / autoconf environment changed builting to an automake / autoconf environment

View File

@ -9,10 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
File data output
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -27,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#ifndef FILE_SINK_H #ifndef FILE_SINK_H
@ -52,29 +47,51 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* File data output
* *
*----------------------------------------------------------------------------*/ * @author $Author$
* @version $Revision$
*/
class FileSink : public Sink class FileSink : public Sink
{ {
private: private:
/**
* Name of the file represented by the FileSink.
*/
char * fileName; char * fileName;
/**
* Initialize the object.
*
* @param name name of the file to be represented by the object.
* @exception Exception
*/
void void
init ( const char * name ) throw ( Exception ); init ( const char * name ) throw ( Exception );
/**
* De-initialize the object.
*
* @exception Exception
*/
void void
strip ( void ) throw ( Exception ); strip ( void ) throw ( Exception );
protected: protected:
/**
* Low-level file descriptor for the file represented by this object.
*/
int fileDescriptor; int fileDescriptor;
/**
* Default constructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
FileSink ( void ) throw ( Exception ) FileSink ( void ) throw ( Exception )
{ {
@ -84,69 +101,135 @@ class FileSink : public Sink
public: public:
/**
* Constructor by a file name.
*
* @param name name of the file to be represented by the object.
* @exception Exception
*/
inline inline
FileSink( const char * name ) throw ( Exception ) FileSink( const char * name ) throw ( Exception )
{ {
init( name); init( name);
} }
/**
* Copy constructor.
*
* @param fsink the FileSink to copy.
* @exception Exception
*/
FileSink( const FileSink & fsink ) throw ( Exception ); FileSink( const FileSink & fsink ) throw ( Exception );
/**
* Destructor.
*
* @exception Exception
*/
inline virtual inline virtual
~FileSink( void ) throw ( Exception ) ~FileSink( void ) throw ( Exception )
{ {
strip(); strip();
} }
/**
* Assignment operator.
*
* @param fs the FileSink to assign to this object.
* @return a reference to this object.
* @exception Exception
*/
virtual FileSink & virtual FileSink &
operator= ( const FileSink & fs ) throw ( Exception ); operator= ( const FileSink & fs ) throw ( Exception );
/**
* Get the file name this FileSink represents.
*
* @return the file name this FileSink represents.
*/
inline const char * inline const char *
getFileName ( void ) const throw () getFileName ( void ) const throw ()
{ {
return fileName; return fileName;
} }
/**
* Check for the existence of the file this FileSink represents.
*
* @return true if the file exists, false otherwise.
*/
virtual bool virtual bool
exists ( void ) const throw (); exists ( void ) const throw ();
/**
* Create the file.
*
* @return true if creation was successful, false otherwise.
* @exception Exception
*/
virtual bool virtual bool
create ( void ) throw ( Exception ); create ( void ) throw ( Exception );
/**
* Open the file. Truncates the file.
*
* @return true if opening was successful, false otherwise.
* @exception Exception
*/
virtual bool virtual bool
open ( void ) throw ( Exception ); open ( void ) throw ( Exception );
/**
* Check if the FileSink is open.
*
* @return true if the FileSink is open, false otherwise.
*/
inline virtual bool inline virtual bool
isOpen ( void ) const throw () isOpen ( void ) const throw ()
{ {
return fileDescriptor != 0; return fileDescriptor != 0;
} }
/**
* Check if the FileSink is ready to accept data.
* Blocks until the specified time for data to be available.
*
* @param sec the maximum seconds to block.
* @param usec micro seconds to block after the full seconds.
* @return true if the Sink is ready to accept data, false otherwise.
* @exception Exception
*/
virtual bool virtual bool
canWrite ( unsigned int sec, canWrite ( unsigned int sec,
unsigned int usec ) throw ( Exception ); unsigned int usec ) throw ( Exception );
/**
* Write data to the FileSink.
*
* @param buf the data to write.
* @param len number of bytes to write from buf.
* @return the number of bytes written (may be less than len).
* @exception Exception
*/
virtual unsigned int virtual unsigned int
write ( const void * buf, write ( const void * buf,
unsigned int len ) throw ( Exception ); unsigned int len ) throw ( Exception );
/**
* This is a no-op in this FileSink.
*
* @exception Exception
*/
inline virtual void inline virtual void
flush ( void ) throw ( Exception ) flush ( void ) throw ( Exception )
{ {
} }
/**
* Close the FileSink.
*
* @exception Exception
*/
virtual void virtual void
close ( void ) throw ( Exception ); close ( void ) throw ( Exception );
}; };
@ -167,6 +250,9 @@ class FileSink : public Sink
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/11 12:33:13 darkeye
added kdoc-style documentation
Revision 1.2 2000/11/05 17:37:24 darkeye Revision 1.2 2000/11/05 17:37:24 darkeye
removed clone() functions removed clone() functions

View File

@ -9,10 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
Audio data input
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -27,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -129,6 +124,9 @@ PipeSink :: open ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.4 2000/11/11 12:33:13 darkeye
added kdoc-style documentation
Revision 1.3 2000/11/10 20:10:46 darkeye Revision 1.3 2000/11/10 20:10:46 darkeye
changed from non-blocking to blocking changed from non-blocking to blocking

View File

@ -9,10 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
FIFO pipe data output
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -27,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#ifndef PIPE_SINK_H #ifndef PIPE_SINK_H
@ -52,9 +47,12 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* FIFO pipe data output
* *
*----------------------------------------------------------------------------*/ * @author $Author$
* @version $Revision$
*/
class PipeSink : public FileSink class PipeSink : public FileSink
{ {
private: private:
@ -62,6 +60,11 @@ class PipeSink : public FileSink
protected: protected:
/**
* Default constructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
PipeSink ( void ) throw ( Exception ) PipeSink ( void ) throw ( Exception )
{ {
@ -71,41 +74,72 @@ class PipeSink : public FileSink
public: public:
/**
* Constructor by a pipe name.
*
* @param name name of the pipe to be represented by the object.
* @exception Exception
*/
inline inline
PipeSink ( const char * name ) throw ( Exception ) PipeSink ( const char * name ) throw ( Exception )
: FileSink( name ) : FileSink( name )
{ {
} }
/**
* Copy constructor.
*
* @param fsink the PipeSink to copy.
* @exception Exception
*/
inline inline
PipeSink ( const PipeSink & ps ) throw ( Exception ) PipeSink ( const PipeSink & ps ) throw ( Exception )
: FileSink( ps ) : FileSink( ps )
{ {
} }
/**
* Assignment operator.
*
* @param ps the PipeSink to assign to this object.
* @return a reference to this object.
* @exception Exception
*/
inline virtual PipeSink & inline virtual PipeSink &
operator= ( const PipeSink & fs ) throw ( Exception ) operator= ( const PipeSink & ps ) throw ( Exception )
{ {
if ( this != &fs ) { if ( this != &ps ) {
FileSink::operator=( fs ); FileSink::operator=( ps );
} }
return *this; return *this;
} }
/**
* Destructor.
*
* @exception Exception
*/
virtual inline virtual inline
~PipeSink( void ) throw ( Exception ) ~PipeSink( void ) throw ( Exception )
{ {
} }
/**
* Create the pipe.
*
* @return true if creation was successful, false otherwise.
* @exception Exception
*/
virtual bool virtual bool
create ( void ) throw ( Exception ); create ( void ) throw ( Exception );
/**
* Open the pipe.
*
* @return true if opening was successful, false otherwise.
* @exception Exception
*/
virtual bool virtual bool
open ( void ) throw ( Exception ); open ( void ) throw ( Exception );
}; };
@ -126,6 +160,9 @@ class PipeSink : public FileSink
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/11 12:33:13 darkeye
added kdoc-style documentation
Revision 1.2 2000/11/05 17:37:24 darkeye Revision 1.2 2000/11/05 17:37:24 darkeye
removed clone() functions removed clone() functions

View File

@ -9,32 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
Java-like object reference class
Objects used with this reference class have to be descandents
of class Referable
sample usage:
#include "Ref.h"
#include "Referable.h"
class A : public virtual Referable;
...
A * a = new A();
Ref<A> ref1 = a; // 1 reference to a
Ref<A> ref2 = ref1; // 2 references to a
ref1 = 0; // 1 reference to a
ref2 = 0; // at this point object a is destroyed
Based on Tima Saarinen's work,
http://gamma.nic.fi/~timosa/comp/refcount.html
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -49,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#ifndef REF_H #ifndef REF_H
@ -74,14 +47,46 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* Java-like object reference class.
* Objects used with this reference class have to be descandents
* of class Referable.
* *
*----------------------------------------------------------------------------*/ * sample usage:
*
* <pre>
* #include "Ref.h"
* #include "Referable.h"
*
* class A : public virtual Referable;
*
* ...
*
* A * a = new A();
* Ref<A> ref1 = a; // 1 reference to a
* Ref<A> ref2 = ref1; // 2 references to a
*
* ref1 = 0; // 1 reference to a
* ref2 = 0; // at this point object a is destroyed
* </pre>
*
* Based on Tima Saarinen's work,
* http://gamma.nic.fi/~timosa/comp/refcount.html
*
* @ref Referable
*
* @author $Author$
* @version $Revision$
*/
template <class T> template <class T>
class Ref class Ref
{ {
private: private:
/**
* The object referenced by this Ref.
* Must be a descandant of Referable.
*/
T* object; T* object;
@ -90,13 +95,21 @@ class Ref
public: public:
/**
* Default constructor.
*/
inline inline
Ref ( void ) throw () Ref ( void ) throw ()
{ {
object = NULL; object = NULL;
} }
/**
* Copy constructor.
*
* @param other the Ref to copy.
* @exception Exception
*/
inline inline
Ref ( const Ref<T> & other ) throw ( Exception ) Ref ( const Ref<T> & other ) throw ( Exception )
{ {
@ -104,7 +117,12 @@ class Ref
set( other.object); set( other.object);
} }
/**
* Constructor based on an object to reference.
*
* @param obj the object to reference.
* @exception Exception
*/
inline inline
Ref ( T * obj ) throw ( Exception ) Ref ( T * obj ) throw ( Exception )
{ {
@ -112,14 +130,22 @@ class Ref
obj->increaseReferenceCount(); obj->increaseReferenceCount();
} }
/**
* Destructor.
*
* @exception Exception
*/
inline virtual inline virtual
~Ref ( void ) throw ( Exception ) ~Ref ( void ) throw ( Exception )
{ {
set( 0 ); set( 0 );
} }
/**
* Operator overload to make the reference seem like a pointer.
*
* @return the pointer to the object referenced.
*/
inline T* inline T*
operator->() const throw () operator->() const throw ()
{ {
@ -130,14 +156,27 @@ class Ref
return object; return object;
} }
/**
* Assignment operator.
*
* @param other the Ref to assign to this one.
* @return a reference to this Ref.
* @exception Exception
*/
inline Ref<T> & inline Ref<T> &
operator= ( Ref<T> other ) throw ( Exception ) operator= ( Ref<T> other ) throw ( Exception )
{ {
set( other.object); set( other.object);
return this;
} }
/**
* Assignment operator.
*
* @param obj pointer to the object to assign to this Ref.
* @return a reference to this Ref.
* @exception Exception
*/
inline Ref<T> & inline Ref<T> &
operator= ( T* obj ) throw ( Exception ) operator= ( T* obj ) throw ( Exception )
{ {
@ -145,7 +184,13 @@ class Ref
return *this; return *this;
} }
/**
* Set the object referenced.
* Deletes the old referenced object is this was it's last reference.
*
* @param newobj pointer to the object to reference by this Ref.
* @exception Exception
*/
inline void inline void
set ( T* newobj ) throw ( Exception ) set ( T* newobj ) throw ( Exception )
{ {
@ -170,17 +215,16 @@ class Ref
object = newobj; object = newobj;
} }
/** /**
* Return object pointer. This method should be used with * Return object pointer. This method should be used with
* care because it breaks the encapsulation. * care because it breaks the encapsulation.
* Typically this method is needed for the method calls * Typically this method is needed for the method calls
* which require literal object pointer. * which require literal object pointer.
* *
* <P>It may not be bad idea to pass the <CODE>Ref</CODE> * It may not be bad idea to pass the Ref
* objects as method arguments.</P> * objects as method arguments.
* *
* @return Object pointer or <CODE>NULL</CODE>. * @return Object pointer or NULL.
*/ */
inline T* inline T*
get ( void ) const throw () get ( void ) const throw ()
@ -188,14 +232,26 @@ class Ref
return object; return object;
} }
/**
* Equality operator.
*
* @param other the Ref to compare this with.
* @return true is the two Refs refer to the same object,
* false otherwise.
*/
inline bool inline bool
operator== ( const Ref<T> & other ) const throw () operator== ( const Ref<T> & other ) const throw ()
{ {
return object == other.object; return object == other.object;
} }
/**
* Unequality operator.
*
* @param other the Ref to compare this with.
* @return false is the two Refs refer to the same object,
* true otherwise.
*/
inline bool inline bool
operator!= ( const Ref<T> & other ) const throw () operator!= ( const Ref<T> & other ) const throw ()
{ {
@ -218,8 +274,11 @@ class Ref
$Source$ $Source$
$Log$ $Log$
Revision 1.1 2000/11/05 10:05:54 darkeye Revision 1.2 2000/11/11 12:33:13 darkeye
Initial revision added kdoc-style documentation
Revision 1.1.1.1 2000/11/05 10:05:54 darkeye
initial version
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/

View File

@ -9,18 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
Base class for an object for which references can be made
with the reference class Ref (see Ref.h)
usage:
class A : public virtual Referable
{
...
};
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -35,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#ifndef REFERABLE_H #ifndef REFERABLE_H
@ -60,21 +47,45 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* Base class for an object for which references can be made
* with the reference class Ref.
* *
*----------------------------------------------------------------------------*/ * usage:
*
* <pre>
* class A : public virtual Referable
* {
* ...
* };
* </pre>
*
* @ref Ref
*
* @author $Author$
* @version $Revision$
*/
class Referable class Referable
{ {
private: private:
/**
* Number of references to the object.
*/
unsigned int referenceCount; unsigned int referenceCount;
/**
* Maximum number of references before an overflow occurs.
*/
static const static const
unsigned int maxCount = ~((unsigned int)0); unsigned int maxCount = ~((unsigned int)0);
protected: protected:
/**
* Default constructor.
*/
inline inline
Referable ( void ) throw () Referable ( void ) throw ()
{ {
@ -82,6 +93,11 @@ class Referable
} }
/**
* Desctructor.
*
* @exception Exception
*/
inline virtual inline virtual
~Referable ( void ) throw ( Exception ) ~Referable ( void ) throw ( Exception )
{ {
@ -95,6 +111,12 @@ class Referable
public: public:
/**
* Increase reference count.
*
* @return the new reference count.
* @exception Exception
*/
inline unsigned int inline unsigned int
increaseReferenceCount ( void ) throw ( Exception ) increaseReferenceCount ( void ) throw ( Exception )
{ {
@ -107,7 +129,12 @@ class Referable
return ++referenceCount; return ++referenceCount;
} }
/**
* Decrease reference count.
*
* @return the new reference count.
* @exception Exception
*/
inline unsigned int inline unsigned int
decreaseReferenceCount ( void ) throw ( Exception ) decreaseReferenceCount ( void ) throw ( Exception )
{ {
@ -119,7 +146,11 @@ class Referable
return --referenceCount; return --referenceCount;
} }
/**
* Get the reference count.
*
* @return the reference count.
*/
inline unsigned int inline unsigned int
getReferenceCount ( void ) const throw () getReferenceCount ( void ) const throw ()
{ {
@ -143,8 +174,11 @@ class Referable
$Source$ $Source$
$Log$ $Log$
Revision 1.1 2000/11/05 10:05:54 darkeye Revision 1.2 2000/11/11 12:33:13 darkeye
Initial revision added kdoc-style documentation
Revision 1.1.1.1 2000/11/05 10:05:54 darkeye
initial version
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/

View File

@ -9,10 +9,6 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
A general data sink
Copyright notice: Copyright notice:
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -27,8 +23,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
USA.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
#ifndef SINK_H #ifndef SINK_H
@ -42,6 +37,7 @@
/* ============================================================ include files */ /* ============================================================ include files */
#include "Referable.h" #include "Referable.h"
#include "Exception.h"
/* ================================================================ constants */ /* ================================================================ constants */
@ -52,9 +48,12 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* A general data sink
* *
*----------------------------------------------------------------------------*/ * @author $Author$
* @version $Revision$
*/
class Sink : public virtual Referable class Sink : public virtual Referable
{ {
private: private:
@ -62,20 +61,32 @@ class Sink : public virtual Referable
protected: protected:
/**
* Default constructor.
*/
inline inline
Sink ( void ) Sink ( void ) throw ()
{ {
} }
/**
* Copy constructor.
*
* @param sink the Sink to copy.
*/
inline inline
Sink ( const Sink & sink ) Sink ( const Sink & sink ) throw ()
{ {
} }
/**
* Assignment operator.
*
* @param sink the Sink to assign this to.
* @return a reference to this Sink.
*/
inline virtual Sink & inline virtual Sink &
operator= ( const Sink & sink ) operator= ( const Sink & sink ) throw ()
{ {
return *this; return *this;
} }
@ -83,36 +94,72 @@ class Sink : public virtual Referable
public: public:
/**
* Destructor.
*/
inline virtual inline virtual
~Sink ( void ) ~Sink ( void ) throw ()
{ {
} }
/**
* Open the sink.
*
* @return true if opening was successfull, false otherwise.
* @exception Exception
*/
virtual bool virtual bool
open ( void ) = 0; open ( void ) throw ( Exception ) = 0;
/**
* Check if a Sink is open.
*
* @return true if the Sink is open, false otherwise.
*/
virtual bool virtual bool
isOpen ( void ) const = 0; isOpen ( void ) const throw () = 0;
/**
* Check if the Sink is ready to accept data.
* Blocks until the specified time for data to be available.
*
* @param sec the maximum seconds to block.
* @param usec micro seconds to block after the full seconds.
* @return true if the Sink is ready to accept data, false otherwise.
* @exception Exception
*/
virtual bool virtual bool
canWrite ( unsigned int sec, canWrite ( unsigned int sec,
unsigned int usec ) = 0; unsigned int usec ) throw ( Exception ) = 0;
/**
* Write data to the Sink.
*
* @param buf the data to write.
* @param len number of bytes to write from buf.
* @return the number of bytes written (may be less than len).
* @exception Exception
*/
virtual unsigned int virtual unsigned int
write ( const void * buf, write ( const void * buf,
unsigned int len ) = 0; unsigned int len ) throw ( Exception ) = 0;
/**
* Flush all data that was written to the Sink to the underlying
* construct.
*
* @exception Exception
*/
virtual void virtual void
flush ( void ) = 0; flush ( void ) throw ( Exception ) = 0;
/**
* Close the Sink.
*
* @exception Exception
*/
virtual void virtual void
close ( void ) = 0; close ( void ) throw ( Exception ) = 0;
}; };
@ -131,8 +178,11 @@ class Sink : public virtual Referable
$Source$ $Source$
$Log$ $Log$
Revision 1.1 2000/11/05 10:05:54 darkeye Revision 1.2 2000/11/11 12:33:13 darkeye
Initial revision added kdoc-style documentation
Revision 1.1.1.1 2000/11/05 10:05:54 darkeye
initial version
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/