Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

FileCast.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 
00003    Copyright (c) 2000 Tyrell Corporation. All rights reserved.
00004 
00005    Tyrell DarkIce
00006 
00007    File     : FileCast.h
00008    Version  : $Revision: 1.1 $
00009    Author   : $Author: darkeye $
00010    Location : $Source: /cvsroot/darkice/darkice/src/FileCast.h,v $
00011    
00012    Copyright notice:
00013 
00014     This program is free software; you can redistribute it and/or
00015     modify it under the terms of the GNU General Public License  
00016     as published by the Free Software Foundation; either version 2
00017     of the License, or (at your option) any later version.
00018    
00019     This program is distributed in the hope that it will be useful,
00020     but WITHOUT ANY WARRANTY; without even the implied warranty of 
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
00022     GNU General Public License for more details.
00023    
00024     You should have received a copy of the GNU General Public License
00025     along with this program; if not, write to the Free Software
00026     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00027 
00028 ------------------------------------------------------------------------------*/
00029 #ifndef FILE_CAST_H
00030 #define FILE_CAST_H
00031 
00032 #ifndef __cplusplus
00033 #error This is a C++ include file
00034 #endif
00035 
00036 
00037 /* ============================================================ include files */
00038 
00039 #include "Ref.h"
00040 #include "Sink.h"
00041 #include "CastSink.h"
00042 #include "FileSink.h"
00043 #include "FileCast.h"
00044 
00045 
00046 /* ================================================================ constants */
00047 
00048 
00049 /* =================================================================== macros */
00050 
00051 
00052 /* =============================================================== data types */
00053 
00060 class FileCast : public CastSink
00061 {
00062     private:
00063 
00067         Ref<FileSink>       targetFile;
00068 
00075         inline void
00076         init (  FileSink          * targetFile )
00077                                                     throw ( Exception )
00078         {
00079             this->targetFile = targetFile;
00080         }
00081 
00087         inline void
00088         strip ( void )                              throw ( Exception )
00089         {
00090             if ( isOpen() ) {
00091                 close();
00092             }
00093         }
00094 
00095 
00096     protected:
00097 
00103         inline
00104         FileCast ( void )                            throw ( Exception )
00105         {
00106             throw Exception( __FILE__, __LINE__);
00107         }
00108 
00116         inline virtual bool
00117         sendLogin ( void )              throw ( Exception )
00118         {
00119             return true;
00120         }
00121 
00122 
00123     public:
00124 
00131         inline
00132         FileCast (  FileSink          * targetFile )
00133                                                         throw ( Exception )
00134                 : CastSink( 0, 0, 0)
00135         {
00136             init( targetFile );
00137         }
00138 
00144         inline
00145         FileCast(   const FileCast &    cs )        throw ( Exception )
00146         {
00147             init( targetFile.get() );
00148         }
00149 
00155         inline virtual
00156         ~FileCast( void )                           throw ( Exception )
00157         {
00158             strip();
00159         }
00160 
00168         inline virtual FileCast &
00169         operator= ( const FileCast &    cs )        throw ( Exception )
00170         {
00171             if ( this != &cs ) {
00172                 strip();
00173                 init( targetFile.get() );
00174             }
00175             return *this;
00176         }
00177 
00184         virtual bool
00185         open ( void )                               throw ( Exception );
00186 
00192         inline virtual bool
00193         isOpen ( void ) const                       throw ()
00194         {
00195             return targetFile->isOpen();
00196         }
00197 
00208         inline virtual bool
00209         canWrite (     unsigned int    sec,
00210                        unsigned int    usec )       throw ( Exception )
00211         {
00212             return targetFile->canWrite( sec, usec);
00213         }
00214 
00223         inline virtual unsigned int
00224         write (        const void    * buf,
00225                        unsigned int    len )        throw ( Exception )
00226         {
00227             return targetFile->write( buf, len);
00228         }
00229 
00235         inline virtual void
00236         flush ( void )                              throw ( Exception )
00237         {
00238             return targetFile->flush();
00239         }
00240 
00246         inline virtual void
00247         close ( void )                              throw ( Exception )
00248         {
00249             return targetFile->close();
00250         }
00251 
00252 };
00253 
00254 
00255 /* ================================================= external data structures */
00256 
00257 
00258 /* ====================================================== function prototypes */
00259 
00260 
00261 
00262 #endif  /* FILE_CAST_H */
00263 
00264 
00265 /*------------------------------------------------------------------------------
00266  
00267   $Source: /cvsroot/darkice/darkice/src/FileCast.h,v $
00268 
00269   $Log: FileCast.h,v $
00270   Revision 1.1  2002/02/28 09:49:25  darkeye
00271   added possibility to save the encoded stream to a local file only
00272   (no streaming server needed)
00273 
00274 
00275   
00276 ------------------------------------------------------------------------------*/
00277 

Generated on Fri May 19 15:36:48 2006 for DarkIce by  doxygen 1.4.4