/********************************************************************** * * * Copyright (c) 2003 INFN - Sezione di Napoli * * * * For more information (including a list of authors) see * * the README file * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this library (see file COPYING); if not, write to the * * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * * Boston, MA 02111-1307 USA, or contact the authors. * * * **********************************************************************/ #include #include #include using namespace std; #include "makeHeader.h" struct makeHeader_Tuples : makeHeader { makeHeader_Tuples( ostream& out, int n ) : makeHeader ( out ) { copyrightNotice(); head( "TUPLES_H" ); _out << "#include \"boost/mpl/vector.hpp\"\n" << "#include \"boost/mpl/fold_backward.hpp\"\n" << "#include \"boost/tuple/tuple.hpp\"\n" << "#include \"boost/tuple/tuple_io.hpp\"\n"; ns( "Pdf" ); _out << "template< typename typelist >\n" << "struct tuple_from_typelist : boost::mpl::fold_backward< typelist,\n" << " boost::tuples::null_type,\n" << " boost::tuples::cons< boost::mpl::_2, boost::mpl::_1 > > { };\n\n"; _out << "template\n" << "struct Types { };\n\n"; _out << "template::value >\n" << "struct tuple_adapter {\n" << "};\n\n"; _out << "// partial specialization\n\n"; for ( int i = 1; i <= n; i ++ ) { _out << "template\n" << "struct Types {\n" << " typedef typename boost::mpl::vector<\n"; list ( " typename Rnd::arg", i, "", ",\n" ); _out << "\n" << " > type;\n"; _out << "};\n\n"; } for ( int i = 1; i <= n; i ++ ) { _out << "template\n" << "struct tuple_adapter {\n" << " template\n" << " static void generate( const Generator& g, container& c ) {\n" << " g.generate( \n"; list ( " boost::get<", i, ">( c )", ",\n" ); _out << "\n" << " );\n"; _out << " }\n"; _out << " template\n" << " static double evaluate( const Pdf& p, const container& c ) {\n" << " return p( \n"; list ( " boost::get<", i, ">( c )", ",\n" ); _out << "\n" << " );\n"; _out << " }\n"; _out << "};\n\n"; } foot(); } }; int main( int argc, char ** argv ) { const char * header ="Tuples.h"; if ( argc == 2 ) { cout << " generating header file " << header << endl; istringstream str( argv[ 1 ] ); int n; str >> n; cout << " maximum numger of arguments for Pdf's is " << n << endl; ofstream file( header ); makeHeader_Tuples( file, n ); return 0; } cout << "usage: " << argv[ 0 ] << " \n" << " : maximum number of pdf arguments" << endl; return 0; }