Gromacs: gmx::ICheckpointHelperClient Class Reference

Client that needs to store data during checkpointing.

Clients receive a CheckpointData object for reading and writing. Note that ReadCheckpointData is a typedef for CheckpointData<CheckpointDataOperation::Read>, and WriteCheckpointData is a typedef for CheckpointData<CheckpointDataOperation::Write>. This allows clients to write a single templated function, e.g. template<CheckpointDataOperation operation> void doCheckpointData(CheckpointData<operation>* checkpointData, const t_commrec* cr) { checkpointData->scalar(“important value”, &value_); } for both checkpoint reading and writing. This function can then be dispatched from the interface functions, void writeCheckpoint(WriteCheckpointData checkpointData, const t_commrec* cr) { doCheckpointData<CheckpointDataOperation::Write>(&checkpointData, cr); } void readCheckpoint(ReadCheckpointData checkpointData, const t_commrec* cr) { doCheckpointData<CheckpointDataOperation::Read>(&checkpointData, cr); } This reduces code duplication and ensures that reading and writing operations will not get out of sync.

Read more here: Source link