H3DSoundFileNode.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00027 //
00029 #ifndef __H3DSOUNDFILENODE_H__
00030 #define __H3DSOUNDFILENODE_H__
00031 
00032 #include "H3DSoundStreamNode.h"
00033 #include <list>
00034 
00035 namespace H3D {
00036 
00046   class H3DAPI_API H3DSoundFileNode : public H3DSoundStreamNode {
00047   public:
00049     typedef H3DSoundFileNode*( *CreateNodeFunc)(); 
00050 
00052     typedef bool ( *SupportsFileFunc)( const string &url ); 
00053     
00054     template< class N >
00055     static H3DSoundFileNode *newSoundFileNode() { return new N; };
00056 
00058     struct H3DAPI_API FileReaderRegistration{
00059     public:
00061       FileReaderRegistration( const string &_name,
00062                               CreateNodeFunc _create, 
00063                               SupportsFileFunc _supports ):
00064       name( _name ),
00065       create_func( _create ),
00066       supports_func( _supports ) {
00067         if( !H3DSoundFileNode::initialized ) {
00068           H3DSoundFileNode::registered_file_readers = 
00069             new list< FileReaderRegistration >;
00070           initialized = true;
00071         }
00072         H3DSoundFileNode::registerFileReader( *this );
00073       }
00074 
00075       string name;
00076       CreateNodeFunc create_func;
00077       SupportsFileFunc supports_func;
00078     };
00079 
00082     virtual unsigned int load( const string &_url ) = 0;
00083     
00087     static H3DSoundFileNode *getSupportedFileReader( const string &url );
00088 
00095     static void registerFileReader( const string &name,
00096                                     CreateNodeFunc create, 
00097                                     SupportsFileFunc supports ) {
00098       registerFileReader( FileReaderRegistration( name, create, supports ) );
00099     }
00100 
00103     static void registerFileReader( const FileReaderRegistration &fr ) {
00104       registered_file_readers->push_back( fr );
00105     }
00106 
00107   protected:
00108     static list< FileReaderRegistration > *registered_file_readers;
00109     static bool initialized;
00110   };
00111 }
00112 
00113 #endif

Generated on Thu Aug 24 12:38:33 2006 for H3D API by  doxygen 1.4.5