added kdoc-style documentation comments

This commit is contained in:
darkeye 2000-11-12 13:31:40 +00:00
parent 7418ed1299
commit 8b319e8584
10 changed files with 617 additions and 234 deletions

View File

@ -9,26 +9,21 @@
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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 AUDIO_SOURCE_H #ifndef AUDIO_SOURCE_H
@ -52,18 +47,40 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* * Audio data input
*----------------------------------------------------------------------------*/ *
* @author $Author$
* @version $Revision$
*/
class AudioSource : public Source class AudioSource : public Source
{ {
private: private:
/**
* Number of channels of the audio source
* (e.g. 1 for mono, 2 for stereo, etc.)
*/
unsigned int channel; unsigned int channel;
/**
* Samples per second (e.g. 44100 for 44.1kHz CD quality)
*/
unsigned int sampleRate; unsigned int sampleRate;
/**
* Bits per sample (e.g. 8 bits, 16 bits, etc.)
*/
unsigned int bitsPerSample; unsigned int bitsPerSample;
/**
* Initialize the object.
*
* @param sampleRate samples per second.
* @param bitsPerSample bits per sample.
* @param channel number of channels of the audio source.
* @exception Exception
*/
inline void inline void
init ( unsigned int sampleRate, init ( unsigned int sampleRate,
unsigned int bitsPerSample, unsigned int bitsPerSample,
@ -74,7 +91,11 @@ class AudioSource : public Source
this->channel = channel; this->channel = channel;
} }
/**
* De-initialize the object.
*
* @exception Exception
*/
inline void inline void
strip ( void ) throw ( Exception ) strip ( void ) throw ( Exception )
{ {
@ -83,6 +104,17 @@ class AudioSource : public Source
protected: protected:
/**
* Constructor.
* Because all values have defaults, this is also the default
* constructor.
*
* @param sampleRate samples per second (e.g. 44100 for 44.1kHz).
* @param bitsPerSample bits per sample (e.g. 16 bits).
* @param channel number of channels of the audio source
* (e.g. 1 for mono, 2 for stereo, etc.).
* @exception Exception
*/
inline inline
AudioSource ( unsigned int sampleRate = 44100, AudioSource ( unsigned int sampleRate = 44100,
unsigned int bitsPerSample = 16, unsigned int bitsPerSample = 16,
@ -92,7 +124,12 @@ class AudioSource : public Source
init ( sampleRate, bitsPerSample, channel); init ( sampleRate, bitsPerSample, channel);
} }
/**
* Copy Constructor.
*
* @param source the object to copy.
* @exception Exception
*/
inline inline
AudioSource ( const AudioSource & as ) throw ( Exception ) AudioSource ( const AudioSource & as ) throw ( Exception )
: Source( as ) : Source( as )
@ -100,13 +137,23 @@ class AudioSource : public Source
init ( as.sampleRate, as.bitsPerSample, as.channel); init ( as.sampleRate, as.bitsPerSample, as.channel);
} }
/**
* Destructor.
*
* @exception Exception
*/
virtual inline virtual inline
~AudioSource ( void ) throw ( Exception ) ~AudioSource ( void ) throw ( Exception )
{ {
} }
/**
* Assignment operator.
*
* @param as the object to assign to this one.
* @return a reference to this object.
* @exception Exception
*/
inline virtual AudioSource & inline virtual AudioSource &
operator= ( const AudioSource & as ) throw ( Exception ) operator= ( const AudioSource & as ) throw ( Exception )
{ {
@ -122,13 +169,22 @@ class AudioSource : public Source
public: public:
/**
* Get the number of channels for this AudioSource.
*
* @return the number of channels.
*/
inline unsigned int inline unsigned int
getChannel ( void ) const throw () getChannel ( void ) const throw ()
{ {
return channel; return channel;
} }
/**
* Get the sample rate per seconds for this AudioSource.
*
* @return the sample rate per seconds.
*/
inline unsigned int inline unsigned int
getSampleRate ( void ) const throw () getSampleRate ( void ) const throw ()
{ {
@ -136,6 +192,11 @@ class AudioSource : public Source
} }
/**
* Get the number of bits per sample for this AudioSource.
*
* @return the number of bits per sample.
*/
inline unsigned int inline unsigned int
getBitsPerSample ( void ) const throw () getBitsPerSample ( void ) const throw ()
{ {
@ -159,6 +220,9 @@ class AudioSource : public Source
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/12 13:31:40 darkeye
added kdoc-style documentation comments
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,26 +9,21 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
Data input from a file
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -261,6 +256,9 @@ FileSource :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/12 13:31:40 darkeye
added kdoc-style documentation comments
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,26 +9,21 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
Data input from a file
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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_SOURCE_H #ifndef FILE_SOURCE_H
@ -52,27 +47,51 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* A data source based on a file * A data source based on a file
*----------------------------------------------------------------------------*/ *
* @author $Author$
* @version $Revision$
*/
class FileSource : public Source class FileSource : public Source
{ {
private: private:
/**
* Name of the file represented by the FileSource.
*/
char * fileName; char * fileName;
int fileDescriptor;
/**
* 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;
/**
* Default constructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
FileSource ( void ) throw ( Exception ) FileSource ( void ) throw ( Exception )
{ {
@ -82,59 +101,117 @@ class FileSource : public Source
public: public:
/**
* Constructor by a file name.
*
* @param name name of the file to be represented by the object.
* @exception Exception
*/
inline inline
FileSource ( const char * name ) throw ( Exception ) FileSource ( const char * name ) throw ( Exception )
{ {
init( name); init( name);
} }
/**
* Copy constructor.
*
* @param fs the FileSource to copy.
* @exception Exception
*/
FileSource ( const FileSource & fs ) throw ( Exception ); FileSource ( const FileSource & fs ) throw ( Exception );
/**
* Destructor.
*
* @exception Exception
*/
inline inline
~FileSource ( void ) throw ( Exception ) ~FileSource ( void ) throw ( Exception )
{ {
strip(); strip();
} }
/**
* Assignment operator.
*
* @param fs the FileSource to assign to this object.
* @return a reference to this object.
* @exception Exception
*/
inline virtual FileSource & inline virtual FileSource &
operator= ( const FileSource & fs ) throw ( Exception ); operator= ( const FileSource & fs ) throw ( Exception );
/**
* Get the file name this FileSource represents.
*
* @return the file name this FileSource represents.
*/
inline virtual const char * inline virtual const char *
getFileName ( void ) const throw () getFileName ( void ) const throw ()
{ {
return fileName; return fileName;
} }
/**
* Check for the existence of the file this FileSource represents.
*
* @return true if the file exists, false otherwise.
*/
virtual bool virtual bool
exists ( void ) const throw (); exists ( void ) const throw ();
/**
* Open 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 FileSource is open.
*
* @return true if the FileSource 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 FileSource has data available.
* 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 FileSource has data to be read,
* false otherwise.
* @exception Exception
*/
virtual bool virtual bool
canRead ( unsigned int sec, canRead ( unsigned int sec,
unsigned int usec ) throw ( Exception ); unsigned int usec ) throw ( Exception );
/**
* Read from the FileSource.
*
* @param buf the buffer to read into.
* @param len the number of bytes to read into buf
* @return the number of bytes read (may be less than len).
* @exception Exception
*/
virtual unsigned int virtual unsigned int
read ( void * buf, read ( void * buf,
unsigned int len ) throw ( Exception ); unsigned int len ) throw ( Exception );
/**
* Close the FileSource.
*
* @exception Exception
*/
virtual void virtual void
close ( void ) throw ( Exception ); close ( void ) throw ( Exception );
}; };
@ -155,8 +232,11 @@ class FileSource : public Source
$Source$ $Source$
$Log$ $Log$
Revision 1.1 2000/11/05 10:05:51 darkeye Revision 1.2 2000/11/12 13:31:40 darkeye
Initial revision added kdoc-style documentation comments
Revision 1.1.1.1 2000/11/05 10:05:51 darkeye
initial version
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/

View File

@ -9,26 +9,21 @@
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -269,6 +264,9 @@ OssDspSource :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/12 13:31:40 darkeye
added kdoc-style documentation comments
Revision 1.2 2000/11/05 14:08:28 darkeye Revision 1.2 2000/11/05 14:08:28 darkeye
changed builting to an automake / autoconf environment changed builting to an automake / autoconf environment

View File

@ -9,26 +9,21 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
Audio data input from an OSS /dev/dsp-like device
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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 OSS_DSP_SOURCE_H #ifndef OSS_DSP_SOURCE_H
@ -52,37 +47,77 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* An audio input based on /dev/dsp-like raw devices * An audio input based on /dev/dsp-like raw devices
*----------------------------------------------------------------------------*/ *
* @author $Author$
* @version $Revision$
*/
class OssDspSource : public AudioSource class OssDspSource : public AudioSource
{ {
private: private:
/**
* The file name of the OSS DSP device (e.g. /dev/dsp or /dev/dsp0).
*/
char * fileName; char * fileName;
/**
* The low-level file descriptor of the OSS DSP device.
*/
int fileDescriptor; int fileDescriptor;
/**
* Indicates wether the low-level OSS DSP device is in a recording
* state.
*/
bool running; bool running;
protected: protected:
/**
* Default constructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
OssDspSource ( void ) throw ( Exception ) OssDspSource ( void ) throw ( Exception )
{ {
throw Exception( __FILE__, __LINE__); throw Exception( __FILE__, __LINE__);
} }
/**
* Initialize the object
*
* @param name the file name of the OSS DSP device.
* @exception Exception
*/
void void
init ( const char * name ) throw ( Exception ); init ( const char * name ) throw ( Exception );
/**
* De-iitialize the object
*
* @exception Exception
*/
void void
strip ( void ) throw ( Exception ); strip ( void ) throw ( Exception );
public: public:
/**
* Constructor.
*
* @param name the file name of the OSS DSP device
* (e.g. /dev/dsp or /dev/dsp0).
* @param sampleRate samples per second (e.g. 44100 for 44.1kHz).
* @param bitsPerSample bits per sample (e.g. 16 bits).
* @param channel number of channels of the audio source
* (e.g. 1 for mono, 2 for stereo, etc.).
* @exception Exception
*/
inline inline
OssDspSource ( const char * name, OssDspSource ( const char * name,
int sampleRate = 44100, int sampleRate = 44100,
@ -95,7 +130,12 @@ class OssDspSource : public AudioSource
init( name); init( name);
} }
/**
* Copy Constructor.
*
* @param source the object to copy.
* @exception Exception
*/
inline inline
OssDspSource ( const OssDspSource & ds ) throw ( Exception ) OssDspSource ( const OssDspSource & ds ) throw ( Exception )
: AudioSource( ds ) : AudioSource( ds )
@ -103,14 +143,24 @@ class OssDspSource : public AudioSource
init( ds.fileName); init( ds.fileName);
} }
/**
* Destructor.
*
* @exception Exception
*/
inline virtual inline virtual
~OssDspSource ( void ) throw ( Exception ) ~OssDspSource ( void ) throw ( Exception )
{ {
strip(); strip();
} }
/**
* Assignment operator.
*
* @param ds the object to assign to this one.
* @return a reference to this object.
* @exception Exception
*/
inline virtual OssDspSource & inline virtual OssDspSource &
operator= ( const OssDspSource & ds ) throw ( Exception ) operator= ( const OssDspSource & ds ) throw ( Exception )
{ {
@ -122,28 +172,64 @@ class OssDspSource : public AudioSource
return *this; return *this;
} }
/**
* Open the OssDspSource.
* This does not put the OSS DSP device into recording mode.
* To start getting samples, call either canRead() or read().
*
* @return true if opening was successful, false otherwise
* @exception Exception
*
* @see #canRead
* @see #read
*/
virtual bool virtual bool
open ( void ) throw ( Exception ); open ( void ) throw ( Exception );
/**
* Check if the OssDspSource is open.
*
* @return true if the OssDspSource 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 OssDspSource can be read from.
* Blocks until the specified time for data to be available.
* Puts the OSS DSP device into recording mode.
*
* @param sec the maximum seconds to block.
* @param usec micro seconds to block after the full seconds.
* @return true if the OssDspSource is ready to be read from,
* false otherwise.
* @exception Exception
*/
virtual bool virtual bool
canRead ( unsigned int sec, canRead ( unsigned int sec,
unsigned int usec ) throw ( Exception ); unsigned int usec ) throw ( Exception );
/**
* Read from the OssDspSource.
* Puts the OSS DSP device into recording mode.
*
* @param buf the buffer to read into.
* @param len the number of bytes to read into buf
* @return the number of bytes read (may be less than len).
* @exception Exception
*/
virtual unsigned int virtual unsigned int
read ( void * buf, read ( void * buf,
unsigned int len ) throw ( Exception ); unsigned int len ) throw ( Exception );
/**
* Close the OssDspSource.
*
* @exception Exception
*/
virtual void virtual void
close ( void ) throw ( Exception ); close ( void ) throw ( Exception );
}; };
@ -164,6 +250,9 @@ class OssDspSource : public AudioSource
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/12 13:31:40 darkeye
added kdoc-style documentation comments
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,26 +9,21 @@
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -110,6 +105,9 @@ PipeSource :: create ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/12 13:31:40 darkeye
added kdoc-style documentation comments
Revision 1.2 2000/11/05 14:08:28 darkeye Revision 1.2 2000/11/05 14:08:28 darkeye
changed builting to an automake / autoconf environment changed builting to an automake / autoconf environment

View File

@ -11,7 +11,6 @@
Abstract : Abstract :
FIFO pipe data input
Copyright notice: Copyright notice:
@ -52,9 +51,12 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* * FIFO pipe data input
*----------------------------------------------------------------------------*/ *
* @author $Author$
* @version $Revision$
*/
class PipeSource : public FileSource class PipeSource : public FileSource
{ {
private: private:
@ -62,6 +64,11 @@ class PipeSource : public FileSource
protected: protected:
/**
* Default constructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
PipeSource ( void ) throw ( Exception ) PipeSource ( void ) throw ( Exception )
{ {
@ -71,37 +78,63 @@ class PipeSource : public FileSource
public: public:
/**
* Constructor by a file name.
*
* @param name name of the file to be represented by the object.
* @exception Exception
*/
inline inline
PipeSource ( const char * name ) throw ( Exception ) PipeSource ( const char * name ) throw ( Exception )
: FileSource( name ) : FileSource( name )
{ {
} }
/**
* Copy constructor.
*
* @param ps the PipeSource to copy.
* @exception Exception
*/
inline inline
PipeSource ( const PipeSource & ps ) throw ( Exception ) PipeSource ( const PipeSource & ps ) throw ( Exception )
: FileSource( ps ) : FileSource( ps )
{ {
} }
/**
* Assignment operator.
*
* @param ps the PipeSource to assign to this object.
* @return a reference to this object.
* @exception Exception
*/
inline virtual PipeSource & inline virtual PipeSource &
operator= ( const PipeSource & fs ) throw ( Exception ) operator= ( const PipeSource & ps ) throw ( Exception )
{ {
if ( this != &fs ) { if ( this != &ps ) {
FileSource::operator=( fs ); FileSource::operator=( ps );
} }
return *this; return *this;
} }
/**
* Destructor.
*
* @exception Exception
*/
virtual inline virtual inline
~PipeSource( void ) throw ( Exception ) ~PipeSource( 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 );
}; };
@ -122,6 +155,9 @@ class PipeSource : public FileSource
$Source$ $Source$
$Log$ $Log$
Revision 1.3 2000/11/12 13:31:40 darkeye
added kdoc-style documentation comments
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,26 +9,21 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
A general data source
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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 SOURCE_H #ifndef SOURCE_H
@ -53,27 +48,46 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* * A general data source
*----------------------------------------------------------------------------*/ *
* @author $Author$
* @version $Revision$
*/
class Source : public virtual Referable class Source : public virtual Referable
{ {
private: private:
protected: protected:
/**
* Default Constructor.
*
* @exception Exception
*/
inline inline
Source ( void ) throw ( Exception ) Source ( void ) throw ( Exception )
{ {
} }
/**
* Copy Constructor.
*
* @param source the object to copy.
* @exception Exception
*/
inline inline
Source ( const Source & source ) throw ( Exception ) Source ( const Source & source ) throw ( Exception )
{ {
} }
/**
* Assignment operator.
*
* @param source the object to assign to this one.
* @return a reference to this object.
* @exception Exception
*/
inline virtual Source & inline virtual Source &
operator= ( const Source & source ) throw ( Exception ) operator= ( const Source & source ) throw ( Exception )
{ {
@ -83,30 +97,64 @@ class Source : public virtual Referable
public: public:
/**
* Destructor.
*
* @exception Exception
*/
inline virtual inline virtual
~Source ( void ) throw ( Exception ) ~Source ( void ) throw ( Exception )
{ {
} }
/**
* Open the Source.
*
* @return true if opening was successful, false otherwise
* @exception Exception
*/
virtual bool virtual bool
open ( void ) throw ( Exception ) = 0; open ( void ) throw ( Exception ) = 0;
/**
* Check if the Source is open.
*
* @return true if the Source is open, false otherwise.
*/
virtual bool virtual bool
isOpen ( void ) const throw () = 0; isOpen ( void ) const throw () = 0;
/**
* Check if the Source can be read from.
* 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 Source is ready to be read from,
* false otherwise.
* @exception Exception
*/
virtual bool virtual bool
canRead ( unsigned int sec, canRead ( unsigned int sec,
unsigned int usec ) throw ( Exception ) = 0; unsigned int usec ) throw ( Exception ) = 0;
/**
* Read from the Source.
*
* @param buf the buffer to read into.
* @param len the number of bytes to read into buf
* @return the number of bytes read (may be less than len).
* @exception Exception
*/
virtual unsigned int virtual unsigned int
read ( void * buf, read ( void * buf,
unsigned int len ) throw ( Exception ) = 0; unsigned int len ) throw ( Exception ) = 0;
/**
* Close the Source.
*
* @exception Exception
*/
virtual void virtual void
close ( void ) throw ( Exception ) = 0; close ( void ) throw ( Exception ) = 0;
}; };
@ -127,8 +175,11 @@ class Source : public virtual Referable
$Source$ $Source$
$Log$ $Log$
Revision 1.1 2000/11/05 10:05:54 darkeye Revision 1.2 2000/11/12 13:31:40 darkeye
Initial revision added kdoc-style documentation comments
Revision 1.1.1.1 2000/11/05 10:05:54 darkeye
initial version
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/

View File

@ -9,26 +9,21 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
Widely used utilities
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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.
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -191,6 +186,9 @@ Util :: strToL( const char * str,
$Source$ $Source$
$Log$ $Log$
Revision 1.5 2000/11/12 13:31:40 darkeye
added kdoc-style documentation comments
Revision 1.4 2000/11/09 22:04:33 darkeye Revision 1.4 2000/11/09 22:04:33 darkeye
added functions strLen strCpy and strCat added functions strLen strCpy and strCat

View File

@ -9,26 +9,21 @@
Author : $Author$ Author : $Author$
Location : $Source$ Location : $Source$
Abstract :
Widely used utilities
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
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
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 UTIL_H #ifndef UTIL_H
@ -52,9 +47,22 @@
/* =============================================================== data types */ /* =============================================================== data types */
/*------------------------------------------------------------------------------ /**
* Widely used utilities.
* This class can not be instantiated, but contains useful (?) static
* functions.
*
* Typical usage:
*
* <pre>
* #include "Util.h"
* *
*----------------------------------------------------------------------------*/ * char * str = Util::strDup( otherStr);
* </pre>
*
* @author $Author$
* @version $Revision$
*/
class Util class Util
{ {
private: private:
@ -62,29 +70,47 @@ class Util
protected: protected:
/**
* Default constructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
Util ( void ) throw ( Exception ) Util ( void ) throw ( Exception )
{ {
throw Exception( __FILE__, __LINE__); throw Exception( __FILE__, __LINE__);
} }
/**
* Copy constructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
Util ( const Util & e ) throw ( Exception ) Util ( const Util & e ) throw ( Exception )
{ {
throw Exception( __FILE__, __LINE__); throw Exception( __FILE__, __LINE__);
} }
/**
* Destructor. Always throws an Exception.
*
* @exception Exception
*/
inline inline
~Util ( void ) throw ( Exception ) ~Util ( void ) throw ( Exception )
{ {
throw Exception( __FILE__, __LINE__); throw Exception( __FILE__, __LINE__);
} }
/**
* Assignment operator. Always throws an Exception.
*
* @param u the object to assign to this one.
* @exception Exception
*/
inline Util & inline Util &
operator= ( const Util & e ) throw ( Exception ) operator= ( const Util & u ) throw ( Exception )
{ {
throw Exception( __FILE__, __LINE__); throw Exception( __FILE__, __LINE__);
} }
@ -93,29 +119,71 @@ class Util
public: public:
/**
* Determine a C string's length.
*
* @param str a zero-terminated C string.
* @return length of str
* @exception Exception
*/
static unsigned int static unsigned int
strLen ( const char * str ) throw ( Exception ); strLen ( const char * str ) throw ( Exception );
/**
* Copy a C string into another.
*
* @param dest place for the copy. Storage size must be at least
* Util::strLen(src) + 1 long.
* @param str the string to copy.
* @exception Exception
*/
static void static void
strCpy ( char * dest, strCpy ( char * dest,
const char * src ) throw ( Exception ); const char * src ) throw ( Exception );
/**
* Concatenate a string to another's end.
*
* @param dest the string to concatenate to.
* Storage size of dest must be at least
* Util::strLen(dest) + Util::strLen(src) + 1 long.
* @param str the string to concatenate.
* @exception Exception
*/
static void static void
strCat ( char * dest, strCat ( char * dest,
const char * src ) throw ( Exception ); const char * src ) throw ( Exception );
/**
* Duplicate a string by allocating space with new[].
* The returned string must be freed with delete[].
*
* @param str the string to duplicate.
* @exception Exception
*/
static char * static char *
strDup ( const char * str ) throw ( Exception ); strDup ( const char * str ) throw ( Exception );
/**
* Determine wether two string are equal.
*
* @param str1 one of the strings.
* @param str2 the other string.
* @return true if the two strings are equal, false othersize.
* @exception Exception
*/
static bool static bool
strEq ( const char * str1, strEq ( const char * str1,
const char * str2 ) throw ( Exception ); const char * str2 ) throw ( Exception );
/**
* Convert a string to long.
*
* @param str the string to convert.
* @param base numeric base of number in str.
* @return the value of str as a long int
* @exception Exception
*/
static long int static long int
strToL ( const char * str, strToL ( const char * str,
int base = 10 ) throw ( Exception ); int base = 10 ) throw ( Exception );
@ -137,6 +205,9 @@ class Util
$Source$ $Source$
$Log$ $Log$
Revision 1.4 2000/11/12 13:31:40 darkeye
added kdoc-style documentation comments
Revision 1.3 2000/11/09 22:04:33 darkeye Revision 1.3 2000/11/09 22:04:33 darkeye
added functions strLen strCpy and strCat added functions strLen strCpy and strCat