Changeset 701bbc for src


Ignore:
Timestamp:
Jun 29, 2012, 8:01:46 AM (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:
a8f54b6
Parents:
7dd8bc
git-author:
Frederik Heber <heber@…> (03/04/12 15:59:32)
git-committer:
Frederik Heber <heber@…> (06/29/12 08:01:46)
Message:

Added SyncOperation and common base Operation.

Location:
src/Fragmentation/Automation
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Automation/Controller/CommandRegistry.cpp

    r7dd8bc r701bbc  
    3434{}
    3535
    36 CONSTRUCT_REGISTRY(AsyncOperation)
     36CONSTRUCT_REGISTRY(Operation)
  • src/Fragmentation/Automation/Controller/CommandRegistry.hpp

    r7dd8bc r701bbc  
    1414#endif
    1515
    16 #include "Controller/Commands/AsyncOperation.hpp"
     16#include "Controller/Commands/Operation.hpp"
    1717#include "CodePatterns/Registry.hpp"
    1818
    19 class CommandRegistry : public Registry<AsyncOperation>
     19class CommandRegistry : public Registry<Operation>
    2020{
    2121public:
  • src/Fragmentation/Automation/Controller/Commands/AsyncOperation.cpp

    r7dd8bc r701bbc  
    3131
    3232#include "Controller/Commands/AsyncOperation.hpp"
    33 
    34 
    35 /** Constructor for class AsyncOperation.
    36  *
    37  * \param _name name for this Operation for retrieval from a registry
    38  * \param _connection connection to operate on
    39  */
    40 AsyncOperation::AsyncOperation(const std::string &_name, Connection &_connection) :
    41     connection_(_connection),
    42     name(_name),
    43     Exitflag(OkFlag)
    44 {}
    45 
    46 /** Destructor for class AsyncOperation.
    47  *
    48  */
    49 AsyncOperation::~AsyncOperation()
    50 {}
    5133
    5234/** Callback function when an operation has been completed.
     
    9779      boost::asio::placeholders::error, ++endpoint_iterator));
    9880}
     81
  • src/Fragmentation/Automation/Controller/Commands/AsyncOperation.hpp

    r7dd8bc r701bbc  
    1818#include <vector>
    1919
    20 #include "Connection.hpp"
     20#include "Operation.hpp"
    2121
    22 class AsyncOperation {
     22class AsyncOperation : public Operation {
    2323public:
    24   AsyncOperation(const std::string &_name, Connection &_connection);
    25   virtual ~AsyncOperation();
     24  /** Constructor for class AsyncOperation.
     25   *
     26   * \param _name name for this AsyncOperation for retrieval from a registry
     27   * \param _connection connection to operate on
     28   */
     29  AsyncOperation(const std::string &_name, Connection &_connection) :
     30    Operation(_name, _connection)
     31  {}
     32
     33  /** Destructor for class AsyncOperation.
     34   *
     35   */
     36  virtual ~AsyncOperation()
     37  {}
     38
    2639public:
    27   /// The Connection to the server.
    28   Connection &connection_;
    29 
    3040  // virtual function pointer to the operation to do
    3141  void operator()(const std::string& _host, const std::string& _service);
    3242
     43protected:
    3344  // virtual function pointer to the connection handler
    3445  virtual void handle_connect(const boost::system::error_code& e,
     
    3849  void handle_FinishOperation(const boost::system::error_code& e);
    3950
    40   enum Exitflag_t {
    41     OkFlag = 0,
    42     ErrorFlag = 255
    43   };
    44 
    45   /** Getter for Exitflag.
    46    *
    47    * @return Exitflag
    48    */
    49   size_t getExitflag() const
    50   {
    51     return Exitflag;
    52   }
    53 
    54   std::string getName() const {
    55     return name;
    56   }
    57 
    58 private:
    59   /// Name of this Operation (required for Registry pattern)
    60   std::string name;
    61 
    6251protected:
    6352  /// internal function to disconnect from server
    6453  void disconnect();
    65 
    66   // exit flag of this operation
    67   enum Exitflag_t Exitflag;
    6854};
    6955
  • src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp

    r7dd8bc r701bbc  
    2727#include "Connection.hpp" // Must come before boost/serialization headers.
    2828#include "CodePatterns/Info.hpp"
    29 #include "CodePatterns/Log.hpp"
    3029#include "ControllerChoices.hpp"
    3130
    3231#include "Controller/Commands/ShutdownOperation.hpp"
    3332
    34 /** Handle connect operation to shutdown scheduler.
     33/** Virtual internal function to give shutdown choice.
    3534 *
    36  * \param e error code if something went wrong
    37  * \param endpoint_iterator endpoint of the connection
    3835 */
    39 void ShutdownOperation::handle_connect(const boost::system::error_code& e,
    40     boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
     36void ShutdownOperation::internal()
    4137{
    4238  Info info(__FUNCTION__);
    43   if (!e)
    44   {
    45     // Successfully established connection. Give choice.
    46     enum ControllerChoices choice = ShutdownControllerSocket;
    47     connection_.async_write(choice,
    48       boost::bind(&ShutdownOperation::handle_FinishOperation, this,
    49       boost::asio::placeholders::error));
    50   } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
    51     // Try the next endpoint.
    52     connection_.socket().close();
    53     boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
    54     connection_.socket().async_connect(endpoint,
    55       boost::bind(&ShutdownOperation::handle_connect, this,
    56       boost::asio::placeholders::error, ++endpoint_iterator));
    57   } else {
    58     // An error occurred. Log it and return. Since we are not starting a new
    59     // operation the io_service will run out of work to do and the client will
    60     // exit.
    61     Exitflag = ErrorFlag;
    62     ELOG(1, e.message());
    63   }
     39  enum ControllerChoices choice = ShutdownControllerSocket;
     40  connection_.sync_write(choice);
    6441}
     42
  • src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.hpp

    r7dd8bc r701bbc  
    2020#include "Connection.hpp"
    2121
    22 #include "Controller/Commands/AsyncOperation.hpp"
     22#include "Controller/Commands/SyncOperation.hpp"
    2323
    24 class ShutdownOperation : public AsyncOperation  {
     24/** Synchronous operation that gives shutdown command.
     25 *
     26 */
     27class ShutdownOperation : public SyncOperation  {
    2528public:
    2629  /// Constructor for class ShutdownOperation.
    2730  ShutdownOperation(Connection &_connection) :
    28     AsyncOperation(std::string("shutdown"),_connection) {}
     31    SyncOperation(std::string("shutdown"),_connection) {}
    2932  /// Destructor for class ShutdownOperation
    3033  ~ShutdownOperation() {}
    3134
    3235public:
    33   // virtual function pointer to the connection handler
    34   virtual void handle_connect(const boost::system::error_code& e,
    35       boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
     36  // function that implements read&writes in between connect/disconnect
     37  virtual void internal();
    3638};
    3739
  • src/Fragmentation/Automation/Makefile.am

    r7dd8bc r701bbc  
    5252  Controller/Commands/SendResultsOperation.cpp \
    5353  Controller/Commands/ShutdownOperation.cpp \
    54   Controller/Commands/SubmitResultOperation.cpp
     54  Controller/Commands/SubmitResultOperation.cpp \
     55  Controller/Commands/SyncOperation.cpp
    5556
    5657FRAGMENTATIONCOMMANDSHEADER = \
     
    6162  Controller/Commands/GetNextJobIdOperation.hpp \
    6263  Controller/Commands/ObtainJobOperation.hpp \
     64  Controller/Commands/Operation.hpp \
    6365  Controller/Commands/ReceiveJobsOperation.hpp \
    6466  Controller/Commands/SendJobToWorkerOperation.hpp \
    6567  Controller/Commands/SendResultsOperation.hpp \
    6668  Controller/Commands/ShutdownOperation.hpp \
    67   Controller/Commands/SubmitResultOperation.hpp
     69  Controller/Commands/SubmitResultOperation.hpp \
     70  Controller/Commands/SyncOperation.hpp
    6871
    6972noinst_LTLIBRARIES += libMolecuilderFragmentationCommands.la
Note: See TracChangeset for help on using the changeset viewer.