Ignore:
Timestamp:
Nov 1, 2011, 7:56:15 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:
35a889
Parents:
e6c470
Message:

DOCU: Added some important notes in usual mistakes to serialization.dox.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/documentation/constructs/serialization.dox

    re6c470 rbc3411  
    114114 *  again make it a friend).
    115115 *
     116 *  \subsection serialization-important notes Some important notes
    116117 *
    117  * \date 2011-10-31
     118 *  There are a few things that one needs to be aware of: Otherwise easily
     119 *  a stupid mistake is introduced that is trivial once understand but hard
     120 *  to find otherwise. This is especially so because compiler errors with
     121 *  respect to the serialization part are always length (whole page) and
     122 *  very hard to read:
     123 *  \li Always obtain the same type from an archive that you put into it!
     124 *    If it's been an instance, get an instance, not a ref(&) or a pointer(*)
     125 *    and also the other way round.
     126 *  \li boost::serialization always uses the default constructor of your class
     127 *    that is afterwards filled with state information stored. If your default
     128 *    constructor is unusable, something goes wrong here. There are two ways
     129 *    out:
     130 *    -# Write a private default constructor. Also you might have to split
     131 *      serialize() into load() and save() and do some additional stuff in
     132 *      load().
     133 *    -# one can write save_construct_data() and load_construct_data() directly
     134 *      as is explained in the boost::serialization documentation on
     135 *      constructors (as of 1.47).
     136 *  \li Const members are a problem as they can only be written during the
     137 *    constructor and as always the default cstor is used ... however, wiggle
     138 *    around by casting it to non-const, e.g.
     139 *    \code
     140 *    const foo foo_instance;
     141 *    ...
     142 *    const_cast<foo &>(foo_instance);
     143 *    \endcode
     144 *    Alternatively, you could place const variables in an extra class (and
     145 *    non-const there), make them available only via a getter. Hence, they
     146 *    would still be const in your main class but could be serialized without
     147 *    any trouble.
     148 *  \li When you want to serialize a derived class, also the base class state
     149 *    has to be serialized, this is done via
     150 *    \code
     151 *    boost::serialization::base_object<base type>(*this);
     152 *    \endcode
     153 *
     154 *
     155 * \date 2011-11-01
    118156 */
Note: See TracChangeset for help on using the changeset viewer.