Changeset caece4 for src/documentation/constructs/serialization.dox
- Timestamp:
- May 20, 2014, 9:14:56 AM (11 years ago)
- 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:
- 6029a6
- Parents:
- 74459a
- git-author:
- Frederik Heber <heber@…> (03/20/14 17:23:35)
- git-committer:
- Frederik Heber <heber@…> (05/20/14 09:14:56)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/documentation/constructs/serialization.dox
r74459a rcaece4 17 17 /** \page serialization Serialization 18 18 * 19 * Serialization is a mighty concept. Th eis only possible within an object-19 * Serialization is a mighty concept. This is only possible within an object- 20 20 * oriented framework. The member variables of a class make up its internal 21 21 * state. By storing this state, creating another instance and restoring … … 23 23 * we obtain additional control as to the moment of restoration because the 24 24 * internal state is stored temporarily. To allow for this storage all of 25 * these variables have to be \e serializ ed.25 * these variables have to be \e serializable. 26 26 * 27 27 * Serialization refers to putting one after another into a writable form … … 114 114 * again make it a friend). 115 115 * 116 * \subsection serialization-add-complicated The more complicated case 117 * 118 * Noted the additional \a version parameter up there in the serialize functions' 119 * signature? When classes change, we might still want to be able to parse in 120 * older states. As as state is always written to a default constructed object. 121 * this is possible. You can check the version variable like this to make your 122 * function compatible with older functions. 123 * 124 * \code 125 * void serialize(Archive & ar, const unsigned int version) const 126 * { 127 * ar & content; 128 * if (version > 0) 129 * are & newcontent; 130 * } 131 * ... 132 * double newcontent; 133 * }; 134 * \endcode 135 * 136 * The version itself is set as follows, 137 * \code 138 * BOOST_CLASS_VERSION(foo, 1) 139 * \endcode 140 * where you give the name of your class and the version. 141 * 116 142 * \subsection serialization-important notes Some important notes 117 143 * … … 119 145 * a stupid mistake is introduced that is trivial once understand but hard 120 146 * to find otherwise. This is especially so because compiler errors with 121 * respect to the serialization part are always length (whole page) and147 * respect to the serialization part are always lengthy (whole page) and 122 148 * very hard to read: 123 149 * \li Always obtain the same type from an archive that you put into it! … … 151 177 * boost::serialization::base_object<base type>(*this); 152 178 * \endcode 179 * \li When you have code in header and implementation module, boost might get 180 confused, use \code BOOST_CLASS_EXPORT_KEY(foo) \endcode and 181 \code BOOST_CLASS_EXPORT_IMPLEMENT(foo) \encode for this. 182 * \li The only other issues encountered so far is that a class needs to get 183 * instantiated. Otherwise its (templated) serialization code is not present. 184 * There are ..._EXPORT keywords in boost::serialization for this. Similarly 185 * required when just the base class is created/instantiated but you also need 186 * derived classes. 187 * \li The boost::serialization documentation is in general quite helpful. Use 188 * above mentioned keywords to look for more information. 153 189 * 154 190 * 155 * \date 201 1-11-01191 * \date 2014-03-10 156 192 */
Note:
See TracChangeset
for help on using the changeset viewer.