Changeset 9948a7 for src/Fragmentation


Ignore:
Timestamp:
May 17, 2012, 3:21:54 PM (13 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:
96c83b
Parents:
d6fe76
git-author:
Frederik Heber <heber@…> (12/11/11 16:59:08)
git-committer:
Frederik Heber <heber@…> (05/17/12 15:21:54)
Message:

Operation::operator() now contains everything to get the endpoint and connect.

  • getting the endpoint is placed in operator() which needs host and service as parameters.
  • derived classes just implement handle_connect whose virtual function pointer is boost::bind in Operation::operator().
  • this all makes it very easy to implement new commands for the Controller.
  • all handle_connect_... of course are now the above implementation.
  • all connect_... are now contained in Operation::operator(), hence have been removed.
Location:
src/Fragmentation/Automation/Controller
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Automation/Controller/Commands/CheckResultsOperation.cpp

    rd6fe76 r9948a7  
    2424
    2525#include <boost/bind.hpp>
    26 #include <boost/foreach.hpp>
    2726#include <iostream>
    2827#include "Connection.hpp" // Must come before boost/serialization headers.
     
    3837 * \param endpoint_iterator endpoint of the connection
    3938 */
    40 void CheckResultsOperation::handle_connect_check(const boost::system::error_code& e,
     39void CheckResultsOperation::handle_connect(const boost::system::error_code& e,
    4140    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
    4241{
     
    5453    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    5554    connection_.socket().async_connect(endpoint,
    56       boost::bind(&CheckResultsOperation::handle_connect_check, this,
     55      boost::bind(&CheckResultsOperation::handle_connect, this,
    5756      boost::asio::placeholders::error, ++endpoint_iterator));
    5857  } else {
     
    8988}
    9089
    91 /** Internal function to connect to the endpoint of the server asynchronuously.
    92  *
    93  * We require internal connetion_ and host and service to be set up for this.
    94  */
    95 void CheckResultsOperation::connect_check()
    96 {
    97   Info info(__FUNCTION__);
    98   // Resolve the host name into an IP address.
    99   boost::asio::ip::tcp::resolver::iterator endpoint_iterator = getEndpointIterator();
    100   boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    101 
    102   // Start an asynchronous connect operation.
    103   std::cout << "Connecting to endpoint " << endpoint << " to check " << std::endl;
    104   connection_.socket().async_connect(endpoint,
    105     boost::bind(&CheckResultsOperation::handle_connect_check, this,
    106       boost::asio::placeholders::error, ++endpoint_iterator));
    107 }
    108 
    109 /** Prepares the calculation of the results for the current jobs.
    110  */
    111 void CheckResultsOperation::operator()()
    112 {
    113   Info info(__FUNCTION__);
    114   // connect
    115   connect_check();
    116   //disconnect
    117   disconnect();
    118 }
    119 
    120 void CheckResultsOperation::handle_connect(const boost::system::error_code& e,
    121     boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
    122 {}
    123 
  • src/Fragmentation/Automation/Controller/Commands/CheckResultsOperation.hpp

    rd6fe76 r9948a7  
    3333
    3434public:
    35   // placing receive jobs operations into an io_service
    36   virtual void operator()();
    37 
    3835  // virtual function pointer to the connection handler
    3936  virtual void handle_connect(const boost::system::error_code& e,
    4037      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
    4138
    42   /// Handle completion of a CheckResults operation.
    43   void handle_connect_check(const boost::system::error_code& e,
    44       boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
    45 
    4639  /// Callback function when doneJobs have been received.
    4740  void handle_ReceiveDoneJobs(const boost::system::error_code& e);
    48 
    49   /// internal function to connect to server and check done jobs
    50   void connect_check();
    5141
    5242  /** Getter for doneJobs.
  • src/Fragmentation/Automation/Controller/Commands/Operation.cpp

    rd6fe76 r9948a7  
    9696}
    9797
    98 void Operation::testfunction(const std::string& _host, const std::string& _service)
     98void Operation::operator()(const std::string& _host, const std::string& _service)
    9999{
    100100  Info info(__FUNCTION__);
  • src/Fragmentation/Automation/Controller/Commands/Operation.hpp

    rd6fe76 r9948a7  
    2929
    3030  // virtual function pointer to the operation to do
    31   virtual void operator()() = 0;
     31  void operator()(const std::string& _host, const std::string& _service);
    3232
    3333  // virtual function pointer to the connection handler
    3434  virtual void handle_connect(const boost::system::error_code& e,
    3535      boost::asio::ip::tcp::resolver::iterator endpoint_iterator) = 0;
    36 
    37   void testfunction(const std::string& _host, const std::string& _service);
    3836
    3937  /// Handle completion of an operation.
  • src/Fragmentation/Automation/Controller/Commands/ReceiveJobsOperation.cpp

    rd6fe76 r9948a7  
    4141 * \param endpoint_iterator endpoint of the connection
    4242 */
    43 void ReceiveJobsOperation::handle_connect_calc(const boost::system::error_code& e,
     43void ReceiveJobsOperation::handle_connect(const boost::system::error_code& e,
    4444    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
    4545{
     
    5757    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    5858    connection_.socket().async_connect(endpoint,
    59       boost::bind(&ReceiveJobsOperation::handle_connect_calc, this,
     59      boost::bind(&ReceiveJobsOperation::handle_connect, this,
    6060      boost::asio::placeholders::error, ++endpoint_iterator));
    6161  } else {
     
    110110}
    111111
    112 /** Internal function to connect to the endpoint of the server asynchronuously.
    113  *
    114  * We require internal connetion_ and host and service to be set up for this.
    115  */
    116 void ReceiveJobsOperation::connect_calc()
    117 {
    118   Info info(__FUNCTION__);
    119   // Resolve the host name into an IP address.
    120   boost::asio::ip::tcp::resolver::iterator endpoint_iterator = getEndpointIterator();
    121   boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    122 
    123   // Start an asynchronous connect operation.
    124   std::cout << "Connecting to endpoint " << endpoint << " to calc " << std::endl;
    125   connection_.socket().async_connect(endpoint,
    126     boost::bind(&ReceiveJobsOperation::handle_connect_calc, this,
    127       boost::asio::placeholders::error, ++endpoint_iterator));
    128 }
    129 
    130112/** Place number of jobs into this controller.
    131113 *
     
    140122}
    141123
    142 /** Prepares the calculation of the results for the current jobs.
    143  */
    144 void ReceiveJobsOperation::operator()()
    145 {
    146   Info info(__FUNCTION__);
    147   // connect
    148   connect_calc();
    149   //disconnect
    150   disconnect();
    151 }
    152 
    153 void ReceiveJobsOperation::handle_connect(const boost::system::error_code& e,
    154     boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
    155 {}
    156 
  • src/Fragmentation/Automation/Controller/Commands/ReceiveJobsOperation.hpp

    rd6fe76 r9948a7  
    3232
    3333public:
    34   /// Placing receive jobs operations into an io_service
    35   virtual void operator()();
    36 
    3734  // virtual function pointer to the connection handler
    3835  virtual void handle_connect(const boost::system::error_code& e,
    3936      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
    4037
    41   /// Handle completion of a calculate operation.
    42   void handle_connect_calc(const boost::system::error_code& e,
    43       boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
    44 
    4538  /// Callback function when bunch of jobs have been sent.
    4639  void handle_SendJobs(const boost::system::error_code& e);
    47 
    48   /// internal function to connect to server and send jobs for calculation
    49   void connect_calc();
    5040
    5141  /// Setter for jobs
  • src/Fragmentation/Automation/Controller/Commands/SendResultsOperation.cpp

    rd6fe76 r9948a7  
    2424
    2525#include <boost/bind.hpp>
    26 #include <boost/foreach.hpp>
    2726#include <iostream>
    2827#include <vector>
     
    4140 * \param endpoint_iterator endpoint of the connection
    4241 */
    43 void SendResultsOperation::handle_connect_get(const boost::system::error_code& e,
     42void SendResultsOperation::handle_connect(const boost::system::error_code& e,
    4443    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
    4544{
     
    5756    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    5857    connection_.socket().async_connect(endpoint,
    59       boost::bind(&SendResultsOperation::handle_connect_get, this,
     58      boost::bind(&SendResultsOperation::handle_connect, this,
    6059      boost::asio::placeholders::error, ++endpoint_iterator));
    6160  } else {
     
    108107}
    109108
    110 /** Internal function to connect to the endpoint of the server asynchronuously.
    111  *
    112  * We require internal connetion_ and host and service to be set up for this.
    113  */
    114 void SendResultsOperation::connect_get()
    115 {
    116   Info info(__FUNCTION__);
    117   // Resolve the host name into an IP address.
    118   boost::asio::ip::tcp::resolver::iterator endpoint_iterator = getEndpointIterator();
    119   boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    120 
    121   // Start an asynchronous connect operation.
    122   std::cout << "Connecting to endpoint " << endpoint << " to get results " << std::endl;
    123   connection_.socket().async_connect(endpoint,
    124     boost::bind(&SendResultsOperation::handle_connect_get, this,
    125       boost::asio::placeholders::error, ++endpoint_iterator));
    126 }
    127 
    128109/** Getter for results.
    129110 *
     
    136117  return results;
    137118}
    138 
    139 /** Function to initiate receival of results.
    140  *
    141  */
    142 void SendResultsOperation::operator()()
    143 {
    144   // connect
    145   connect_get();
    146   //disconnect
    147   disconnect();
    148 }
    149 
    150 void SendResultsOperation::handle_connect(const boost::system::error_code& e,
    151     boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
    152 {}
  • src/Fragmentation/Automation/Controller/Commands/SendResultsOperation.hpp

    rd6fe76 r9948a7  
    3232
    3333public:
    34   // placing receive jobs operations into an io_service
    35   virtual void operator()();
    36 
    3734  // virtual function pointer to the connection handler
    3835  virtual void handle_connect(const boost::system::error_code& e,
    39       boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
    40 
    41   /// Handle completion of a GetResults operation.
    42   void handle_connect_get(const boost::system::error_code& e,
    4336      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
    4437
     
    4841  /// Callback function when results have been received.
    4942  void handle_ReceivedResults(const boost::system::error_code& e);
    50 
    51   /// internal function to connect to server and receive calculated results
    52   void connect_get();
    5343
    5444  /// Getter for results
  • src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp

    rd6fe76 r9948a7  
    2424
    2525#include <boost/bind.hpp>
    26 #include <boost/foreach.hpp>
    2726#include <iostream>
    2827#include "Connection.hpp" // Must come before boost/serialization headers.
     
    3837 * \param endpoint_iterator endpoint of the connection
    3938 */
    40 void ShutdownOperation::handle_connect_shutdown(const boost::system::error_code& e,
     39void ShutdownOperation::handle_connect(const boost::system::error_code& e,
    4140    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
    4241{
     
    5453    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    5554    connection_.socket().async_connect(endpoint,
    56       boost::bind(&ShutdownOperation::handle_connect_shutdown, this,
     55      boost::bind(&ShutdownOperation::handle_connect, this,
    5756      boost::asio::placeholders::error, ++endpoint_iterator));
    5857  } else {
     
    6463  }
    6564}
    66 
    67 /** Internal function to connect to the endpoint of the server asynchronuously.
    68  *
    69  * We require internal connetion_ and host and service to be set up for this.
    70  */
    71 void ShutdownOperation::connect_shutdown()
    72 {
    73   Info info(__FUNCTION__);
    74   // Resolve the host name into an IP address.
    75   boost::asio::ip::tcp::resolver::iterator endpoint_iterator = getEndpointIterator();
    76   boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    77 
    78   // Start an asynchronous connect operation.
    79   std::cout << "Connecting to endpoint " << endpoint << " to get results " << std::endl;
    80   connection_.socket().async_connect(endpoint,
    81     boost::bind(&ShutdownOperation::handle_connect_shutdown, this,
    82       boost::asio::placeholders::error, ++endpoint_iterator));
    83 }
    84 
    85 /** Function to initiate shutdown of server.
    86  *
    87  */
    88 void ShutdownOperation::operator()()
    89 {
    90   // connect
    91   connect_shutdown();
    92   //disconnect
    93   disconnect();
    94 }
    95 
    96 void ShutdownOperation::handle_connect(const boost::system::error_code& e,
    97     boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
    98 {}
  • src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.hpp

    rd6fe76 r9948a7  
    3131
    3232public:
    33   // placing receive jobs operations into an io_service
    34   virtual void operator()();
    35 
    3633  // virtual function pointer to the connection handler
    3734  virtual void handle_connect(const boost::system::error_code& e,
    3835      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
    39 
    40   /// Handle completion of a Shutdown operation.
    41   void handle_connect_shutdown(const boost::system::error_code& e,
    42       boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
    43 
    44   /// internal function to connect to server and receive calculated results
    45   void connect_shutdown();
    4636};
    4737
  • src/Fragmentation/Automation/Controller/JobAdder.cpp

    rd6fe76 r9948a7  
    6767    }
    6868    controller.addJobs(jobs);
    69     controller.recjobs();
     69    controller.recjobs(argv[1], argv[2]);
    7070    {
    7171      Info info("io_service");
  • src/Fragmentation/Automation/Controller/ResultChecker.cpp

    rd6fe76 r9948a7  
    5959    FragmentController controller(io_service, argv[1], argv[2]);
    6060
    61     controller.checkres();
     61    controller.checkres(argv[1], argv[2]);
    6262    {
    6363      Info info("io_service");
  • src/Fragmentation/Automation/Controller/ResultGetter.cpp

    rd6fe76 r9948a7  
    6767    }
    6868
    69     controller.sendres();
     69    controller.sendres(argv[1], argv[2]);
    7070    {
    7171      Info info("io_service");
  • src/Fragmentation/Automation/Controller/Shutdowner.cpp

    rd6fe76 r9948a7  
    5959    FragmentController controller(io_service, argv[1], argv[2]);
    6060
    61     controller.shutdown();
     61    controller.shutdown(argv[1], argv[2]);
    6262    {
    6363      Info info("io_service");
Note: See TracChangeset for help on using the changeset viewer.