# make_genotype_MyStruct.h

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 //-----------------------------------------------------------------------------
    00004 // make_genotype.h
    00005 // (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
    00006 /*
    00007     This library is free software; you can redistribute it and/or
    00008     modify it under the terms of the GNU Lesser General Public
    00009     License as published by the Free Software Foundation; either
    00010     version 2 of the License, or (at your option) any later version.
    00011
    00012     This library is distributed in the hope that it will be useful,
    00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015     Lesser General Public License for more details.
    00016
    00017     You should have received a copy of the GNU Lesser General Public
    00018     License along with this library; if not, write to the Free Software
    00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00020
    00021     Contact: todos@geneura.ugr.es, http://geneura.ugr.es
    00022              Marc.Schoenauer@polytechnique.fr
    00023              mkeijzer@dhi.dk
    00024  */
    00025 //-----------------------------------------------------------------------------
    00026
    00027 #ifndef _make_genotype_h
    00028 #define _make_genotype_h
    00029
    00030 #include <eoMyStruct.h>
    00031 #include <eoMyStructInit.h>
    00032   // also need the parser and param includes
    00033 #include <utils/eoParser.h>
    00034 #include <utils/eoState.h>
    00035
    00036
    00037 /*
    00038  * This fuction does the create an eoInit<eoMyStruct>
    00039  *
    00040  * It could be here tempatized only on the fitness, as it can be used
    00041  * to evolve structures with any fitness.
    00042  * However, for consistency reasons, it was finally chosen, as in
    00043  * the rest of EO, to templatize by the full EOT, as this eventually
    00044  * allows to choose the type of genotype at run time (see in es dir)
    00045  *
    00046  * It returns an eoInit<EOT> that can later be used to initialize
    00047  * the population (see make_pop.h).
    00048  *
    00049  * It uses a parser (to get user parameters) and a state (to store the memory)
    00050  * the last argument is to disambiguate the call upon different instanciations.
    00051  *
    00052  * WARNING: that last argument will generally be the result of calling
    00053  *          the default ctor of EOT, resulting in most cases in an EOT
    00054  *          that is ***not properly initialized***
    00055 */
    00056
    00057 template <class EOT>
    00058 eoInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT)
    00059 {
    00060   // read any useful parameter here from the parser
    00061   // the param itself will belong to the parser (as far as memory is concerned)
    00062
    00063   //    paramType & param = _parser.createParam(deafultValue, "Keyword", "Comment to appear in help and status", 'c',"Section of status file").value();
    00064
    00065   // Then built the initializer - a pointer, stored in the eoState
    00066   eoInit<EOT>* init = new eoMyStructInit<EOT> /* ( param ) */ ;
    00067   // store in state
    00068   _state.storeFunctor(init);
    00069   // and return a reference
    00070   return *init;
    00071 }
    00072
    00073 #endif