00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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