Changeset 477012 for src


Ignore:
Timestamp:
Sep 19, 2013, 8:23:52 PM (11 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
27d0bc
Parents:
9b56f34
git-author:
Frederik Heber <heber@…> (08/26/13 08:23:15)
git-committer:
Frederik Heber <heber@…> (09/19/13 20:23:52)
Message:

Added Action::outputAsPython() and ActionQueue::outputAsPython().

  • these work in exactly the same way as outputAsCLI().
Location:
src
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.hpp

    r9b56f34 r477012  
    174174  virtual void outputAsCLI(std::ostream &ost) const=0;
    175175
     176  /** Prints what would be necessary to add the Action from a Python script
     177   *
     178   * \param ost output stream to print to
     179   * \param prefix package prefix to be used
     180   */
     181  virtual void outputAsPython(std::ostream &ost, const std::string &prefix) const=0;
     182
    176183  /**
    177184   * Traits resemble all necessary information that "surrounds" an action, such as
  • src/Actions/ActionQueue.cpp

    r9b56f34 r477012  
    106106}
    107107
     108void ActionQueue::outputAsPython(std::ostream &output) const
     109{
     110  const std::string prefix("pyMoleCuilder");
     111  output << "import " << prefix << std::endl;
     112  output << "% ========================== Stored Session BEGIN ==========================" << std::endl;
     113  for (ActionQueue_t::const_iterator iter = queue.begin();
     114      iter != queue.end();
     115      ++iter) {
     116    // skip store-session in printed list
     117    if ((*iter)->getName() != std::string("store-session"))
     118      (*iter)->outputAsPython(output, prefix);
     119  }
     120  output << "% =========================== Stored Session END ===========================" << std::endl;
     121}
     122
    108123const ActionTrait& ActionQueue::getActionsTrait(const std::string &name) const
    109124{
  • src/Actions/ActionQueue.hpp

    r9b56f34 r477012  
    9696  void outputAsCLI(std::ostream &output) const;
    9797
     98  /** Print the current contents of the queue as Python instantiated list of Actions.
     99   *
     100   * This is useful for storing the current session.
     101   *
     102   * \param output output stream to print to
     103   */
     104  void outputAsPython(std::ostream &output) const;
     105
    98106  /** Undoes last called Action.
    99107   *
  • src/Actions/ActionSequence.cpp

    r9b56f34 r477012  
    166166  }
    167167}
     168
     169void ActionSequence::outputAsPython(std::ostream &ost, const std::string &prefix) const
     170{
     171  for(std::deque<Action*>::const_iterator it=actions.begin();it!=actions.end();++it)
     172    (*it)->outputAsPython(ost, prefix);
     173}
  • src/Actions/ActionSequence.hpp

    r9b56f34 r477012  
    4545
    4646  void outputAsCLI(std::ostream &ost) const;
     47  void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    4748
    4849protected:
  • src/Actions/Action_impl_header.hpp

    r9b56f34 r477012  
    213213
    214214  void outputAsCLI(std::ostream &ost) const;
     215  void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    215216
    216217  struct PARAMS : ActionParameters {
  • src/Actions/Action_impl_pre.hpp

    r9b56f34 r477012  
    148148#define outputAsCLI_print(z,n,output) \
    149149    output << \
    150     BOOST_PP_IF(n, BOOST_PP_STRINGIZE( ) , BOOST_PP_STRINGIZE() ) \
    151       << "--" << \
     150    BOOST_PP_IF(n, " --", "--") \
     151    << \
    152152    BOOST_PP_SEQ_ELEM(n, paramtokens) \
    153153    << " \"" << toCLIString(params. \
     
    162162        == getName()) \
    163163        booltoken = false;
     164
     165// prints command line call for this Action for paramtypes with tokens
     166#define outputAsPython_print(z,n,output) \
     167    output << \
     168    BOOST_PP_IF(n, ", ", "") \
     169    << "\"" << toCLIString(params. \
     170        BOOST_PP_SEQ_ELEM(n, paramreferences) \
     171        .get()) \
     172    << "\"";
    164173
    165174// print an initialiser list, i.e. "var( token, valid (,default) )(,)"
     
    315324}
    316325
     326// =========== output as PYTHON ===========
     327void ACTION::outputAsPython(std::ostream &ost, const std::string &prefix) const {
     328  // print prefix and action command
     329  ost << prefix << "." << BOOST_PP_STRINGIZE( COMMAND ) << "(";
     330  // then print option along with each argument if set
     331#if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
     332#define BOOST_PP_LOCAL_MACRO(n) outputAsPython_print(~, n, ost)
     333#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     334#include BOOST_PP_LOCAL_ITERATE()
     335#endif
     336  ost << ")" << std::endl;
     337}
     338
    317339// =========== time the action ===========
    318340// we need this here to have the correct function name
  • src/Actions/Calculation.hpp

    r9b56f34 r477012  
    4343
    4444  virtual void outputAsCLI(std::ostream &ost) const;
     45  virtual void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    4546
    4647  /**
  • src/Actions/Calculation_impl.hpp

    r9b56f34 r477012  
    7272}
    7373
     74template<typename T>
     75void Calculation<T>::outputAsPython(std::ostream &ost, const std::string &prefix) const
     76{}
     77
    7478// methods for calculation infrastructure
    7579
  • src/Actions/ErrorAction.cpp

    r9b56f34 r477012  
    8282void ErrorAction::outputAsCLI(std::ostream &ost) const
    8383{}
     84
     85void ErrorAction::outputAsPython(std::ostream &ost, const std::string &prefix) const
     86{}
  • src/Actions/ErrorAction.hpp

    r9b56f34 r477012  
    3030
    3131  void outputAsCLI(std::ostream &ost) const;
     32  void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    3233
    3334private:
  • src/Actions/MakroAction.cpp

    r9b56f34 r477012  
    132132  actions.outputAsCLI(ost);
    133133}
     134
     135void MakroAction::outputAsPython(std::ostream &ost, const std::string &prefix) const
     136{
     137  actions.outputAsCLI(ost);
     138}
  • src/Actions/MakroAction.hpp

    r9b56f34 r477012  
    3838
    3939  virtual void outputAsCLI(std::ostream &ost) const;
     40  virtual void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    4041
    4142  // must be called after all primitive actions are present
  • src/Actions/MakroAction_impl_header.hpp

    r9b56f34 r477012  
    219219
    220220  void outputAsCLI(std::ostream &ost) const;
     221  void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    221222
    222223  struct PARAMS : ActionParameters {
  • src/Actions/MakroAction_impl_pre.hpp

    r9b56f34 r477012  
    146146#define outputAsCLI_print(z,n,output) \
    147147    output << \
    148     BOOST_PP_IF(n, BOOST_PP_STRINGIZE( ) , BOOST_PP_STRINGIZE() ) \
    149       << "--" << \
     148    BOOST_PP_IF(n, " --", "--") \
     149    << \
    150150    BOOST_PP_SEQ_ELEM(n, paramtokens) \
    151151    << " \"" << toCLIString(params. \
     
    160160        == getName()) \
    161161        booltoken = false;
     162
     163// prints command line call for this Action for paramtypes with tokens
     164#define outputAsPython_print(z,n,output) \
     165    output << \
     166    BOOST_PP_IF(n, ", ", "") \
     167    << "\"" << toCLIString(params. \
     168        BOOST_PP_SEQ_ELEM(n, paramreferences) \
     169        .get()) \
     170    << "\"";
    162171
    163172// print an initialiser list, i.e. "var( token, valid (,default) )(,)"
     
    314323}
    315324
     325// =========== output as PYTHTON ===========
     326void ACTION::outputAsPython(std::ostream &ost, const std::string &prefix) const {
     327  // print prefix and action command
     328  ost << prefix << "." << BOOST_PP_STRINGIZE( COMMAND ) << "(";
     329  // then print option along with each argument if set
     330#if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
     331#define BOOST_PP_LOCAL_MACRO(n) outputAsCLI_print(~, n, ost)
     332#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     333#include BOOST_PP_LOCAL_ITERATE()
     334#endif
     335  ost << ")" << std::endl;
     336}
     337
    316338// =========== time the action ===========
    317339// we need this here to have the correct function name
  • src/Actions/ManipulateAtomsProcess.cpp

    r9b56f34 r477012  
    8787{}
    8888
     89void ManipulateAtomsProcess::outputAsPython(std::ostream &ost, const std::string &prefix) const
     90{}
     91
    8992void ManipulateAtomsProcess::doManipulate(World *world){
    9093  setMaxSteps(world->numAtoms());
  • src/Actions/ManipulateAtomsProcess.hpp

    r9b56f34 r477012  
    3939
    4040  void outputAsCLI(std::ostream &ost) const;
     41  void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    4142
    4243  virtual void doManipulate(World *);
  • src/Actions/MethodAction.cpp

    r9b56f34 r477012  
    7979}
    8080
     81bool MethodAction::shouldUndo(){
     82  return true;
     83}
     84
    8185void MethodAction::outputAsCLI(std::ostream &ost) const
    8286{}
    8387
    84 bool MethodAction::shouldUndo(){
    85   return true;
    86 }
     88void MethodAction::outputAsPython(std::ostream &ost, const std::string &prefix) const
     89{}
  • src/Actions/MethodAction.hpp

    r9b56f34 r477012  
    3535
    3636  void outputAsCLI(std::ostream &ost) const;
     37  void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    3738
    3839protected:
  • src/Actions/Reaction.hpp

    r9b56f34 r477012  
    4343
    4444  virtual void outputAsCLI(std::ostream &ost) const;
     45  virtual void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    4546
    4647  /**
  • src/Actions/Reaction_impl.hpp

    r9b56f34 r477012  
    6969{}
    7070
     71template<typename T>
     72void Reaction<T>::outputAsPython(std::ostream &ost, const std::string &prefix) const
     73{}
     74
    7175// methods for calculation infrastructure
    7276
  • src/Actions/Reaction_impl_header.hpp

    r9b56f34 r477012  
    207207
    208208  void outputAsCLI(std::ostream &ost) const;
     209  void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    209210
    210211  virtual RETURNTYPE * doCalc();
  • src/Actions/Reaction_impl_pre.hpp

    r9b56f34 r477012  
    130130#define outputAsCLI_print(z,n,output) \
    131131    output << \
    132     BOOST_PP_IF(n, BOOST_PP_STRINGIZE( ) , BOOST_PP_STRINGIZE() ) \
    133       << "--" << \
     132    BOOST_PP_IF(n, " --", "--") \
     133    << \
    134134    BOOST_PP_SEQ_ELEM(n, paramtokens) \
    135135    << " \"" << toCLIString(params. \
     
    144144        == getName()) \
    145145        booltoken = false;
     146
     147// prints command line call for this Action for paramtypes with tokens
     148#define outputAsPython_print(z,n,output) \
     149    output << \
     150    BOOST_PP_IF(n, ", ", "") \
     151    << "\"" << toCLIString(params. \
     152        BOOST_PP_SEQ_ELEM(n, paramreferences) \
     153        .get()) \
     154    << "\"";
    146155
    147156// prints set/queryCurrentValue (command) for paramreferences and paramtokens
     
    221230#include BOOST_PP_LOCAL_ITERATE()
    222231#endif
     232}
     233
     234// =========== output as PYTHTON ===========
     235void REACTION::outputAsPython(std::ostream &ost, const std::string &prefix) const {
     236  // print prefix and action command
     237  ost << prefix << "." << BOOST_PP_STRINGIZE( COMMAND ) << "(";
     238  // then print option along with each argument if set
     239#if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
     240#define BOOST_PP_LOCAL_MACRO(n) outputAsCLI_print(~, n, ost)
     241#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     242#include BOOST_PP_LOCAL_ITERATE()
     243#endif
     244  ost << ")" << std::endl;
    223245}
    224246
  • src/Actions/unittests/ActionSequenceUnitTest.cpp

    r9b56f34 r477012  
    8787  void outputAsCLI(std::ostream &ost) const
    8888  {}
     89  void outputAsPython(std::ostream &ost, const std::string &prefix) const
     90  {}
    8991};
    9092
     
    118120  void outputAsCLI(std::ostream &ost) const
    119121  {}
     122  void outputAsPython(std::ostream &ost, const std::string &prefix) const
     123  {}
    120124};
    121125
     
    151155  }
    152156  void outputAsCLI(std::ostream &ost) const
     157  {}
     158  void outputAsPython(std::ostream &ost, const std::string &prefix) const
    153159  {}
    154160  bool wasCalled(){
  • src/UIElements/Menu/TextMenu/TxMenuLeaveAction.cpp

    r9b56f34 r477012  
    7474{}
    7575
     76void TxMenu::LeaveAction::outputAsPython(std::ostream &ost, const std::string &prefix) const
     77{}
     78
    7679/** Internal function to construct the dialog.
    7780 * We do not need this function as there is no dialog to construct.
  • src/UIElements/Menu/TextMenu/TxMenuLeaveAction.hpp

    r9b56f34 r477012  
    3434
    3535  void outputAsCLI(std::ostream &ost) const;
     36  void outputAsPython(std::ostream &ost, const std::string &prefix) const;
    3637
    3738protected:
Note: See TracChangeset for help on using the changeset viewer.