Ignore:
Timestamp:
Dec 13, 2012, 9:32:50 AM (12 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:
79ac03
Parents:
67db80
git-author:
Frederik Heber <heber@…> (09/27/12 13:52:16)
git-committer:
Frederik Heber <heber@…> (12/13/12 09:32:50)
Message:

Added serialization to HomologyContainer and completed HomologyContainerUnitTest.

  • Added specific operator==() to HomologyContainer as multimap's values' ordering is not guaranteed and boost::serialization does not adhere to it (simple copy of multimap probably maintains the ordering).
  • added InsertionTest, EqualityTest, and serializeTest().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Homology/HomologyContainer.hpp

    r67db80 r12a24c  
    1414#include <config.h>
    1515#endif
     16
     17#include <boost/serialization/export.hpp>
     18#include <boost/serialization/map.hpp>
     19#include <boost/serialization/vector.hpp>
    1620
    1721#include <iosfwd>
     
    3337  Fragment() {}
    3438  Fragment(const positions_t &_positions, const charges_t &_charges) {}
     39
     40  bool operator==(const Fragment &other) const {
     41    return true;
     42  }
     43
     44private:
     45  friend class boost::serialization::access;
     46  // serialization
     47  template <typename Archive>
     48  void serialize(Archive& ar, const unsigned int version)
     49  {}
    3550};
    3651
    3752std::ostream& operator<<(std::ostream &out, const Fragment &container);
     53
     54// we need to give this class a unique key for serialization
     55BOOST_CLASS_EXPORT_KEY(Fragment)
     56
     57class HomologyContainerTest;
    3858
    3959/** This class takes all KeySets in a Graph, checks for those that homologues
     
    5272  //!> grant access to output operator
    5373  friend std::ostream& operator<<(std::ostream &out, const HomologyContainer &container);
     74  //!> grant unit test access
     75  friend class HomologyContainerTest;
    5476public:
    5577  typedef double energy_t;
     
    7597  ~HomologyContainer() {}
    7698
     99  /** Equality comparator.
     100   *
     101   * Sadly, the insertion order of a std::multimap's values is not guaranteed
     102   * by the standard and boost::serialization does not heed the ordering of
     103   * the values associated to the same key. Hence, we implement a weaker
     104   * comparator for this class in order for the unit test to pass as we don't
     105   * actuallty care about the order of the homologous fragments.
     106   *
     107   * @param other instance to compare to
     108   * @return true - each container contains all elements of the other
     109   */
     110  bool operator==(const HomologyContainer &other) const {
     111    return ((*this >= other) && (other >= *this));
     112  }
     113  bool operator!=(const HomologyContainer& other) const {
     114    return !(*this == other);
     115  }
     116
     117  /** Greater equal comparator, i.e. subset comparator
     118   *
     119   * @param other container to check if it's subset
     120   * @return true - \a other is a subset of this
     121   */
     122  bool operator>=(const HomologyContainer &other) const;
     123
    77124  /** Inserter for more graphs along with values.
    78125   *
     
    95142  //!> multimap containing all homologous graph under same key but each with its value
    96143  container_t container;
     144
     145private:
     146  friend class boost::serialization::access;
     147  // serialization
     148  template <typename Archive>
     149  void serialize(Archive& ar, const unsigned int version)
     150  {
     151    ar & container;
     152  }
    97153};
    98154
     
    105161std::ostream& operator<<(std::ostream &out, const HomologyContainer &container);
    106162
     163// we need to give this class a unique key for serialization
     164BOOST_CLASS_EXPORT_KEY(HomologyContainer)
     165
     166
    107167#endif /* HOMOLOGYCONTAINER_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.