Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/root/src/subsynth/syn/Builder/SubsynthInstrumentBuilder.h

Go to the documentation of this file.
00001    
00002 /****************** <SYN heading BEGIN do not edit this line> *****************
00003  *
00004  * subsynth - modular audio synthesizer
00005  * subsynth is (C) Copyright 2001-2002 by Kevin Meinert
00006  *
00007  * Original Author: Kevin Meinert
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public
00020  * License along with this library; if not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022  * Boston, MA 02111-1307, USA.
00023  *
00024  * -----------------------------------------------------------------
00025  * File:          $RCSfile: SubsynthInstrumentBuilder.h,v $
00026  * Date modified: $Date: 2002/04/15 05:55:22 $
00027  * Version:       $Revision: 1.4 $
00028  * -----------------------------------------------------------------
00029  *
00030  ****************** <SYN heading END do not edit this line> ******************/
00031 
00032 #ifndef SYN_SUBSYNTH_INSTRUMENT_BUILDER
00033 #define SYN_SUBSYNTH_INSTRUMENT_BUILDER
00034 
00035 #include <string>
00036 #include <map>
00037 #include <xmlpp/xmlpp.h>
00038 #include <syn/Core/Module.h>
00039 #include <syn/Util/Singleton.h>
00040 #include <syn/Module/InstrumentModule.h>
00041 #include <syn/Builder/InstrumentBuilder.h>
00042 
00043 
00044 namespace syn
00045 {
00052    class SubsynthInstrumentBuilder : public InstrumentBuilder
00053    {
00054    public:
00059       virtual Module* create( std::string filename )
00060       {
00061          xmlpp::XMLContextPtr ctx( new xmlpp::XMLContext );
00062          xmlpp::XMLDocument doc( ctx );
00063 
00064          // load a xml document from a file
00065          try
00066          {
00067             doc.load_file( filename );
00068          }
00069          catch (xmlpp::xmlerror e)
00070          {
00071             std::cerr << "Error: " << e.get_string() << std::endl;
00072             if (e.get_info().size())
00073             {
00074                std::cerr << "File: " << e.get_info() << std::endl;
00075             }
00076             if (e.get_error() != xmlpp::xml_filename_invalid &&
00077                 e.get_error() != xmlpp::xml_file_access)
00078             {
00079                //e.show_error( ctx );
00080                //e.show_line( ctx, filename );
00081             }
00082             return false;
00083          }
00084 
00085          std::cerr << "Loaded Configuration: " << filename << std::endl;
00086 
00087          xmlpp::XMLNodeList nl = doc.getChild( "gameinput" )->getChildren();
00088          xmlpp::XMLNodeListIterator it = nl.begin();
00089          while (it != nl.end())
00090          {
00091             //std::cerr << "in name: " << (*it)->name() << std::endl;
00092             try
00093             {
00094                xmlpp::XMLAttributes& attr = (*it)->get_attrmap();
00095                //std::cout << "attr: " << attr.get( "action" ) << "\n" << std::flush;
00096                //std::cout << "attr: " << attr.get( "device" ) << "\n" << std::flush;
00097                //std::cout << "attr: " << attr.get( "input" ) << "\n" << std::flush;
00098             }
00099             catch (xmlpp::xmlerror e)
00100             {
00101                std::cerr << "Error: " << e.get_string() << std::endl;
00102                it++;
00103                continue;
00104             }
00105             it++;
00106          }
00107       }
00108    };
00109 
00110 } // end namespace
00111 
00112 #endif

Generated at Mon Apr 15 09:26:06 2002 for subsynth by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001