GRALESHELL

cmdinvert.h

00001 /*
00002 
00003   This file is a part of GRALESHELL, a program to facilitate the simulation
00004   and inversion of gravitational lenses, based on the GRALE library.
00005 
00006   Copyright (C) 2008-2012 Jori Liesenborgs
00007 
00008   Contact: jori.liesenborgs@gmail.com
00009   
00010   This program is free software; you can redistribute it and/or modify
00011   it under the terms of the GNU General Public License as published by
00012   the Free Software Foundation; either version 2 of the License, or
00013   (at your option) any later version.
00014   
00015   This program is distributed in the hope that it will be useful,
00016   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018   GNU General Public License for more details.
00019   
00020   You should have received a copy of the GNU General Public License
00021   along with this program; if not, write to the Free Software
00022   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023   
00024 */
00025 
00026 #ifndef CMDINVERT_H
00027 
00028 #define CMDINVERT_H
00029 
00030 #include <shellp/shellcommand.h>
00031 #include <shellp/shellcmdstringarg.h>
00032 #include <shellp/shellcmdrealarg.h>
00033 #include <shellp/shellcmdintarg.h>
00034 #include <shellp/shellcmdboolarg.h>
00035 
00036 namespace mogal
00037 {
00038         class GeneticAlgorithm;
00039         class GAFactoryParams;
00040         class GAFactory;
00041 }
00042 
00043 class CmdInvertBase : public shellp::ShellCommand
00044 {
00045 public:
00046         CmdInvertBase(const std::string &cmdname);
00047         ~CmdInvertBase();
00048 protected:
00049         bool GetModuleDirectory(std::string &moduledir);
00050         bool ProcessSolution(mogal::GeneticAlgorithm &ga);
00051         mogal::GeneticAlgorithm *GetGeneticAlgorithm();
00052 };
00053 
00054 class CmdInvertGridBase : public CmdInvertBase
00055 {
00056 public:
00057         CmdInvertGridBase(const std::string &cmdname);
00058         ~CmdInvertGridBase();
00059 protected:
00060         void AddDefaultArguments();
00061         mogal::GAFactoryParams *GetFactoryParameters();
00062         bool GetModuleName(std::string &modulename);
00063         int GetPopulationSize()                                                         { return popsizearg->getValue(); }
00064 private:
00065         shellp::ShellCmdRealArg *Ddarg;
00066         shellp::ShellCmdRealArg *m_pZArg;
00067         shellp::ShellCmdStringArg *invtypearg;
00068         shellp::ShellCmdIntArg *popsizearg;
00069         shellp::ShellCmdIntArg *maxgenarg;
00070         shellp::ShellCmdRealArg *plumwidtharg;
00071         shellp::ShellCmdBoolArg *adjustweights;
00072         shellp::ShellCmdStringArg *basisarg;
00073         shellp::ShellCmdBoolArg *m_pAllowNegativeArg;
00074         shellp::ShellCmdBoolArg *m_pUseBaseLensArg;
00075         shellp::ShellCmdRealArg *m_pMassScaleArg;
00076         shellp::ShellCmdStringArg *m_pSearchSheetArg;
00077 };
00078 
00079 class CmdInvertGridLocal : public CmdInvertGridBase
00080 {
00081 public:
00082         CmdInvertGridLocal(const std::string &cmdname);
00083         ~CmdInvertGridLocal();
00084         bool execute();
00085 };
00086 
00087 class CmdInvertGridRemote : public CmdInvertGridBase
00088 {
00089 public:
00090         CmdInvertGridRemote(const std::string &cmdname);
00091         ~CmdInvertGridRemote();
00092         bool execute();
00093 private:
00094         shellp::ShellCmdStringArg *ipstrarg;
00095         shellp::ShellCmdIntArg *portarg;
00096 };
00097 
00098 class CmdInvertGAParamsShow : public shellp::ShellCommand
00099 {
00100 public:
00101         CmdInvertGAParamsShow(const std::string &cmdname);
00102         ~CmdInvertGAParamsShow();
00103         bool execute();
00104 };
00105 
00106 class CmdInvertGAParamsSet : public shellp::ShellCommand
00107 {
00108 public:
00109         CmdInvertGAParamsSet(const std::string &cmdname);
00110         ~CmdInvertGAParamsSet();
00111         bool execute();
00112 private:
00113         shellp::ShellCmdRealArg *betaarg;
00114         shellp::ShellCmdBoolArg *elitarg;
00115         shellp::ShellCmdBoolArg *bestarg;
00116         shellp::ShellCmdRealArg *crossarg;
00117         shellp::ShellCmdBoolArg *saveintarg;
00118         shellp::ShellCmdStringArg *prefarg;
00119         shellp::ShellCmdBoolArg *saveallarg;
00120         shellp::ShellCmdStringArg *saveprefarg;
00121 };
00122 
00123 class CmdInvertAreaBase : public CmdInvertBase
00124 {
00125 public:
00126         CmdInvertAreaBase(const std::string &cmdname);
00127         ~CmdInvertAreaBase();
00128 protected:
00129         void AddDefaultArguments();
00130         int GetPopulationSize()                                                         { return popsizearg->getValue(); }
00131         bool GetModuleName(std::string &modulename);
00132         mogal::GAFactoryParams *GetFactoryParameters(mogal::GAFactory &factory);
00133 private:
00134         shellp::ShellCmdRealArg *Ddarg;
00135         shellp::ShellCmdRealArg *sizearg;
00136         shellp::ShellCmdRealArg *xarg;
00137         shellp::ShellCmdRealArg *yarg;
00138         shellp::ShellCmdStringArg *invtypearg;
00139         shellp::ShellCmdIntArg *popsizearg;
00140         shellp::ShellCmdIntArg *maxgenarg;
00141         shellp::ShellCmdStringArg *filearg;
00142 };
00143 
00144 class CmdInvertAreaLocal : public CmdInvertAreaBase
00145 {
00146 public:
00147         CmdInvertAreaLocal(const std::string &cmdname);
00148         ~CmdInvertAreaLocal();
00149         bool execute();
00150 };
00151 
00152 class CmdInvertAreaRemote : public CmdInvertAreaBase
00153 {
00154 public:
00155         CmdInvertAreaRemote(const std::string &cmdname);
00156         ~CmdInvertAreaRemote();
00157         bool execute();
00158 private:
00159         shellp::ShellCmdStringArg *ipstrarg;
00160         shellp::ShellCmdIntArg *portarg;
00161 };
00162 
00163 class CmdInvertTreeBase : public CmdInvertBase
00164 {
00165 public:
00166         CmdInvertTreeBase(const std::string &cmdName);
00167         ~CmdInvertTreeBase();
00168 protected:
00169         void AddDefaultArguments();
00170         int GetPopulationSize()                                                         { return m_pPopulationSizeArg->getValue(); }
00171         bool GetModuleName(std::string &moduleName);
00172         mogal::GAFactoryParams *GetFactoryParameters();
00173 private:
00174         shellp::ShellCmdRealArg *m_pDdArg;
00175         shellp::ShellCmdRealArg *m_pSizeArg;
00176         shellp::ShellCmdRealArg *m_pCenterXArg;
00177         shellp::ShellCmdRealArg *m_pCenterYArg;
00178         shellp::ShellCmdStringArg *m_pInversionModuleArg;
00179         shellp::ShellCmdIntArg *m_pMaxDepthArg;
00180         shellp::ShellCmdIntArg *m_pMaxBasisArg;
00181         shellp::ShellCmdIntArg *m_pFirstSubdivArg;
00182         shellp::ShellCmdIntArg *m_pPopulationSizeArg;
00183         shellp::ShellCmdIntArg *m_pMaxGenArg;
00184         shellp::ShellCmdBoolArg *m_pUseWeightsArg;
00185 };
00186 
00187 class CmdInvertTreeLocal : public CmdInvertTreeBase
00188 {
00189 public:
00190         CmdInvertTreeLocal(const std::string &cmdname);
00191         ~CmdInvertTreeLocal();
00192         bool execute();
00193 };
00194 
00195 class CmdInvertTreeRemote : public CmdInvertTreeBase
00196 {
00197 public:
00198         CmdInvertTreeRemote(const std::string &cmdname);
00199         ~CmdInvertTreeRemote();
00200         bool execute();
00201 private:
00202         shellp::ShellCmdStringArg *m_pIPArg;
00203         shellp::ShellCmdIntArg *m_pPortArg;
00204 };
00205 
00206 class CmdInvertGridNewBase : public CmdInvertBase
00207 {
00208 public:
00209         CmdInvertGridNewBase(const std::string &cmdName);
00210         ~CmdInvertGridNewBase();
00211 protected:
00212         void AddDefaultArguments();
00213         mogal::GAFactoryParams *GetFactoryParameters();
00214         bool GetModuleName(std::string &modulename);
00215         int GetPopulationSize()                                                         { return popsizearg->getValue(); }
00216 private:
00217         shellp::ShellCmdRealArg *Ddarg;
00218         shellp::ShellCmdRealArg *m_pZArg;
00219         shellp::ShellCmdStringArg *invtypearg;
00220         shellp::ShellCmdIntArg *popsizearg;
00221         shellp::ShellCmdIntArg *maxgenarg;
00222         shellp::ShellCmdRealArg *plumwidtharg;
00223         shellp::ShellCmdStringArg *basisarg;
00224         shellp::ShellCmdBoolArg *m_pAllowNegativeArg;
00225         shellp::ShellCmdBoolArg *m_pUseBaseLensArg;
00226         shellp::ShellCmdRealArg *m_pMassScaleArg;
00227         shellp::ShellCmdBoolArg *m_pSearchSheetArg;
00228         shellp::ShellCmdBoolArg *m_pShowEvolutionArg;
00229         shellp::ShellCmdBoolArg *m_pSaveFirstGenomeArg;
00230 };
00231 
00232 class CmdInvertGridNewLocal : public CmdInvertGridNewBase
00233 {
00234 public:
00235         CmdInvertGridNewLocal(const std::string &cmdname);
00236         ~CmdInvertGridNewLocal();
00237         bool execute();
00238 };
00239 
00240 class CmdInvertGridNewRemote : public CmdInvertGridNewBase
00241 {
00242 public:
00243         CmdInvertGridNewRemote(const std::string &cmdname);
00244         ~CmdInvertGridNewRemote();
00245         bool execute();
00246 private:
00247         shellp::ShellCmdStringArg *ipstrarg;
00248         shellp::ShellCmdIntArg *portarg;
00249 };
00250 
00251 
00252 #endif // CMDINVERT_H
00253